And yes if you have something in memory is likely the same or faster when using a hashmap, but performance isn’t a one dimensional thing like comparing btree to hashmap performance. It’s the entire system as a whole. For instance, the binary note format is cpu cache friendly. Even just switching to that in damus ios helped perf immensely.

A lot of the computational things involved in note processing is amortized by having it done up front in the nostrdb and stored forever. Things like note content parsing (contents are chopped up into blocks, these are just offsets into the contents tagged with a type (url, hashtag, etc), stat counting, etc. i’m also going to add and store minimal perfect hashmaps for efficient mute word checking.

Just having these data structures near the note in memory and available to any app without duplicate processing was another motivation.

notedeck is a realtime system, i can’t have it do any work on the render thread. The render path has to be as fast as possible, it has forced me to move all of the computational upfront work into the nostrdb ingester pool.

This results in a smooth scrolling experience because the render thread is just accessing pointers to data that has already been processed.

Anyway, just trying to point out that hyper fixating on one component of the system would be misleading, as it was specifically designed for performance at every level.

If you want to check performance just run notedeck, you will see the results.

Reply to this note

Please Login to reply.

Discussion

Agree, we don't use the render path either. Though I lazy load/compute the additional data structure (like the text parsing) only when the event is being placed in the same page that will be rendered. And those can be discarded individually by the GC after the event is old/not used anymore. Same for decryptions.

Don't get me wrong. I think notedeck is fast. My only concern is "at what cost" (increased disk usage, increased memory usage). Exactly by how much is very unclear right now.

Keep pushing.

> Though I lazy load/compute the additional data structure (like the text parsing) only when the event is being placed in the same page that will be rendered

damus ios works the same way, but it is really annoying, leading to needing to recalculate the view after the parsing was done, which was janky. Now i don’t have to worry about it. If it’s in the db then it has everything it needs to render.

It definitely uses more disk space, but i just need to optimize the db on startup by removing old notes not in web of trust. I think nostur does something like this as well.

“Increased memory usage” is kind of misleading. It uses a lot of memory in the sense the page cache uses a lot of memory, but it does that anyway when reading from disk from anywhere. you can’t compare heap memory to a pagecache-backed virtual memory. They are not really the same thing. it’s more accurate to say it uses a small amount of fixed memory for the subscription queues and thats about it.

There is middle ground too, where nostrdb is used to cache certain kinds (vs everything) and the local relay is used for certain other kinds (vs always)

The main issue with the local relay is that you can't count on it so you need a database anyway