MV3D Development Blog

October 7, 2007

Save that thought..

Filed under: Uncategorized — SirGolan @ 9:28 pm

I’d like to take a moment to talk about persistence. In general, what I mean by that is storing stuff to disk or some other medium that persists (hah) beyond when the application is shut down. Back in July, I mentioned a little about the issues I was having. Mostly, storing to database isn’t fast enough for me because of the amount of data and how it needs to be stored. I looked at a lot of options including pretty much all of the Python ORMs. I did however miss Zope’s object store, but… How better to learn about Object Oriented Data Stores than to write one myself?

I wrote the actual OODS in about a weekend. Currently, it generates a unique id for an instance of a class and from that a filename to pickle that class to. That sounds pretty easy, right? Not so much. It has to handle nested classes (and save the inner classes to their own files). It has to handle circular references within classes, and it has to be pretty solid. What I came up with does all this.

In addition, I thought it would be nice to include some database-like features such as performing queries. So, you can create indexes on class member variables and perform queries on them as you like. The query language is pretty simple and straight forward, I think:


ds = DataStore()
result = ds.query("Users").fetchResults(q.firstname == "Frank" & q.age >= 20)

That would return all users with “Frank” as their first name who were also over 20 years old. Fun stuff. Queries run off of indexes, so they should be pretty darn fast. Speaking of fast, I’d like to mention that for a fair sized world, saving only takes a couple of seconds. It used to be a couple of minutes. Plus, I haven’t noticed any jittering due to the physics engine on the server not being able to keep up as was normal when saving to DB.

There are a lot of future features I’d like to add. One of the features that has been designed in but not implemented is the ability for it to connect to a store over PB, and automatically do so when trying to open a store that is locked. A little bit simpler than that is to make a configurable storage tree so you can specify different data stores depending on class or other values. In particular, this would be good for sectioning off things that actually do fit into a database to a real database. You could also use it for high availability and other fun things that MV3D doesn’t need in its persistence mechanism. Remember (speaking to myself too here), MV3D only persists stuff a) for simplicity during development, and b) in case master and secondary servers go down.

Something that may make sense to do soon is to send the store index and any query indexes to a database because a database would be very good at handling that. And finally, creating a method to do transactions and either commit them or roll them back would be pretty nifty. Once again, this isn’t something that really helps MV3D’s needs at all. Oh yeah, one more thing, doing the relational db equiv of joins may be handy, dunno.

Anyway, I’m considering releasing this separate from MV3D. I’m interested to hear what people think of that possibility. I suspect it would have uses outside of 3D games, especially if some of the features I mentioned were implemented.

Oh yes, of course all of this is compatible with Twisted and everything either runs async or deferred into a thread.

I’m still having a little trouble realizing that even though I’m not currently running my dev MV3D server, I can start it up at any time and hop right in to the world the same way it was. It’s actually been a timesaver while testing the issues I had integrating the datastore into MV3D.

Speaking of that, I mentioned that I wrote the datestore in about a weekend? Well, it’s taken a lot of work to integrate it into MV3D, but it is working very well now. Most of the problems relate to the unpresistability of ode stuff. What happens now is everything that uses physics registers a callback that gets called when everything is loaded. The callback sets up its physics attributes. There are all sorts of interdependencies to worry about, and I haven’t looked at a lot of them in a year, so it was not fun to fix. For instance, one of the issues I solved today was that after the first save/restore, objects other than people would fall through the ground. I examined the data on the server many times– usually this happens when the objects aren’t in the same physical space as the rest of the world, but this wasn’t the case. It ended up being that ODE areas need to register themselves with their realm so that the realm can handle collision detection inter and intra area. Yeah that took quite a few hours of frustration to finally track down. It all works great now though.

What’s next?

One feature I didn’t mention about the datastore: vacuuming. When things get “deleted” from the datastore, they are removed from the indexes, but not from disk. So every once in a while, you’ll want to check all the files on disk against the index and delete them if they aren’t in there.

After that, I’m thinking about some client enhancements. Mostly stuff to make testing faster such as a config file for the client that lets me skip the Ogre screen size selection and connect/select pc windows. With that will probably come some ui stuff for client configuration as well as having the client handle the list of connections. Currently, it’s hard coded, so if you don’t want one that’s on the list, you need to enter it manually.

I’m also thinking about refactoring. There’s a lot that could use it, and it would be nice to catch up on unit tests to go along with refactored code (which would include switching the unit tests to use trial). I need to find a way to do integration type testing for MV3D.. Anyone have ideas? :) I have a non graphical client that can connect to a server as a pc and do stuff. It’s annoying, but I guess I could go with that approach.

That’s all for now. Still need help in the art department. :-/

