Looking at the SIEVE's code, I don't get why it doesn't degrade to single item?
I mean, since "hand" always move to the head, it will eventually point at the element at the head. And with great probability, every new access will be to different element, head element will always be evicted, and head's access mark will never be updated.
This history sequence generates patological sequence which is different from raw seqscan (every element is accessed 5 times), but still has hit ratio decreasing to zero with grow of N:
def history(N):
for i in range(10, N, 2):
for j in range(-10, -1):
yield i+j
yield i
yield i+1
Here's output of python implementation from https://cachemon.github.io/SIEVE-website/blog/2023/12/17/sieve-is-simpler-than-lru/#appendix for this sequence with N=1000:
999 (Visited: False) -> 998 (Visited: False) -> 10 (Visited: True) -> 8 (Visited: True) -> 7 (Visited: True) -> 6 (Visited: True) -> 5 (Visited: True) -> 4 (Visited: True) -> 3 (Visited: False) -> 2 (Visited: False)
As you see, SIEVE remembers only first 8 elements. Other accesses don't propagate to history part of a cache and so accesses to them are always "misses".
I've instrumented implementation with more logging: https://gist.github.com/funny-falcon/5e7fdd2d2dfc4136d133facc3af763a9
It clearly shows, every access aside first few is miss.
Looking at the SIEVE's code, I don't get why it doesn't degrade to single item?
I mean, since "hand" always move to the head, it will eventually point at the element at the head. And with great probability, every new access will be to different element, head element will always be evicted, and head's access mark will never be updated.
This history sequence generates patological sequence which is different from raw seqscan (every element is accessed 5 times), but still has hit ratio decreasing to zero with grow of
N:Here's output of python implementation from https://cachemon.github.io/SIEVE-website/blog/2023/12/17/sieve-is-simpler-than-lru/#appendix for this sequence with N=1000:
As you see, SIEVE remembers only first 8 elements. Other accesses don't propagate to history part of a cache and so accesses to them are always "misses".
I've instrumented implementation with more logging: https://gist.github.com/funny-falcon/5e7fdd2d2dfc4136d133facc3af763a9
It clearly shows, every access aside first few is miss.