working on smooth scrolling in a virtualized list is so satisfying 😎
Conversation
Using Riffle, every single scroll event in that list view results in a SQLite database write, which reactively updates the visible window of tracks w/ a LIMIT/OFFSET. Putting the DB in the loop at ~60fps!
3
1
29
Replying to
Are you not concerned that will cause excessive wear on SSDs? How much actual disk IO results from each disk write?
1
1
Yep... how long is this data required to persist? Is there no storage option between "gone if you close window" and "etched with ACID for all time"?
Apple got dinged a while back for wearing their M1 Mac SSDs with excessive swapouts; doubt anyone wants that surprise again.
1
the SSD wear thing is interesting, hadn't considered that!
there's a big design space here, have done persist-by-default so far because it's simplest. "don't persist at all" is also easy and makes sense sometimes.
i guess maybe could periodically batch writes if really needed
2
2
I recommend you work out a way to reduce user pref type writes to no more than a couple a minute. Unlike spinny disks, SSDs have to write at least a page every single time a bit changes. If you have multiple per second you may be aging your disk, and the payoff is small.
3
3
I don't know much about SSDs, but my naive math says that this isn't a lot of write traffic in the context of a system. Any thoughts on this?
1
Let's say that an SSD page is 4 KB, so writing one of those at 60 Hz is 240 KB/s of writes (without batching). Activity Monitor says that my (mostly idle) Mac is doing between 5 and 60 MB/s of writes, so this is increasing my write traffic by somewhere between 0.4% and 5%.
1
Does that sound like the right ballpark to you, or am I totally off here?
1
There's what hits the filesystem vs what hits the disk;
e.g. rewriting same file region may not drop data to disk as often.
Try running
iostat -d -I -w 5
a while and see how the total MB written to the disk device lines up with what Activity Monitor says?
60MB/sec is 5TB/day...
2
1
Ah, that does indeed give a different value. Seems like ~200 KB/s is typical. Does that seem more sensible?
Thanks for the tips: we'll use this to check that we aren't hammering the disk with too much write traffic from scrolling.


