feat: enable mmap to alloc on unix-like system#397
feat: enable mmap to alloc on unix-like system#397tecty wants to merge 1 commit intoallegro:mainfrom
Conversation
|
The lowest go version on x/sys/unix is go1.17 and use v0.1.0 version, so I bump up the go version on this package. |
|
By using mmap, we could nearly double the cache space with same memory limit. Because these space are not alloc from heap and not affect the GC behavior. |
That's great! However, incorporating an external dependency introduces differences in behavior between Unix and non-Unix systems. How about a different approach? Instead of adding a dependency, we could extend the code with an interface to handle allocation. By default, we would use the current behavior, but users could provide their own allocator. This approach would be similar to the hasher we currently use: by default, we use the hash from the stdlib, but users can provide their custom hasher. What do you think? We could then create a separate module with your allocator implementation and add a link in the README. In a separate repository, you could add more benchmarks and explain how it works, like a mini blog post. |
|
First of all, this optimization cannot be addressed by relying on the user-implemented allocator. This is because the address space requested by mmap needs to be contiguous, and using |
Use mmap to malloc memory, give a smaller heap memory footprint. This will remove the go memory ballast effect while using bigcache. Thus this will increase a bit on GC stop and CPU. But we have other tools like GC params or gctuner to mitigate this kind of problem.
