Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions compiler-rt/lib/scudo/standalone/primary64.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "thread_annotations.h"
#include "tracing.h"

#include <inttypes.h>

namespace scudo {

// SizeClassAllocator64 is an allocator tuned for 64-bit address space.
Expand Down Expand Up @@ -1146,17 +1148,24 @@ void SizeClassAllocator64<Config>::getStats(ScopedString *Str, uptr ClassId,
BytesInFreeList - Region->ReleaseInfo.BytesInFreeListAtLastCheckpoint;
}
const uptr TotalChunks = Region->MemMapInfo.AllocatedUser / BlockSize;
const u64 CurTimeNs = getMonotonicTime();
const u64 DiffSinceLastReleaseNs =
CurTimeNs - Region->ReleaseInfo.LastReleaseAtNs;
const u64 LastReleaseSecAgo = DiffSinceLastReleaseNs / 1000000000;
const u64 LastReleaseMsAgo = (DiffSinceLastReleaseNs % 1000000000) / 1000000;

Comment on lines +1154 to +1156
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a new thought about this, given that we have ReleaseToOsInterval, can we print something like > ReleaseToOsInterval < ReleaseToOsInterval?

If we hit the threshold to do the page release but it's too close (diff time less than ReleaseToOsInterval) then we will skip the page release. Thus I think longer/shorter than the interval gives us enough information about why the pages aren't released.

Sorry I didn't think about this while came up with the work

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's chat this offline for more details

Str->append(
"%s %02zu (%6zu): mapped: %6zuK popped: %7zu pushed: %7zu "
"inuse: %6zu total: %6zu releases attempted: %6zu last "
"released: %6zuK latest pushed bytes: %6zuK region: 0x%zx "
"(0x%zx)\n",
"(0x%zx) Latest release: %" PRIu64 ":%" PRIu64 " seconds ago\n",
Region->Exhausted ? "E" : " ", ClassId, getSizeByClassId(ClassId),
Region->MemMapInfo.MappedUser >> 10, Region->FreeListInfo.PoppedBlocks,
Region->FreeListInfo.PushedBlocks, InUseBlocks, TotalChunks,
Region->ReleaseInfo.NumReleasesAttempted,
Region->ReleaseInfo.LastReleasedBytes >> 10, RegionPushedBytesDelta >> 10,
Region->RegionBeg, getRegionBaseByClassId(ClassId));
Region->RegionBeg, getRegionBaseByClassId(ClassId), LastReleaseSecAgo,
LastReleaseMsAgo);
}

template <typename Config>
Expand Down Expand Up @@ -1486,7 +1495,7 @@ uptr SizeClassAllocator64<Config>::releaseToOSMaybe(RegionInfo *Region,
Region->ReleaseInfo.BytesInFreeListAtLastCheckpoint = BytesInFreeList;
Region->ReleaseInfo.LastReleasedBytes = Recorder.getReleasedBytes();
}
Region->ReleaseInfo.LastReleaseAtNs = getMonotonicTimeFast();
Region->ReleaseInfo.LastReleaseAtNs = getMonotonicTime();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to keep this with the fast version as long as we have the precise one in getStats


if (Region->ReleaseInfo.PendingPushedBytesDelta > 0) {
// Instead of increasing the threshold by the amount of
Expand Down