Fork me on GitHub
#datomic
<
2021-07-29
>
zendevil.eth07:07:59

How do I use Datomic on gcp?

pedrorgirardi14:07:26

I suppose you have to run Datomic On-prem https://www.datomic.com/on-prem.html

zendevil.eth07:07:18

I want to run it on a gke pod

rgorrepati20:07:47

what is the difference between transact and transact-async when I get similar timings on the same list of txs

(time (d/transact (conn) txs)) ;; 8369 ms

  (time (d/transact-async (conn) txs)) ;;8455 ms

Joe Lane20:07:30

How many txs are you attempting to transact there?

rgorrepati20:07:29

10k, in a in-memory db.

Joe Lane20:07:14

And what is the timing if you run:

(let [conn (conn)]
     (time (d/transact conn txs))
     (time (d/transact-async conn txs)))

rgorrepati20:07:21

"Elapsed time: 8887.066625 msecs" "Elapsed time: 8879.807292 msecs"

favila20:07:51

d/transact derefs the future with a system-property-controlled timeout, then returns the future. It throws if the timeout is reached before the future resolves. d/transact-async returns the future without waiting, and lets you control deref and timeout.

favila20:07:22

what you are seeing is maybe the memory db doesn’t actually do work in another thread.

favila20:07:35

IMO d/transact should only be for convenience in the repl; d/transact-async should be in production code.

rgorrepati20:07:26

Makes sense. I just tested it with a remote db and I get "Elapsed time: 125.154958 msecs" "Elapsed time: 0.808292 msecs"

rgorrepati20:07:42

Thank you :thumbsup:

favila20:07:05

note that you should always deref the result of d/transact-async. That’s the only way you will know if the transaction succeeded or not

rgorrepati20:07:23

I wish there was a callback we could attach to it. I guess there is no way other than to maintain our threadpool of blocking threads to deref those async txs

favila20:07:10

consider using manifold: (manifold.deferred/on-realized (manifold.deferred/->deferred fut) success-cb error-cb)