Commit a19316d9 authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

[heap] Rework Worklist base type

Worklist uses a singly-linked list of segments to hold entries.
Segment size was based on a compile-time constant but already stored
in the segment itself.

Rework the segments to query `malloc_usable_size()` on allocation and
adjust the capacity properly. For PartitionAlloc, it turns out that
there's ~20% more capacity available for the 64-element segments.

This slows down actual allocation of the segments with the upside of
improving utilization and requiring 20% less segments.

Change-Id: Ib8595c3fb9fb75b02e4022f6c525bb59a2df7ab7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3826047
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarAnton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82432}
parent 3fde77b5
......@@ -52,6 +52,9 @@
#if V8_OS_DARWIN
#include <mach/mach.h>
#include <malloc/malloc.h>
#else
#include <malloc.h>
#endif
#if V8_OS_LINUX
......@@ -1262,5 +1265,14 @@ Stack::StackSlot Stack::GetCurrentStackPosition() {
#undef MAP_ANONYMOUS
#undef MADV_FREE
// static
size_t Malloc::GetUsableSize(void* ptr) {
#if defined(V8_OS_DARWIN)
return malloc_size(ptr);
#else // defined(V8_OS_DARWIN)
return malloc_usable_size(ptr);
#endif // !defined(V8_OS_DARWIN)
}
} // namespace base
} // namespace v8
......@@ -19,7 +19,8 @@
// This has to come after windows.h.
#include <VersionHelpers.h>
#include <dbghelp.h> // For SymLoadModule64 and al.
#include <dbghelp.h> // For SymLoadModule64 and al.
#include <malloc.h> // For _msize()
#include <mmsystem.h> // For timeGetTime().
#include <tlhelp32.h> // For Module32First and al.
......@@ -1765,5 +1766,8 @@ Stack::StackSlot Stack::GetCurrentStackPosition() {
#endif
}
// static
size_t Malloc::GetUsableSize(void* ptr) { return _msize(ptr); }
} // namespace base
} // namespace v8
......@@ -661,6 +661,12 @@ class V8_BASE_EXPORT Stack {
}
};
class V8_BASE_EXPORT Malloc final {
public:
// Returns the usable size in bytes for a `ptr` allocated using `malloc()`.
static size_t GetUsableSize(void* ptr);
};
} // namespace base
} // namespace v8
......
......@@ -4,16 +4,12 @@
#include "src/heap/base/worklist.h"
namespace heap {
namespace base {
namespace internal {
namespace heap::base::internal {
// static
SegmentBase* SegmentBase::GetSentinelSegmentAddress() {
static SegmentBase kSentinelSegment(0);
return &kSentinelSegment;
static SegmentBase sentinel_segment(0);
return &sentinel_segment;
}
} // namespace internal
} // namespace base
} // namespace heap
} // namespace heap::base::internal
This diff is collapsed.
......@@ -704,7 +704,7 @@ void Scavenger::Process(JobDelegate* delegate) {
scavenge_visitor.Visit(object_and_size.first);
done = false;
if (delegate && ((++objects % kInterruptThreshold) == 0)) {
if (!copied_list_local_.IsEmpty()) {
if (!copied_list_local_.IsLocalEmpty()) {
delegate->NotifyConcurrencyIncrease();
}
}
......
......@@ -20,10 +20,10 @@ namespace heap {
void PublishSegment(MarkingWorklist* worklist, HeapObject object) {
MarkingWorklist::Local local(worklist);
for (size_t i = 0; i <= MarkingWorklist::kSegmentSize; i++) {
for (size_t i = 0; i < MarkingWorklist::kMinSegmentSizeForTesting; i++) {
local.Push(object);
}
CHECK(local.Pop(&object));
local.Publish();
}
TEST(ConcurrentMarking) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment