Fork me on GitHub
#datomic
<
2023-06-03
>
mx200015:06:02

Hey I was wondering if I should use datomic as an in memory database for my videogame which i am developing. The game uses an entity component system and i am finding myself thinking in terms of attributes and transactions. That would also give free time travel, replays, even multiplayer (just send transactions to the players). It should not be a huge game , a rpg roguelike game and gameplay should be slow, not very quick, about 10-30 updates a second would be enough. a few hundred entities max, usually much less. How much writes are possible in a second ?

leifericf05:06:46

@U07FCNURX has done something like this for his text-based game engine for Aventur Delux: https://www.adventur.no

magnars07:06:58

For sure, Datomic has been a perfect database for my game, particularly because the main character has the ability to time travel.

datomic 1
leifericf12:06:49

I'm playing your game now and it's awesome! And super addictive 😅 Your writing skills might be on par with your Clojure skills! Very cool.

🙏 2
Daniel Tan13:06:16

FYI i tried doing it but the latency was too high on local, and even higher on networking

1
Daniel Tan13:06:45

i’ve now rewritten my ECS in pure clojure data structures backed by duratom

1
mx200010:06:33

@U01458A7CBX do mind to share your ecs or game? What do you mean with latency was too high? Did you queue transactions till the end of a frame? Read latency ?

Daniel Tan10:06:00

Yes, i queued incoming entities/messages until end of frame and processed them. Read/write latency was ok for web apps, but processing hundreds of entities per frame already took around 50-100ms or more so it was unacceptable for a networked game

mx200013:06:16

But wouldn't be both things possible? Just a server using just refs or atoms for speed and at the end of a frame sending transactions to the db? Then every update tick the server sends only the transactions to the client , which does not use datomic ?

Daniel Tan13:06:35

yeah, so there’s really not much use for datomic except maybe as a durable data store

Daniel Tan13:06:05

the players already can get atomic updates via ecs if you structure it to emit effects to the client

mx200013:06:02

As a transaction store I guess

Daniel Tan13:06:03

currently im able to serve game updates at 60 fps on local so thats good enough for me

mx200013:06:19

Would you mind sharing your ECS design or code or what you are working on?

Daniel Tan13:06:33

i’m still in the process of rewriting it, but here’s the core https://gist.github.com/danieltanfh95/1a601090059db22a3303bd04791a7c94

mx200017:06:59

And what kind of Game? I am developing a roguelike rpg

Daniel Tan09:06:27

@U0ALH6R89 im writing a small hack and slash mmorpg

Ben Sless05:06:11

A slightly different take on this is using a rules engine https://github.com/oakes/odoyle-rules

mx200015:06:09

Here it says millions of writes a second possible Datomic processes write transactions by sending them to a transactor via queue, which is currently HornetQ. Hornet claims to be able to do millions a second with SpecJms2007. https://www.dotkam.com/2013/05/31/datomic-can-simple-be-also-fast/

favila16:06:34

What you are reading there is about datomic using an actual durable storage

favila16:06:10

The in-memory storage of datomic-pro is designed for testing, and I think it’s synchronous. I doubt much thought was given to its performance

favila16:06:14

Consider alternatives like datomic dev-local (another product which uses a local on-disk storage with cloud semantics), or if you are willing to give up history: datascript (datomic inspired, but in memory and runs on more platforms) or datalevin (durable via lmdb) or others

favila16:06:02

That said datomic-pro in-memory may be fine but it’s not the typical use

mx200015:06:55

I guess synchronous writes would be a problem?

favila16:06:02

Sync writes are only a problem if they take too long :) You can always do your own queueing if you need the caller not to block