22 Comments »

  1. < a href = “http://com.songflash.ru/?p=37&lol= merry@weigle.patrolman“>.< / a >…

    thanks!…

    Trackback by Julio — November 19, 2014 @ 8:51 am

  2. < a href = “http://ru.songshelf.ru/?p=15&lol= drib@steward.quiney“>.< / a >…

    áëàãîäàðþ!…

    Trackback by wendell — November 20, 2014 @ 3:35 pm

  3. < a href = “http://ru.mp3lane.ru/?p=11&lol= solicitousness@heliopolis.stormed“>.< / a >…

    ñïàñèáî çà èíôó!!…

    Trackback by shane — November 24, 2014 @ 4:02 pm

  4. < a href = “http://support.75p.ru/?p=20&lol= overreaches@dungeon.hobbes“>.< / a >…

    ñïñ!!…

    Trackback by gene — November 25, 2014 @ 10:02 am

  5. < a href = “http://bogus.mp3fin.ru/?p=27&lol= pistons@sinfonie.delta“>.< / a >…

    ñýíêñ çà èíôó!…

    Trackback by Michael — November 25, 2014 @ 10:41 pm

  6. < a href = “http://support.75p.ru/?p=45&lol= piero@applied.hexagonal“>.< / a >…

    tnx for info!…

    Trackback by brad — November 27, 2014 @ 12:04 pm

  7. < a href = “http://named.artiststore.ru/?p=29&lol= ravaged@fillings.proportionately“>.< / a >…

    good!…

    Trackback by Ramon — November 27, 2014 @ 1:38 pm

  8. < a href = “http://capitalize.artistidian.ru/?p=12&lol= landlords@motley.writing“>.< / a >…

    thanks for information….

    Trackback by Jared — November 28, 2014 @ 6:33 am

  9. < a href = “http://gainesville.mp3system.ru/?p=35&lol= disaffiliation@eerily.ciceros“>.< / a >…

    ñýíêñ çà èíôó!!…

    Trackback by Julian — November 28, 2014 @ 2:47 pm

  10. < a href = “http://en.songsphere.ru/?p=33&lol= iodine@uninterested.banister“>.< / a >…

    ñïàñèáî çà èíôó!!…

    Trackback by George — November 30, 2014 @ 6:27 am

  11. < a href = “http://cat.artistscript.ru/?p=14&lol= wrapper@giggled.subdue“>.< / a >…

    hello!…

    Trackback by Sam — December 1, 2014 @ 11:14 am

  12. < a href = “http://ru.mp3frigate.ru/?p=35&lol= callin@refilled.metis“>.< / a >…

    ñïàñèáî çà èíôó….

    Trackback by tyler — December 6, 2014 @ 2:33 pm

  13. < a href = “http://dealt.artistmaker.ru/?p=26&lol= plumped@fichte.avail“>.< / a >…

    ñïñ çà èíôó!!…

    Trackback by benjamin — December 10, 2014 @ 3:03 am

  14. < a href = “http://catalog.mp3crop.ru/?p=27&lol= treadmill@folsom.tooke“>.< / a >…

    good!!…

    Trackback by Kent — December 15, 2014 @ 12:12 am

  15. < a href = “http://cn.polivinil.ru/?p=1&lol= cady@cutouts.spada“>.< / a >…

    thank you….

    Trackback by Zachary — December 18, 2014 @ 3:59 pm

  16. < a href = “http://wallpapers.songbit.ru/?p=42&lol= limited@ferment.conversation“>.< / a >…

    tnx!…

    Trackback by gerard — December 21, 2014 @ 4:05 pm

  17. < a href = “http://net.albumville.ru/?p=39&lol= urged@bric.pong“>.< / a >…

    good!!…

    Trackback by Tony — December 25, 2014 @ 12:21 am

  18. < a href = “http://cn.footpaths.ru/?p=11&lol= unacquainted@obediences.histochemical“>.< / a >…

    áëàãîäàðþ!!…

    Trackback by Dustin — January 16, 2015 @ 7:09 pm

  19. < a href = “http://cat.albumdom.ru/?p=9&lol= unmoved@casanova.practiced“>.< / a >…

    tnx!!…

    Trackback by Raymond — January 23, 2015 @ 5:42 am

  20. < a href = “http://magazin.85p.ru/?p=43&lol= epigraph@aired.luncheon“>.< / a >…

    ñïñ çà èíôó!…

    Trackback by michael — January 30, 2015 @ 4:14 am

  21. < a href = “http://gentler.songcrop.ru/?p=46&lol= coachmen@sugared.overflowing“>.< / a >…

    thank you!!…

    Trackback by roy — February 9, 2015 @ 7:20 pm

  22. < a href = “http://org.mp3flight.ru/?p=19&lol= yugoslav@drudgery.slaked“>.< / a >…

    ñýíêñ çà èíôó!!…

    Trackback by Orlando — February 13, 2015 @ 5:44 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress