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

Add pool based memory resource #25325

Merged

Commits on Mar 23, 2023

  1. Add pool based memory resource & allocator

    A memory resource similar to std::pmr::unsynchronized_pool_resource, but
    optimized for node-based containers.
    
    Co-Authored-By: Pieter Wuille <pieter@wuille.net>
    martinus and sipa committed Mar 23, 2023
    Configuration menu
    Copy the full SHA
    b8401c3 View commit details
    Browse the repository at this point in the history
  2. Calculate memory usage correctly for unordered_maps that use PoolAllo…

    …cator
    
    Extracts the resource from a PoolAllocator and uses it for
    calculation of the node's memory usage.
    martinus committed Mar 23, 2023
    Configuration menu
    Copy the full SHA
    e19943f View commit details
    Browse the repository at this point in the history
  3. Add PoolResource fuzzer

    Fuzzes PoolResource with random allocations/deallocations, and multiple
    asserts.
    
    Co-Authored-By: Pieter Wuille <pieter@wuille.net>
    martinus and sipa committed Mar 23, 2023
    Configuration menu
    Copy the full SHA
    1afca6b View commit details
    Browse the repository at this point in the history
  4. Call ReallocateCache() on each Flush()

    This frees up all associated memory with the map, not only the nodes.
    This is necessary in preparation for using the PoolAllocator for
    CCoinsMap, which does not actually free any memory on clear().
    martinus committed Mar 23, 2023
    Configuration menu
    Copy the full SHA
    5e4ac5a View commit details
    Browse the repository at this point in the history
  5. Use PoolAllocator for CCoinsMap

    In my benchmarks, using this pool allocator for CCoinsMap gives about
    20% faster `-reindex-chainstate` with -dbcache=5000 with practically the
    same memory usage. The change in max RSS changed was 0.3%.
    
    The `validation_flush_tests` tests need to be updated because
    memory allocation is now done in large pools instead of one node at a
    time, so the limits need to be updated accordingly.
    martinus committed Mar 23, 2023
    Configuration menu
    Copy the full SHA
    9f947fc View commit details
    Browse the repository at this point in the history