This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Use bytes-in-freelist as a hint of page release
ClosedPublic

Authored by Chia-hungDuan on Mar 19 2023, 4:25 PM.

Details

Summary

Tracking the pushed bytes between to releaseToOSMaybe calls may lead to
a overestimated case that if we do malloc 2KB -> free 2KB -> malloc 2KB
-> free 2KB, we may think we have released 4KB but it only releases 2KB
actually. Switch to use bytes-in-freelist excludes more cases that can't
release the pages

Diff Detail

Event Timeline

Chia-hungDuan created this revision.Mar 19 2023, 4:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2023, 4:25 PM
Chia-hungDuan requested review of this revision.Mar 19 2023, 4:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2023, 4:25 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
Chia-hungDuan added a comment.EditedMar 19 2023, 4:30 PM

Continue how we measure the efficiency of early-exit releaseToOS in D146312,

scudo   : -- Average Operation Time -- -- Name (# of Calls) --
scudo   :            264.4(ns)            releaseToOSMaybe (30981)
scudo   :             91.8(ns)              TryMarkingBlocks (7118)
scudo   :           7935.0(ns)              releaseFreeMemoryToOS (1)

(30981 - 7118) / 30981 ~= 77% of releaseToOSMaybe calls are excluded from trying of marking blocks. So far I didn't see the overall memory impact here thus I suppose we only exempt the cases that are supposed to release nothing.

cferris requested changes to this revision.Mar 20 2023, 1:29 PM
cferris added inline comments.
compiler-rt/lib/scudo/standalone/primary32.h
741

Should this be skipped when force freeing everything?

846–848

updating

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

updating

This revision now requires changes to proceed.Mar 20 2023, 1:29 PM
Chia-hungDuan marked 3 inline comments as done.

Address review comments

cferris requested changes to this revision.Mar 21 2023, 3:03 PM

As mentioned, there is a difference between primary32 and primary64 that isn't clear.

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

This isn't in the primary32.h, is there a fundamental difference that means this isn't needed in that one?

This revision now requires changes to proceed.Mar 21 2023, 3:03 PM

Address review comment

Chia-hungDuan marked an inline comment as done.Mar 21 2023, 7:55 PM
Chia-hungDuan added inline comments.
compiler-rt/lib/scudo/standalone/primary32.h
741

You're right! Done.

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

A left over. Done!

cferris accepted this revision.Mar 21 2023, 8:03 PM

LGTM

This revision is now accepted and ready to land.Mar 21 2023, 8:03 PM
This revision was automatically updated to reflect the committed changes.
Chia-hungDuan marked an inline comment as done.