You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think foyer used the W-TinyLFU policy, and moka used the TinyLFU policy for the benchmark. I believe they should have similar hit ratios for this workload (ARC S3). For the expected results, see this comment moka-rs/moka#446 (comment) having the results from Caffeine Simulator.
I briefly reviewed the foyer code, and found potential errors in the W-TinyLFU policy implementation.
1. The W-TinyLFU policy does not seem to update the frequency of the key if it is not in the cache.
For a cache read, foyer should update the frequency of the key no matter if it is in the cache or not.
The inferred type for record is &Arc<Record<Lfu<K, V>>>. This implies the closure will never be called if a Record does not exist in the cache.
2. The W-TinyLFU policy updates the frequency of the key when inserting it into the cache.
It should not update the frequency of the key for cache writes. At least, moka does not do that. The popularity of the key should only be determined when it is requested, not when it is created.
Sorry for the late response. Recently it's the Chinese New Year holiday, I just returned from a vacation in Japan. (Maybe a bit off topic, but I know you are from Japan, the travel experience in Japan is really great.)
Let me try to apply the both suggestions. I'll be back here as soon as I make time for experiments.
Thank you very much for helping. That means a lot. 🥰
Sorry for the late response. Recently it's the Chinese New Year holiday, I just returned from a vacation in Japan. (Maybe a bit off topic, but I know you are from Japan, the travel experience in Japan is really great.)
No worries. I am from Tokyo, Japan but currently live in Shanghai with my wife and child, so I knew about the holiday. I am glad to hear that you enjoyed your vacation in Japan! (FYI, my Chinese is really bad because my family speaks Japanese, and I have worked only for American and Japanese companies. I should learn Chinese.)
No worries. I am from Tokyo, Japan but currently live in Shanghai with my wife and child, so I knew about the holiday. I am glad to hear that you enjoyed your vacation in Japan! (FYI, my Chinese is really bad because my family speaks Japanese, and I have worked only for American and Japanese companies. I should learn Chinese.)
Don't worry at all! I only know Chinese and English as well. I have been to Japan twice, and I visited Tokyo last year. So, I hope to learn Japanese, but learning languages is very difficult for me. 🥲
I am usually in Beijing, and I occasionally go on business trips to Shanghai. I am looking forward to meeting you face-to-face if you don't mind next time.
Hi.
In the
mokabench
result moka-rs/mokabench#20 (comment),foyer
had lower hit ratio thanmoka
in the same workload.I think
foyer
used the W-TinyLFU policy, andmoka
used the TinyLFU policy for the benchmark. I believe they should have similar hit ratios for this workload (ARC S3). For the expected results, see this comment moka-rs/moka#446 (comment) having the results from Caffeine Simulator.I briefly reviewed the
foyer
code, and found potential errors in the W-TinyLFU policy implementation.1. The W-TinyLFU policy does not seem to update the frequency of the key if it is not in the cache.
For a cache read,
foyer
should update the frequency of the key no matter if it is in the cache or not.foyer/foyer-memory/src/eviction/lfu.rs
Lines 368 to 370 in 92522d3
The inferred type for
record
is&Arc<Record<Lfu<K, V>>>
. This implies the closure will never be called if aRecord
does not exist in the cache.2. The W-TinyLFU policy updates the frequency of the key when inserting it into the cache.
It should not update the frequency of the key for cache writes. At least,
moka
does not do that. The popularity of the key should only be determined when it is requested, not when it is created.foyer/foyer-memory/src/eviction/lfu.rs
Lines 277 to 287 in 92522d3
I think fixing 1. will improve the hit ratio of
foyer
in themokabench
result. So please check and fix it if necessary.The text was updated successfully, but these errors were encountered: