-
Notifications
You must be signed in to change notification settings - Fork 3k
[erts] report writable binaries as off-heap binaries #6574
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
Conversation
CT Test ResultsNo tests were run for this PR. This is either because the build failed, or the PR is based on a branch without GH actions tests configured. Results for commit b0ad453 To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
// Erlang/OTP Github Action Bot |
|
@max-au Thanks for the PR. Looks good, test case and all. One little nitpick. Writable binaries were not introduced by #5195, it's a quite old performance feature. |
When writable binaries were moved to a separate list
`proc->wrt_bins`, they weren't added to the output of
`process_info(Pid, binary)`. It led to interesting effects of
binaries suddenly disappearing after running implicit GC caused
by BIF calls, including `process_info` itself. Effectively,
running `process_info(self(), binary)` twice in a row resulted
in different lists, because first call triggers GC clearing out
original binary from the off-heap list:
start() ->
OffHeapBin = crypto:strong_rand_bytes(1024 * 1024),
Bin = <<OffHeapBin/binary, "a">>,
Before = erlang:process_info(self(), [binary]),
After = erlang:process_info(self(), [binary]),
Before =/= After andalso erlang:display({wtf, Before, After}),
Bin.
Fixes erlang#6573
7996bf4 to
b0ad453
Compare
|
Updated, thanks for the correction! While at it, I wonder if there is any way to take a peek into what's stored in these binaries. Something like |
There is nothing like that, but it would be easy to implement. However, then you probably also want to know which parts of large shared binaries that are actually referred by the process. That is a bit trickier, as you have to scan the heap to find all ErlSubBin terms. |
|
Thanks @max-au ! Just one thing I would like to add: While it is totally correct to report orig_size for writable ProcBins, it is a bit unexpected to see the total size there. If there was more info in the tuple, (maybe a used_size and an is_writable) it would be more transparent. Just mentioning this because I think it relates to your 'peeking into binaries' question. |
|
Merged regression fix to maint for OTP 25.3. |
When writable binaries were moved to a separate list
proc->wrt_bins, they weren't added to the output ofprocess_info(Pid, binary). It led to interesting effects of binaries suddenly disappearing after running implicit GC caused by BIF calls, includingprocess_infoitself. Effectively, runningprocess_info(self(), binary)twice in a row resulted in different lists, because first call triggers GC clearing out original binary from the off-heap list:Fixes #6573