asami

Asami, the graph database https://github.com/threatgrid/asami
borkdude 2020-11-12T15:24:34.086600Z

I'm running the README example:

(defn -main [& _args]
  (let [db-uri "asami:<mem://dbname>"
        _ (d/create-database db-uri)
        conn (d/connect db-uri)
        first-movies [{:movie/title "Explorers"
                       :movie/genre "adventure/comedy/family"
                       :movie/release-year 1985}
                      {:movie/title "Demolition Man"
                       :movie/genre "action/sci-fi/thriller"
                       :movie/release-year 1993}
                      {:movie/title "Johnny Mnemonic"
                       :movie/genre "cyber-punk/action"
                       :movie/release-year 1995}
                      {:movie/title "Toy Story"
                       :movie/genre "animation/adventure"
                       :movie/release-year 1995}]
        _ (d/transact conn {:tx-data first-movies})
        db (d/db conn)]
    (prn (d/q '[:find ?movie-title
                :where [?m :movie/title ?movie-title]] db)))
  ;; =&gt; ()
  (shutdown-agents))
But the query returns an empty list... did I miss something?

borkdude 2020-11-12T15:25:28.086800Z

This is with 1.2.6

borkdude 2020-11-12T15:28:37.088500Z

Ah, deref-ing the transaction did the trick:

_ @(d/transact conn {:tx-data first-movies})

borkdude 2020-11-12T15:31:11.089Z

I tried out asami with GraalVM:

$ ./asami
(["Explorers"] ["Demolition Man"] ["Johnny Mnemonic"] ["Toy Story"])

borkdude 2020-11-12T15:31:15.089200Z

works like a charm.

đź‘Ť 1
borkdude 2020-11-12T15:31:46.089700Z

Hopefully it will keep working with durable storage. It could be pretty cool to build small CLI apps that have persistent datalog storage

quoll 2020-11-12T16:10:01.090Z

I should document that. The transaction occurs in a future on the JVM, and it hasn’t had time to update the connection with the new database yet. This isn’t the case in ClojureScript, since it doesn’t use an extra thread there.

borkdude 2020-11-12T16:10:17.090200Z

Makes sense.

quoll 2020-11-12T16:24:05.090500Z

I haven’t been checking Graal while doing the durable stuff, but I hope it will. The JVM version is based on memory mapped files. I’d hope that it’s the same in Graal, but I also know that this is a rarely used feature in most Java apps

borkdude 2020-11-12T16:25:27.090700Z

We'll see :)

borkdude 2020-11-12T16:25:41.090900Z

sqlite for datalog, would be cool

đź‘Ť 1
quoll 2020-11-12T16:27:13.091100Z

It’ll be cooler when we have it seamlessly working in ClojureScript as well. That’s being developed in parallel, but with some delay as I get it going on the JVM first

🙌 1
borkdude 2020-11-12T16:28:00.091400Z

I have tried datahike with GraalVM some years ago, but couldn't get that working

quoll 2020-11-12T16:28:34.091700Z

If it ends up being a problem, then I’d be willing to work through it

borkdude 2020-11-12T16:28:38.091900Z

I remember your talk from ClojureD in 2019. Nice to see that asami came a long way since then

quoll 2020-11-12T16:29:09.092100Z

It’s weird… people keep asking me for features :rolling_on_the_floor_laughing:

quoll 2020-11-12T16:31:02.092300Z

Development has slowed right down while I build the durable storage. That’s going well though. I now have a data pool (maps data to IDs, and IDs back to data). I’m actually considering copying it out into a separate library to provide a fast key-value store

quoll 2020-11-12T16:34:04.092600Z

That would help me gather feedback on how well it’s working. So far I haven’t put more than a few MB into it

dominicm 2020-11-12T19:04:05.092900Z

I've been considering loading in a few gb of data, and moving our user system over to asami.

noprompt 2020-11-12T19:11:37.093200Z

@borkdude I have been equally excited about the prospect of using SQLite for some time now in this context. 🙂

đź‘Ť 1
quoll 2020-11-12T19:23:43.093500Z

@dominicm I can only hope it will work well. What I can say is that benchmarks with Mulgara on a 2008 notebook computer did very well up to about 20GB. After that, it started to slow as it had more and more cache misses, but it was still scaling linearly to over 100GB. This design copies a lot of Mulgara, with a few differences: • Mulgara was 100% Java. Asami is 100% Clojure. There will be some overhead, but I don’t expect it to be significant in relation to I/O. • Mulgara used additional structures to track blocks that are no longer in use so that they can be recycled. This required additional I/O. • Mulgara used 6 indexes. Asami will use 4. • Mulgara’s data pool was less space efficient. Overall, Asami will use less space, and have fewer I/O operations. It ought to be significantly faster than Mulgara, and I know that Mulgara is still considered fast, despite the codebase being nearly 20 years old!

quoll 2020-11-12T19:24:37.093700Z

So, I don’t know, but I am confident 🙂