Live data from Hacker News

Honker – Durable queues, streams, pub/sub, and cron scheduler in a SQLite file

honker.dev

51–60 of 69 posts

Re: Honker – Durable queues, streams, pub/sub, and cron scheduler in a SQLite file

#51

Could this work with Turso, the SQLite rust rewrite?

Author here. Yeah doesn’t depend on the underlying db if it speaks SQLite.

I think this is interesting too sqlite a as the coordination boundary: business state, queue state, stream offsets, retries, and acks all sharing one transactional substrate. The 1ms polling is getting a lot of weight in the thread though :)

Re: Honker – Durable queues, streams, pub/sub, and cron scheduler in a SQLite file

#54
post #35

Earlier quoted context omitted.

That only catches changes made by the database connection being "hooked." This has a thread running in the background trying to catch changes made by other connections, potentially (I'm not sure here, but I suspect as much) in different processes that are modifying the same database.

good point. but ime and as seems to be widely understood writing from multiple connections is a bit of a minefield in SQLite. and afaik it still would be possible to have a hook on all connections you expect to be writing?

i did a quick benchmark on this with a single db connection updating user_version in a tight loop with the wal_hook callback enabled.

on my crappy old i5 with the db file on /dev/shm it can do ~150k writes a second with the wal_hook callback called on every write. and this is using JS bindings to C++ so has some unnecessary overhead.

Re: Honker – Durable queues, streams, pub/sub, and cron scheduler in a SQLite file

#58
post #35

Earlier quoted context omitted.

That only catches changes made by the database connection being "hooked." This has a thread running in the background trying to catch changes made by other connections, potentially (I'm not sure here, but I suspect as much) in different processes that are modifying the same database.

good point. but ime and as seems to be widely understood writing from multiple connections is a bit of a minefield in SQLite. and afaik it still would be possible to have a hook on all connections you expect to be writing?

That wouldn't work across processes. And if you only care about in-process queuing then you might find it easier/faster to use another kind of storage or roll your own WAL.

Re: Honker – Durable queues, streams, pub/sub, and cron scheduler in a SQLite file

#59
post #12
post #10

Earlier quoted context omitted.

Yeah, I had the same instinct - this feels very much like a "nice idea" but the execution falls short. I mean - busily banging on sqlite like this? Shit at that point just use Redis.

What's the CPU usage? Like 2%? I had a manual fs polling thing a while back. It was ugly (low time budget, didn't wanna mess with the native watchers), just scanned the whole thing once per second. It averaged out to like 0.3% CPU. Not elegant, but acceptable for my purposes! (Small-ish directory, and "ping me within a second or two" was realtime enough for this use case.)

If this stops the core being able to drop to a lower power state it can be whole multiples of power use on some devices.

Wake ups are death for mobile form factors, even if not really doing much work.

Re: Honker – Durable queues, streams, pub/sub, and cron scheduler in a SQLite file

#60
post #5

"Idle cost is that one lightweight SELECT per millisecond per database — no page-cache pressure, no writer-lock contention, no kernel file watcher in the mix." I think (respectfully) the LLM that probably wrote this overshot the mark here because busy-polling a select does not actually sound better to me than a "kernel file watcher".

A prepared `PRAGMA data_version` is likely quite cheap to run because it hits the same page every time…

…but some other push-based IPC mechanism would be a lot more battery friendly

Post reply on HN