update value / release of memory #50
-
Hi I like Moka and its API very much but found the following issue (possibly due to my own incorrect usage of it): In my actual app I have some background job updating the values of the cache periodically. Below is an example which should simulate this behaviour (happy to provide more details). Is there a better way to update values or to invalidate / release the value of the key? Thanks for your help
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi. Thank you for reporting the issue. I have not had a chance to run your code yet, but will try soon. I think you are doing right, so it will be Moka's problem. Moka uses a concurrent hash table called cht as the central storage. And I know there are a couple of places to improve in cht for better memory usage. One such thing is a usage of crossbeam-epoch. cht uses crossbeam-epoch, which provides lock-free shared garbage collected pointers. Maybe the issue you are seeing is caused by it. By design, it will not immediately drop values pointed by its pointers, and will keep last few hundreds of them in memory after they were marked as "droppable". I once opened a GitHub issue for it, but closed after I realized it was by design: Gregory-Meyer/cht#23 (comment) $ cargo run --release --bin main2
...
inserted: 10000, dropped: 9832 I will check whether your issue is caused by it or not. And if so, try to come up with options to mitigate the issue. It seems cht's development has been stalled, so I forked it and will maintain it by myself. |
Beta Was this translation helpful? Give feedback.
Hi. Thank you for reporting the issue. I have not had a chance to run your code yet, but will try soon.
I think you are doing right, so it will be Moka's problem.
Moka uses a concurrent hash table called cht as the central storage. And I know there are a couple of places to improve in cht for better memory usage.
One such thing is a usage of crossbeam-epoch. cht uses crossbeam-epoch, which provides lock-free shared garbage collected pointers. Maybe the issue you are seeing is caused by it. By design, it will not immediately drop values pointed by its pointers, and will keep last few hundreds of them in memory after they were marked as "droppable".
I once opened a GitHub issue for it, but …