-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request, mmap option #15
Comments
I thought it before, here is my roudmap
|
So as we see, I'm reinventing another freecache/fastcache, it seems that a bit sad. |
@phuslu can you implement it? i know u can make this the fastest for interprocess sharing. this will be mmapped for inter process golang accessing, which is not available in other solutions |
@phuslu pls implement it. this will make it work around all the 192 cores issues and more. |
@phuslu when can you get it done? how can i show my appreciation and thanks for this? |
The reason I haven't start it yet is that I don't have the confidence to do it better than fastcache. But under your encouragement, let me try reluctantly. |
@phuslu if you do an mmap version, u already done better than the rest as it'll be the only lru cache that can be accessed across independent and separate processes. please post incomplete code or where u think i can help contribute coz i think i can help u make it faster then. dont worry about speed for the moment, it's the only mmap lru that is shareable across process. can u pls start it and i'll help with speeding it up. |
@phuslu chatgpt may help u out too in certain areas. |
ok, let me push a drafted "BytesCache" commit to poc our ideas today |
@phuslu i'm not sure how u will have a global mutex to sync for separate golang processes to access it. not sure if u will hit any issues but i have solution. u may come up with a better global mutex lock or similar. |
@phuslu this is my last bit of performance issue with golang, so i'll be around 24/7 just looking at this issue. i was working on chatgpt with an mmap lru and it's terrible. i know u definitely will come up with "the best". |
Found another similar implementation in c/php, https://github.com/happyfish100/libshmcache The noticeable feature is that it also choose FIFO rather than LRU, this same as fastcache. I think that because of "lock contention" reduction |
dont worry about them, get it done on your version. in fact, just mapped the variables to the memory mapped memory file e.g. /dev/shm/shm.mmap or something. as i mentioned, if u found issue with lock, i have solution |
you can do what u think is best first, i will try the lock issue on my side and send you the code once i verify it can be resolved. by the way, i think u'll confuse yourself more if you reference others' implementation, that c repo is irrelevant. your lru will work directly with mmap referencing directly, the only issue u have will be the global lock that's all. dont need to do the fifo etc and no need to flush writes actually. i've tested mmap file sharing and without flushing it works too as long as you dont reboot the server of course. p.s. : i mean directly u can just implement a global lock on your lru without any issue. dont do fifo etc. use your version exactly. 2 things need to change only.
that's all really. |
@phuslu do send the code of what u have done so i can try the lock issue if u think i can do better |
I done the first easiest step.
I think I need "steal" some fastcache codes.
need learn bytedance codes and your guide/help. |
@phuslu fastcache does not have the things u need, u can reference some code from here: but this does not work across processes because it is missing somethings. i'm sure u'll figure out. |
@phuslu check the
i prefer the 2nd option as it's "better" also, please make it in bytes so it's cleaner. the 256 is in megabytes, u can do 256000000 as input parameter. the other two 0s can be ignored for now. |
@phuslu hope u have seen the scache. it's really easy concept. |
@phuslu i saw the mmap_file entry now. u picked up really quick. do mention if u see any issues, pls map the []bytes to the mmap file (and then put a global lock and it's done.) do show any sort of naive implementation too. i will help add code to some sections as add on feature. |
@phuslu any issues? |
sorry for late reply and thanks for help, I've been a little busy these days, so I haven't been thinking and developing this feature fully. Currently I'm blocked in how alloc & place But LRU is more complicated, when it evict old Maybe I needed implement the linux Slab allocation |
@phuslu your comment reminds me of this, which is written in c without lru but does have memory "gc". just for reference but maybe you can get some inspiration from there. not sure if "gc" on the holes is faster or otherwise. |
@phuslu is there any issue with using mmap directly against the lru currently? the spare holes etc are acceptable at this stage. scache will use 2x the memory and not really lru but the spare hole issue you have is mostly an edge case issue i guess. would love to use your mmap version asap as i can help add features to it etc. do u think u can have an eta on this mmap version? global mutex wise i can help resolve too |
I'm learning fastcache architect, a introduction here(Chinese version) https://www.cnblogs.com/ahfuzhang/p/15840313.html
Sorry, I cannot give it. From experience, I usually need a bit long vacation alone to complete this kind of challenge that requires both mental and physical strength. This time I guess it might be during May 1st the International Labor Day. |
@phuslu hmm... ok. i'll be looking at this issue daily. if u have any areas need me to help test / improve do mention. |
@phuslu i have the solution for a high speed lock at > 15mil lock/inlock per second. can u guesstimate an eta for the mmap implementation? |
Sorry these days I spent most time to improve "phuslu/log" and released its v1.0.93 tag. Today I will turn to this lru library. |
sorry, still spend time for improve github.com/phuslu/log performance. will start lru mmap next day. |
@phuslu ok. when do u think an eta can be provided for it? just curious on an eta that's all. p.s. : not rushing u, just very anxious to know that's all. |
@phuslu can u pls help make sure it's not like using a hash function which will result in lower hit ratio? i would prefer if u can help with having something along the lines of map[string]string etc so that there can be no hash collision. i've tried implementing something myself but it's not working but i can help with areas if u have any issues too. |
@phuslu if u need help with test etc. do mention |
@phuslu pls pls pls implement a mmap option that can be shared across golang inter process.
can buy u a few coffees for this. possible to get it done?
maybe with an option to flush to mmap file at regular intervals or something. most importantly so can be used across different separate programs
The text was updated successfully, but these errors were encountered: