Fork me on GitHub

I might be coming up against a bug in Datomic here. I am doing a pull call against an as-of db value, and Datomic seems to be doing a full db scan.


(time (d/pull (d/as-of db 13194152884511) '[*] 17592199395616))
"Elapsed time: 127993.736043 msecs"


(time (d/touch (d/entity (d/as-of db 13194152884511) 17592199395616)))
"Elapsed time: 0.844873 msecs”


Does the same thing basically, but the pull version takes forever. When doing the pull against the current db there is no problem.


@bkamphaus: Mind taking a look at this one you get on?

Ben Kamphaus13:03:20

@casperc one big difference between pull and entity is that entity is lazy. So the entity call isn’t really measuring any retrieval. Are there a lot of component refs? If there are, depending on the size of the graph implied by component refs from the starting entity, a wildcard pull could result in a lot of work.


Yeah, but I am doing a touch, doesn’t that fetch all the datums that are lazy?

Ben Kamphaus13:03:48

gah, reading. Yes.


And it doesn’t actually have any component refs in the mix simple_smile

Ben Kamphaus13:03:12

Have you restarted and tested in isolation?

Ben Kamphaus13:03:28

I.e. is entity taking advantage of pull’s having cached segments?

Ben Kamphaus13:03:39

Or are both hot cache examples.


The database does have alot of data in it though, 5M of that type and about 20M entities in total. Dunno if that makes a difference.


Both are hot in the sense that pull takes a long time regardless of doing it right after entity or a previous (slow) pull.


And it takes up alot of CPU on the peer with the pull, so I think it must be missing an index somehow.


Just retested from a cold start again, and it is the same. And the peer is fetching alot of data on top of the CPU usage, even though it should be cached (via the previous entity/touch call)

Ben Kamphaus13:03:23

which version of Datomic are you using?


[com.datomic/datomic-pro "0.9.5344"]


My process is at 1,08 GB received from just having done those two calls simple_smile

Ben Kamphaus14:03:48

I can’t repro a disparity in performance like that with any of the large dbs I have availably locally. I suspect there’s something specific to your data or schema that’s hitting a corner case. Quick sanity check - are you essentially getting the same results out of both? E.g. checking count and contents of each returned map? You can (into {:db/id ent-id} (d/entity asofdb ent-id)) to put the data into a map similar to what pull returns (except differing re: some retrieval behavior and ident resolution).


Just checking. Count is the same

(= (keys ent-res-map) (keys pull-res))


But equallity is false for some reason, let me just check why

(= ent-res-map pull-res)

Ben Kamphaus14:03:37

{:db/id ...} vs ident probably.


It is due to a ref in the entity map being a datomic.query.EntityMap not clojure.lang.PersistentArrayMap like from the pull


Otherwise they are equal


(count ent-res-map)


I should mention that there is only the one tx on the entity i am pulling, so pulling from the current db actually gives the same result as pulling from the as-of db. Dunno if that could be the edge case being hit, given that for most uses you would just use the current db value.

Ben Kamphaus14:03:54

I wouldn’t expect that to matter and that was true for the first local repro I tried.


So any way to debug this? I’d be happy to take it in a private convo or file a bug to avoid spamming the channel.

Ben Kamphaus14:03:53

Following up in private message.


I built a spreadsheet like clojurescript app using OT and using datomic for persistence. every key stroke is sent to datomic. It works well but I want to get feed back if this is a good use case for datomic. I'm afraid the transactor cannot handle the load. I like using datomic for this use case for its time model. I'd like a user to go back in time and see all changes to the data


perhaps git is a better use case for this? but i'd like the user to be able to query the data as well


this looks interesting and probably would work better for OT use case than datomic


Just throwing it out here. Yesterday I was setting up my first project using Datomic Pro and I noticed that when I do lein run the process will hang, but if I start the repl with lein repl or cider-jack-in, I get the gpg password request and then I can start the server from the repl. It seems like the lein run somehow blocks the gpg auth popup or just doesn’t know how to do that.


@kingoftheknoll: strange. i've never had that experience. I'm using boot but that shouldnt make a difference. what is your DB URL?


Not actually requiring anything in yet.


Just loading the deps


I mean I can get around it and I’ve testing that I can use datomic in the repl with an in memory db but just can’t start my ring server with lein run


kingoftheknoll no error messages?


nope just hangs

Ben Kamphaus17:03:47

@kingoftheknoll: I always get gpg prompting rather than indefinite hanging when I use it (though it hangs a little sometimes). That said, a workaround that bypasses the entire process is to download the distribution and run bin/maven-install - it will put the dep in your local maven and then you don’t need repo+creds in lein.


does that mean I don’t need to include it as a dep in project.clj?


wait, I think I’ve already done that

Ben Kamphaus17:03:17

You’ll still have: [com.datomic/datomic-pro "0.9.5350”] in the :dependencies list, it will just find it in your local maven.


what about making a jar file, would it bundle the dep from maven for me?


^ sheer ignorance here sorry


@sonnyto - did you do a write up about your app anywhere? sounds interesting


@dm3 no but I would like to opensource it later

Ben Kamphaus19:03:30

@kingoftheknoll: ls ~/.m2/repository/com/datomic/datomic-pro/0.9.5350


@sonnyto: Please be aware that gitalin is highly unfinished. 😉


@jannis: have you played with it?


@sonnyto: I only tried it last week.


@sonnyto: Just kidding, I'm the author. 😉


it looks cool and woudld fit my use case nicely


If you can call me that, since it's so unfinished...