Better HN
topnewbestaskshowjobs
Log inSign up

andersmurphy

1,011 karma · joined Feb 22, 2019 (7y ago) · 494 submissions

https://andersmurphy.com
Submissions

comment 5mo ago · link · parent

Is it slow though? Like in practice? This demo [1] using Datastar (a streaming HTML framework) every action including scrolling roundtrips to the server. Even the checkboxes changing colour is a roundtrip.

https://checkboxes.andersmurphy.com

62.

The Tao of Datastar(data-star.dev ↗)

6 points · by andersmurphy · 5mo ago · 1 comment

comment 5mo ago · link · parent

Also if anyone has a better way to do the pre-sort in Java/Clojure/JVM I'm all ears.

64.

SQLite improving performance with pre-sort(andersmurphy.com ↗)

9 points · by andersmurphy · 5mo ago · 1 comment

comment 5mo ago · link · parent

Tokenfalls! My dwarf fortress eyes read this deluge completely differently.

comment 5mo ago · link · parent

In SQLite all writes are serialisable by default and it scales really well. I think having a single writer is what makes the big difference here.

comment 6mo ago · link · parent

User permission can often be very dynamic. Sync engines (local first ones even more so) give them access to a much larger set if that data in a client side database.

This also makes them much more vulnerable to a data leak/breach if their device gets compromised or stolen as the data is all on their device.

The client having access to only what it needs in terms of data and making that as ephemeral as possible is a big part of defence in depth.

comment 6mo ago · link · parent

You don't even need your backend that close if your server is fast enough. Streaming HTML immediate mode is pretty good. See this demo (server is in Germany and runs on a potato uses no optimistic updates, eveb scroll round trips) [1]

Honestly client side animations go a long way to masking latency too.

- [1] https://checkboxes.andersmurphy.com/

comment 6mo ago · link · parent

Sync engines are fast to a point but if you start working with large enough datasets and/or care about security you ultimately end up with something closer to streaming immediate mode HTML. Of course that means sacrificing local first.

comment 6mo ago · link · parent

Although not as prominent as insert SELECT and UPDATE both benefit from page cache locality, assuming rows that are stored near each other are often selected/updated together.

comment 6mo ago · link · parent

An insignificant amount for the comparison (why I didn't mention it), it's a fast implementation and the JVM C2 JIT has kicked in by the time the first batch has completed.

comment 6mo ago · link · parent

I've updated the article with the correct rowid alias (integer not int) so the rowid version is now 715ms. I've also added an example of rowid and a secondary index UUID4, and that also seems to be bad for performance (as although it's not a clustered index it's still random inserts into a b-tree).

comment 6mo ago · link · parent

Update the article there's now a section for UUID4 with rowid. It's less bad than UUID4 without rowid but it's still about 4-6x slower than UUID7 without rowid.

comment 6mo ago · link · parent

Yeah that was just a holdover from when I was playing with smaller batch sizes. It's not in the actual linked source.

comment 6mo ago · link · parent

That's a good question. I don't know the answer. I will say, generally you can get higher write throughput with a single writer. Even more so if you're prepared to shard along boundaries where you don't need atomic transactions.

Contention and coordination are real killers, concurrent writes (that require coordination like postgres) often underdeliver.

comment 6mo ago · link · parent

Yes this matters even more if you are doing a lot of joins. Naive string UUIDs are 32 bytes (though I use binary uuid in the post which is 16) compared to 8 bytes for a 64-bit int. This matters even more with sqlite as it uses varint encoding. The upshot of all this is your indexes take up a lot less space in memory.

comment 6mo ago · link · parent

It's running on an M1 mac with synchronous full. Wouldn't surprise me if it's possible to get higher numbers.

comment 6mo ago · link · parent

Yes it's writing to disk (on a M1 mac which has terribly slow fsync). But, because of the transaction the fsync dance is done once per batch. Each row is the id + a 50 byte data blob.

There's only one index so there's no real write amplification. The numbers will go down as you add more data and indexes.

comment 6mo ago · link · parent

You don't even need to that. SQLite auto increments the ids and is a single writer (which you should be coordinating at the application level.

Regular rowids are definitely the way to go if you can use them.

comment 6mo ago · link · parent

This is actually a draft. I Wanted to add more details about how this changes with row size etc. I might get time to update it later today.

comment 6mo ago · link · parent

Datalog is the dream. But SQL with a good query builder like Clojure's honeysql is not so bad.

That and SQLite seems to be able to scale to almost any problem, is disgustingly fast and with litestream incredibly resilient.

comment 6mo ago · link · parent

This a thousand times. The bigger models also have a habit of overcomplicating things.

comment 6mo ago · link · parent

I believe the point they were making is you can have millions of virtual threads on the JVM no problem. Your information on the JVM is outdated.

comment 6mo ago · link · parent

Really clever!

comment 6mo ago · link · parent

Seems like a pretty close copy of Carson's (of HTMX fame) agent.md from 5 months ago

https://gist.github.com/1cg/a6c6f2276a1fe5ee172282580a44a7ac

comment 6mo ago · link · parent

:cache_size 1562

:page_size 4096

:journal_mode "WAL"

:synchronous "NORMAL"

:temp_store "MEMORY"

:busy_timeout 5000

(Synchronous FULL in context where it matters)

But, it depends on the shape of your data, your indexes, how much of the data you care about is filling up a page. If your distribution is more even you sometimes need more cache than a more Pareto distributed data set etc. Things like not caching prepared statements costs you more (you should almost always be caching prepared statements per connection with sqlite).

You have to give things more thought at a billion sure. Partial indexes are your friend. You'll also want more cache to prevent thrashing etc.

- https://andersmurphy.com/2025/12/02/100000-tps-over-a-billio...

comment 6mo ago · link · parent

You mean 100k+ right?

comment 6mo ago · link · parent

Seems fine at billions of rows in my experience.

comment 6mo ago · link · parent

It doesn't block reads. Single writer systems are often faster than concurrent writers no coordination overhead and you can batch.
12345
17