Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is there some possible optimization to be made here by bucketing seconds and dropping buckets wholesale rather than having to peel off items until you find the start of the window?

You'd end up quantizing the window, but.. dunno, just spitballing here.



I had thought about that but never got around to building a sliding window that worked that way. The challenge is that then the `events/0` call might return events outside the window of time. But there is a potential performance improvement if we don't have to always be removing old events one by one.

I'll have to try improving the list implementation with "buckets"... I wonder if buckets could be represented as lists stored inside a tuple or another list...


Right, you'd end up returning one bucket too little, or one bucket too much, of your full time window, depending on what tradeoff you decided was OK to have.

And yeah, I was thinking of buckets as append-only lists that got dropped in their entirety when out of range.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: