You don’t cache anything for live search?

Reply to this note

Please Login to reply.

Discussion

we cache the note primary keys thats about it, every frame we query the data fresh from nostrdb and the frame buffer is built directly from nostrdb virtual memory. Takes about 1ms.

How does nostrdb work?

from our readme:

The unfairly fast nostr database backed by lmdb.

nostrdb stores nostr events as a custom in-memory representation that enables zero-copy and O(1) access to all note fields. This is similar to flatbuffers but it is custom built for nostr events.

These events are then memory-mapped inside lmdb, enabling insanely fast, zero-copy access and querying.

This entire design of nostrdb is copied almost entirely from strfry, the fastest nostr relay. The difference is that nostrdb is meant to be embeddable as a C library into any application with full nostr query support.

https://github.com/damus-io/nostrdb

basically queries just return pointers to memory aligned structs stored on disk. so no copying data in out. lmdb queries are so fast (its like an in-memory btree lookup), so this gives you an "infinitely" large external memory for nostr notes, powered by the operating systems virtual memory infrastructure.

Ok Ive been toying with a similar implementation but this one is all in ram, doesn’t touch disk. Can store about 3-6 million notes easily

when you use something like lmdb you can let the OS reclaim old pages when under memory pressure. so its a bit nicer and you don't have to worry about the size of the database