Skip to content
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

Problem: memiavl has relatively big gc pressure #988

Open
Tracked by #870
yihuang opened this issue Apr 20, 2023 · 0 comments
Open
Tracked by #870

Problem: memiavl has relatively big gc pressure #988

yihuang opened this issue Apr 20, 2023 · 0 comments

Comments

@yihuang
Copy link
Collaborator

yihuang commented Apr 20, 2023

Depending on the traffic of the chain and interval of snapshot rewriting, memiavl need to manage lots of small memories for MemNodes and key/value slices, which could put a big pressure to golang GC, it might make sense to use some manual memory management.

Memory Arenas

One obvious solution is memory arenas feature introduced in go 1.20, we just allocate these objects with big chunks of arenas.

Negatives

  • we can't reclaim and reuse memory, arenas don't support deallocating, before dropped as a whole when we switch snapshot, it's maybe alright assuming deletion happens more rarely than insertion/updates.

Manual Memory Management

  • Implement MemNode as a []byte, similar to the nodes in mmap-ed snapshots, allocate in a big buffer, maintain an intrusive free list to reuse nodes.
  • Leave key/value slices to golang GC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant