Allow carrier migration between different allocator types#1854
Merged
jhogberg merged 4 commits intoerlang:masterfrom Jul 3, 2018
Merged
Conversation
This reduces instability on test rigs with more than a handful schedulers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Carriers can currently only move between instances of the same allocator type, which causes excessive memory allocation when one type is starved and another has lots of leftovers. This PR lifts that restriction and makes all allocator types share the same "carrier migration pool."
This is transparent aside from changes in how
erlang:system_info({allocator, Alloc})reports its results, which has a new field for statistics of blocks whose type differs from the allocator (foreign_blocks).In an earlier iteration of this PR @ferd asked if this could negatively impact memory fragmentation now that there's no longer a hard barrier between different types, and my reply was a bit too curt. It's a good question, and the long answer is "yes" but we're sure that the effect will be limited.
Carriers inside the migration pool can't be used for allocation, and a carrier is only abandoned and placed in the pool when it's practically empty (user-configurable) in the hopes that we can deallocate it soon. When a carrier is fetched from the pool it won't be abandoned until it's practically empty again, and since allocators prefer the carriers they've abandoned over searching the pool (with some caveats), carriers tend to stick with their allocator unless something drastic happens.
Keeping things separate could of course be better for certain workloads and we're open to adding options to control which types a carrier can migrate between, but it's not a part of this PR.