Commit-Queue | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Thanks, this is indeed much cleaner! I just have one comment.
V8_WARN_UNUSED_RESULT auto HeapAllocator::CustomAllocateWithRetry(
I understand that this was not introduced by your CL but since we are adapting this once more now and I wanted to do this for a while: What about making this non-templatized so we can easily put the retry logic back into the heap-allocator.cc file instead? We could simply expect `base::FunctionRef<bool()>` as allocation function. The bool return value would just tell us whether the allocation was successful or not. The actual allocation address could also be written into some captured local variable by the allocate-lambda. A non-templatized version could probably also be exposed a bit more easily on the API (since you mentioned that).
Performance-wise this shouldn't matter because in `HeapAllocator::AllocateRaw` we already use that method only after the allocation failed already once. At this point we need to do a GC, so inling or not for that function shouldn't matter at all. We should probably invoke "allocate()" manually first before using `CustomAllocateWithRetry()` in the other uses as well to handle the most likely case (that allocation succeeds) without regression. This should be: AllocateExternalBackingStore(), CppHeap::AllocateWithRetry and NewJSDispatchHandle.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
if (allocation == AllocationType::kYoung) {
result = AllocateRaw<AllocationType::kYoung>(size, origin, alignment, hint);
if (result.To(&object)) {
return object;
}
} else if (allocation == AllocationType::kOld) {
result = AllocateRaw<AllocationType::kOld>(size, origin, alignment, hint);
if (result.To(&object)) {
return object;
}
}
It seems to me like this + all the "other" allocation can simply be replaced by `AllocateRaw()` without regression -> this doesn't add any condition and AllocateRaw() is inline.
V8_WARN_UNUSED_RESULT auto HeapAllocator::CustomAllocateWithRetry(
I understand that this was not introduced by your CL but since we are adapting this once more now and I wanted to do this for a while: What about making this non-templatized so we can easily put the retry logic back into the heap-allocator.cc file instead? We could simply expect `base::FunctionRef<bool()>` as allocation function. The bool return value would just tell us whether the allocation was successful or not. The actual allocation address could also be written into some captured local variable by the allocate-lambda. A non-templatized version could probably also be exposed a bit more easily on the API (since you mentioned that).
Performance-wise this shouldn't matter because in `HeapAllocator::AllocateRaw` we already use that method only after the allocation failed already once. At this point we need to do a GC, so inling or not for that function shouldn't matter at all. We should probably invoke "allocate()" manually first before using `CustomAllocateWithRetry()` in the other uses as well to handle the most likely case (that allocation succeeds) without regression. This should be: AllocateExternalBackingStore(), CppHeap::AllocateWithRetry and NewJSDispatchHandle.
We could simply expect base::FunctionRef<bool()> as allocation function.
Done
Performance-wise this shouldn't matter because in HeapAllocator::AllocateRaw we already use that method only after the allocation failed already once.
This is more or less true, because only kYoung and kOld have a fast path; although I don't see why we couldn't add the fast path for all allocation types (done in latest patchset).
We should probably invoke "allocate()" manually first before using CustomAllocateWithRetry() in the other uses as well
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
if (allocation == AllocationType::kYoung) {
result = AllocateRaw<AllocationType::kYoung>(size, origin, alignment, hint);
if (result.To(&object)) {
return object;
}
} else if (allocation == AllocationType::kOld) {
result = AllocateRaw<AllocationType::kOld>(size, origin, alignment, hint);
if (result.To(&object)) {
return object;
}
}
It seems to me like this + all the "other" allocation can simply be replaced by `AllocateRaw()` without regression -> this doesn't add any condition and AllocateRaw() is inline.
Good catch! I missed that we have the fast path only for Young and Old. I think I agree with you but IIRC that code path was added for performance reasons. Not really sure what benchmark that was. I think it would be less controversial if we would keep it as is but add the AllocateRaw in an else-branch after handling Young/Old.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
if (allocation == AllocationType::kYoung) {
result = AllocateRaw<AllocationType::kYoung>(size, origin, alignment, hint);
if (result.To(&object)) {
return object;
}
} else if (allocation == AllocationType::kOld) {
result = AllocateRaw<AllocationType::kOld>(size, origin, alignment, hint);
if (result.To(&object)) {
return object;
}
}
Dominik InführIt seems to me like this + all the "other" allocation can simply be replaced by `AllocateRaw()` without regression -> this doesn't add any condition and AllocateRaw() is inline.
Good catch! I missed that we have the fast path only for Young and Old. I think I agree with you but IIRC that code path was added for performance reasons. Not really sure what benchmark that was. I think it would be less controversial if we would keep it as is but add the AllocateRaw in an else-branch after handling Young/Old.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Commit-Queue | +2 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
15 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: src/heap/heap-allocator-inl.h
Insertions: 16, Deletions: 4.
@@ -225,12 +225,24 @@
AllocationOrigin origin,
AllocationAlignment alignment,
AllocationHint hint) {
+ AllocationResult result;
Tagged<HeapObject> object;
size = ALIGN_TO_ALLOCATION_ALIGNMENT(size);
- AllocationResult result =
- AllocateRaw(size, allocation, origin, alignment, hint);
- if (result.To(&object)) [[likely]] {
- return object;
+ if (allocation == AllocationType::kYoung) {
+ result = AllocateRaw<AllocationType::kYoung>(size, origin, alignment, hint);
+ if (result.To(&object)) {
+ return object;
+ }
+ } else if (allocation == AllocationType::kOld) {
+ result = AllocateRaw<AllocationType::kOld>(size, origin, alignment, hint);
+ if (result.To(&object)) {
+ return object;
+ }
+ } else {
+ result = AllocateRaw(size, allocation, origin, alignment, hint);
+ if (result.To(&object)) {
+ return object;
+ }
}
switch (mode) {
case kLightRetry:
```
[Heap] Unify allocation retry loops
This CL reuses HeapAllocator retry loop in several places, including
oilpan. This ensure they are all aligned under 1 implementation.
Follow-up: this should also be exposed on v8-isolate so that it can be used here: https://chromium-review.googlesource.com/c/chromium/src/+/6164814
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |