News for hackers. Stuff that matters.
Re:Optimizing Datalog for the GPU by haolez on Tuesday November 04, 2025 @11:05AM (#45812510)
On a side note, what tools that leverage Datalog are in use by the HN crowd?

I know that Datomic[0] is very popular. I've also been playing with Clingo[1] lately.

[0] https://www.datomic.com/

[1] https://potassco.org/clingo/

Re:Optimizing Datalog for the GPU by blurbleblurble on Tuesday November 04, 2025 @11:41AM (#45812964)
Check out CozoDB, the embedded datalog-queried hybrid relational+vector+graph database written in Rust: https://www.cozodb.org/

I used it in a toy application and it was awesome.

This appears to be a dream database from the future.

Re:Optimizing Datalog for the GPU by huevosabio on Tuesday November 04, 2025 @12:20PM (#45813463)
It seems like the project has been abandoned? Last commit a year ago.
Re:Optimizing Datalog for the GPU by anonzzzies on Tuesday November 04, 2025 @02:50PM (#45815189)
Yep, bit of a shame, many nice things in it and interesting to learn from but not active.
Re:Optimizing Datalog for the GPU by blurbleblurble on Saturday November 08, 2025 @05:36AM (#45855715)
Fair point but what if it's just really solid already! :D

Idk, I'm not too worried about that, I'm eager to help out on a project like this if something came up.

Re:Optimizing Datalog for the GPU by embedding-shape on Tuesday November 04, 2025 @11:15AM (#45812637)
I have some local-first/client-side applications using datascript in ClojureScript. Used datahike (FOSS Datomic alternative) some times on the backend too, but mostly tend to use XTDB nowadays, which used to have a Datalog API but I think they removed in favor of SQL-like way instead, which was kind of a shame.
Re:Optimizing Datalog for the GPU by manoDev on Tuesday November 04, 2025 @12:46PM (#45813761)
I guess SQL is a requirement if they want to market their technology to normies.
Re:Optimizing Datalog for the GPU by zozbot234 on Tuesday November 04, 2025 @03:51PM (#45815744)
SQL can express Datalog-like queries rather easily using recursive CTE's, and even more so via the recently-added Property Graph Query syntax.
Re:Optimizing Datalog for the GPU by jitl on Tuesday November 04, 2025 @06:52PM (#45817304)
recursive CTEs suck usability-wise compared to the usual Datalog horn clause syntax. I won't speak to usability of the "datomic" kind of datalog though, that thing I haven't been able to wrap my head around.
Re:Optimizing Datalog for the GPU by chc4 on Tuesday November 04, 2025 @06:10PM (#45816960)
CodeQL compiles to the Souffle datalog engine and I use it for static analysis. I've also used ascent for a few random side projects in Rust which is very convenient.
Re:Optimizing Datalog for the GPU by jitl on Tuesday November 04, 2025 @07:00PM (#45817369)
For a while the Rust compiler's borrow checker "Polonius" was implemented with datalog using the `datafrog` engine. However, it appears to me that the in-tree version of polonius is moving away from datafrog (not enough of a rustc expert to say for sure which version of the borrow checker engine is in use)
Re:Optimizing Datalog for the GPU by arxanas on Tuesday November 04, 2025 @11:15PM (#45818985)
Just gave a talk about this: https://blog.waleedkhan.name/what-if-sql-were-good/

- Recommend Ascent (Rust only, but supports targeting WASM)

- Soufflé: good, but too hard to integrate into existing systems; lots of ergonomic problems in comparison to Ascent (can elaborate)

- CozoDB: really cool but seems to be abandoned

- Logica: have not tried it yet

Re:Optimizing Datalog for the GPU by themk on Wednesday November 05, 2025 @07:02AM (#45821937)
Would like to hear about the ergonomic problems you have with souffle. We integrate it into our rust tools quite well, and generate typesafe rust bindings to our souffle programs, allowing us to insert facts and iterate over outputs.
Re:Optimizing Datalog for the GPU by arxanas on Thursday November 06, 2025 @12:20AM (#45831775)
It's quite possible that I have different, smaller-scale problems than you have! So my feedback might not be as relevant

I wrote detailed commentary here: https://github.com/s-arash/ascent/discussions/72

Re Rust bindings and your specific comment:

- Deploying Soufflé and doing FFI is much more difficult for me in practice, just in terms of the overhead to set up a working build. (I'm not going to be able to justify setting up a Soufflé ruleset for Bazel, and then adding Rust-Soufflé binding generation, etc. at my workplace.)

- User-defined functors, or integrating normal data structures/functions/libraries into your Soufflé program, seems painful. If you're doing integrations with random existing systems, then reducing the friction here is essential. (In slide 16 of the talk, you can see how I embedded a constructive `Trace` type and a `GlobSet` into an actual Ascent value+lattice.)

- On the other hand, you might need Soufflé's component system for structuring larger programs whereas I might not (see above GitHub discussion).

Non-specifically:

- Several features like generative clauses, user-defined aggregations, lattices, etc. seem convenient in practice.

- I had worse performance with Soufflé than Ascent for my program for some query-planning reason that I couldn't figure out. I don't really know why; see https://github.com/souffle-lang/souffle/discussions/2557

Re:Optimizing Datalog for the GPU by kmicinski on Thursday November 06, 2025 @12:50PM (#45838020)
> - I had worse performance with Soufflé than Ascent for my program for some query-planning reason that I couldn't figure out. I don't really know why; see https://github.com/souffle-lang/souffle/discussions/2557

I think the basic issue is that ADTs are simply not indexed--so to the degree that you write a query that would necessitate an index on a subtree of an ADT, you will face asymptotic blowup, as the way ADTs work will force you to scan-then-test across all ADTs (associated with that top-level tag). The issue is discussed in Section 5.2 of this paper here: https://arxiv.org/pdf/2411.14330

Re:Optimizing Datalog for the GPU by arxanas on Thursday November 06, 2025 @01:46PM (#45838779)
Ah, yes, but I think Ascent also doesn't index ADTs. In this case, based on some other information, it seems like Soufflé _can_ plan the queries better if it has profiling data. It seems like Ascent just happened to pick a better query plan in my case without the profiling data.

Thanks for the link to the paper!

Re:Optimizing Datalog for the GPU by kmicinski on Thursday November 06, 2025 @02:04PM (#45838978)
It's true that Ascent does not index ADTs either, but there are some tricks that you can use when you control the container type to get similar performance by, e.g., storing a pre-computed hash. I believe Arash, the main author of Ascent, was exploiting this trick for Rc<...> members and seeing good performance gains. It is a bit nuanced, you're right that Ascent doesn't pervasively index ADTs out of the box for sure.