This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Mitigate page releasing thrashing
ClosedPublic

Authored by Chia-hungDuan on Feb 24 2023, 4:55 PM.

Details

Summary

We have the heuristic to determine the threshold of doing page
releasing for smaller size classes. However, in a case that the
memory usage is bouncing between that threshold may result in
frequent try of page releasing but not returning much memory.

This CL add another heuristic to mitigate this problem by increasing
the minimum pages that potentially can be released. Note that this
heuristic is only applied on SizeClassAllocator64. SizeClassAllocator32
has a smaller group size so the overhead is smaller than 64-bit
platform.

Diff Detail

Event Timeline

Chia-hungDuan created this revision.Feb 24 2023, 4:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2023, 4:55 PM
Chia-hungDuan requested review of this revision.Feb 24 2023, 4:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2023, 4:55 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
cferris requested changes to this revision.Feb 28 2023, 1:31 PM

Mostly nits, but do you have any numbers on the change to RSS usage? I wouldn't expect this to cause much change, but I always worry about some pathological case that results in no memory being released.

compiler-rt/lib/scudo/standalone/primary64.h
95

goes over

98

is greater

100

releases

102

reduces the frequency of these calls

121

is caused

122

the longest time to do the page release

913

a certain

This revision now requires changes to proceed.Feb 28 2023, 1:31 PM
Chia-hungDuan marked 7 inline comments as done.

Address review comment

So far, I didn't see memory usage increasing in many apps and boot. This tends
to address some extreme cases that do periodically a bunch of allocs/frees. From
some artificial scenarios, we can see the times of doing page release reduced.
Will keep an eye on the system health afterward

cferris accepted this revision.Mar 3 2023, 12:24 PM

LGTM.

I had one small comment about a comment that is so small that I don't think it's worth holding up the CL.

compiler-rt/lib/scudo/standalone/primary64.h
122

There is an extra space in here. If you have another change already modifying this file, feel free to make it later or even in a follow-on if you want.

This revision is now accepted and ready to land.Mar 3 2023, 12:24 PM

LGTM.

I had one small comment about a comment that is so small that I don't think it's worth holding up the CL.

Got it. I'll rebase this change up to the front of this chain and merge it by next Monday.

Remove extra space and rebase

This revision was automatically updated to reflect the committed changes.