[cpu-profiler] Add a HandleScope to limit memory consumption.
The handles created for each SharedFunctionInfo within SourcePosition::InliningStack live for the life of the profile, reaching 5MiB+ on an example server application for Node. This HandleScope limits their lifetime locally, given that the handles do not escape. This saves ~10% of peak memory. Bug: v8:7719 Change-Id: I97ce0fd3658be89fdd9cb9c1369ea5bfae0ce579 Reviewed-on: https://chromium-review.googlesource.com/1049647 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Alexei Filippov <alph@chromium.org> Commit-Queue: Peter Marshall <petermarshall@chromium.org> Cr-Commit-Position: refs/heads/master@{#53085}
This commit is contained in:
parent
8c57a54b86
commit
3e9f8a4f63
@ -17,7 +17,8 @@ namespace internal {
|
|||||||
|
|
||||||
ProfilerListener::ProfilerListener(Isolate* isolate,
|
ProfilerListener::ProfilerListener(Isolate* isolate,
|
||||||
CodeEventObserver* observer)
|
CodeEventObserver* observer)
|
||||||
: observer_(observer),
|
: isolate_(isolate),
|
||||||
|
observer_(observer),
|
||||||
function_and_resource_names_(isolate->heap()->HashSeed()) {}
|
function_and_resource_names_(isolate->heap()->HashSeed()) {}
|
||||||
|
|
||||||
ProfilerListener::~ProfilerListener() = default;
|
ProfilerListener::~ProfilerListener() = default;
|
||||||
@ -276,6 +277,11 @@ void ProfilerListener::RecordDeoptInlinedFrames(CodeEntry* entry,
|
|||||||
int deopt_id = static_cast<int>(info->data());
|
int deopt_id = static_cast<int>(info->data());
|
||||||
DCHECK(last_position.IsKnown());
|
DCHECK(last_position.IsKnown());
|
||||||
std::vector<CpuProfileDeoptFrame> inlined_frames;
|
std::vector<CpuProfileDeoptFrame> inlined_frames;
|
||||||
|
|
||||||
|
// SourcePosition::InliningStack allocates a handle for the SFI of each
|
||||||
|
// frame. These don't escape this function, but quickly add up. This
|
||||||
|
// scope limits their lifetime.
|
||||||
|
HandleScope scope(isolate_);
|
||||||
for (SourcePositionInfo& pos_info : last_position.InliningStack(code)) {
|
for (SourcePositionInfo& pos_info : last_position.InliningStack(code)) {
|
||||||
if (pos_info.position.ScriptOffset() == kNoSourcePosition) continue;
|
if (pos_info.position.ScriptOffset() == kNoSourcePosition) continue;
|
||||||
if (!pos_info.function->script()->IsScript()) continue;
|
if (!pos_info.function->script()->IsScript()) continue;
|
||||||
|
@ -84,6 +84,7 @@ class ProfilerListener : public CodeEventListener {
|
|||||||
observer_->CodeEventHandler(evt_rec);
|
observer_->CodeEventHandler(evt_rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Isolate* isolate_;
|
||||||
CodeEventObserver* observer_;
|
CodeEventObserver* observer_;
|
||||||
StringsStorage function_and_resource_names_;
|
StringsStorage function_and_resource_names_;
|
||||||
std::deque<std::unique_ptr<CodeEntry>> code_entries_;
|
std::deque<std::unique_ptr<CodeEntry>> code_entries_;
|
||||||
|
Loading…
Reference in New Issue
Block a user