wtaysom11/24/2022, 6:58 AM
The key realization: it's a trickle of reads to disk replacing an unbounded amount of stuff that's just always hanging around in memory.So you were doing some unhelpful work? Disk reads to refresh data that wasn't actively being used? In a way GC issues seem to be a symptom of the general problem that certain program aspects, like performance, are pretty opaque.
GC merely allows you to reduce the ceremony of deallocation.A good way to put it. A problem with deallocation and naive GC is that the concern is too fine-grained. Things like stack allocation and garbage generations can help. I recall Lua handles it's closures relatively cleverly using "upvalues." The gist, if I remember, being that (1) you don't even need to make closure if a function stays within its the lexical scope of its creation, and (2) when you do close you only keep references to necessary variables around other things, the rest of the lexical environment of the function definition can go away.
So you were doing some unhelpful work? Disk reads to refresh data that wasn't actively being used?The key commit is https://git.sr.ht/~akkartik/pensieve.love/commit/af7fba3263fbbdd1168ce7c941f9c6f79fca63d8 I have around 9GB of notes on disk (including all my mail for over a decade, chat logs, stuff like that). But only a tiny sliver of them are on the surface at any time. Currently around 120 columns. Far less than 50 notes/files per column, average file size per note is probably less than 5KB. Before this change, I was loading everything on the surface at startup and holding it until I closed notes/columns from the surface. With this strategy, the heap footprint according to
(https://www.lua.org/manual/5.1/manual.html#pdf-collectgarbage) was between 10 and 20MB. Initial load seemed instantaneous. The commit above eagerly throws away file data that isn't in notes showing on screen right now. When the viewport moves, I load any newly visible files, and throw away any files that are no longer visible. I continue to retain all metadata. It's just the raw strings that take up a lot of space. Now my footprint is halved. But the key metric is how often I find myself distracted by what I'm doing to fix my note-taking system. Today I didn't perceive any sluggishness where earlier things would slow down any time I was editing a note with more than a couple of sentences. I think the full GC might be a lot less frequent now. (I'm still seeing some signs of collection every second or so; see screenshot.)
Jack Rusher11/29/2022, 8:38 AM
Jack Rusher11/29/2022, 10:36 AM