ReleaseAtLeastNPages always madvise pages with smallest addresses, causing pointless decommit for large spans · Issue #1574 · gperftools/gperftools · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the PageHeap::ReleaseAtLeastNPages function, we decommit spans from large_normal_.begin(), which have smallest length and address, and then move them to large_returned_
However, in PageHeap::AllocLarge, spans in large_returned_ with smaller start address take priority over those in large_normal_. As a result, it’s likely that the span we select is the same one we just decommitted in the previous PageHeap::ReleaseAtLeastNPages call.
This behavior can lead to slow decommit as well as performance degradation.
So is there any specific reason for decommitting spans from large_normal_.begin() instead of large_normal_.rbegin() in PageHeap::ReleaseAtLeastNPages ?
Thanks for raising this. Sure, we could try to do rbegin. But then we'd return the largest chunks first. It has its own imperfections.
Perhaps the logic of preferring slightly smaller (or same sized by lower address) when finding spans is the logic to be fixed. I welcome you to experiment and propose your change(s).
I.e. the cost of touching returned memory is not just extra memory usage but also real minor page faults. That's in ~microsecond range per page. High cost.
Thanks for raising this. Sure, we could try to do rbegin. But then we'd return the largest chunks first. It has its own imperfections.
Perhaps the logic of preferring slightly smaller (or same sized by lower address) when finding spans is the logic to be fixed. I welcome you to experiment and propose your change(s).
I understand your concerns. I'll think about improving the strategy in PageHeap::AllocLarge, and do some tests and comparisons.
In the
PageHeap::ReleaseAtLeastNPages
function, we decommit spans fromlarge_normal_.begin()
, which have smallest length and address, and then move them tolarge_returned_
However, in
PageHeap::AllocLarge
, spans inlarge_returned_
with smaller start address take priority over those inlarge_normal_
. As a result, it’s likely that the span we select is the same one we just decommitted in the previousPageHeap::ReleaseAtLeastNPages
call.This behavior can lead to slow decommit as well as performance degradation.
So is there any specific reason for decommitting spans from
large_normal_.begin()
instead oflarge_normal_.rbegin()
inPageHeap::ReleaseAtLeastNPages
?code from
PageHeap::ReleaseAtLeastNPages
:gperftools/src/page_heap.cc
Lines 612 to 622 in ab49985
code from
PageHeap::AllocLarge
:gperftools/src/page_heap.cc
Lines 289 to 298 in ab49985
The text was updated successfully, but these errors were encountered: