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

Refactoring: Memory management #4311

Closed
wants to merge 10 commits into from
Closed

Refactoring: Memory management #4311

wants to merge 10 commits into from

Conversation

lukas-w
Copy link
Member

@lukas-w lukas-w commented Apr 22, 2018

Some refactorings regarding memory management and containers.

  • MemoryManager.h renamed to Memory.h
  • MemoryHelper::alignedMalloc moved to Memory.h, ported to an stl-compatible allocator called AlignedAllocator, implementation replaced by a single rpmalloc call.
  • LocklessAllocator implementation replaced by a new MemoryPool class, which now also replaces the implementations of BufferPool (formerly BufferManager) and NotePlayHandlePool (formerly NotePlayHandleManager). Instead of a custom-written lockless stack, MemoryPool uses a 3rdparty lockless queue implementation which yields much better performance.
  • Add some tests and naïve micro-benchmarks.

This includes a a new submodule, libcds, which is a collection of concurrent and lock-free data structures.

Starting with this PR, I'd like to license my contributions as MIT, while the project as a whole is still licensed as GPL. Hope that doesn't cause any trouble.

* Use a Nifty Counter for rpmalloc initialization. This fixes init order
  with other static objects using MmAllocator or MemoryManagger
* Fix exception throwing in AlignedAllocator
* Add missing constructor to MmAllocator for compatibility with std
  containers
MemoryPool maintains a free list of pre-allocated entries stored in a
libcds MPMC Queue. In contrast to LocklessAllocator, it's a lot faster,
less (and less complex) code to maintain for us and it doesn't fail when
it's full.
@lukas-w
Copy link
Member Author

lukas-w commented Apr 22, 2018

Should have tested with Travis first. Will re-open once fixed.

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

Successfully merging this pull request may close these issues.

1 participant