Commit 5575bd66 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

Revert "[cpu-profiler] Log OSR code when starting the profiler"

This reverts commit f6965281.

Reason for revert: Test is flaky: https://ci.chromium.org/p/v8/builders/ci/V8%20Linux64/39092

Original change's description:
> [cpu-profiler] Log OSR code when starting the profiler
> 
> OSR code doesn't hang off any JSFunction or SFI, so we missed it when
> starting up the profiler. This meant we didn't properly attribute
> ticks to SFI code. The ticks ended up going to the caller instead.
> 
> There is a weak cache of OSR code per native context, so iterate that
> on profiler startup and log all the code objects.
> 
> Change-Id: I2e9738b86a488b37f36ac89803561607dc76f745
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2414216
> Commit-Queue: Peter Marshall <petermarshall@chromium.org>
> Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
> Reviewed-by: Mythri Alle <mythria@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#69964}

TBR=mythria@chromium.org,petermarshall@chromium.org,dinfuehr@chromium.org

Change-Id: I1e69f8af88d901bab6f257652d3536d24a4777f9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2415994Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69969}
parent 6101e9c2
...@@ -1528,8 +1528,6 @@ class Heap { ...@@ -1528,8 +1528,6 @@ class Heap {
static Isolate* GetIsolateFromWritableObject(HeapObject object); static Isolate* GetIsolateFromWritableObject(HeapObject object);
std::vector<Handle<NativeContext>> FindAllNativeContexts();
private: private:
using ExternalStringTableUpdaterCallback = String (*)(Heap* heap, using ExternalStringTableUpdaterCallback = String (*)(Heap* heap,
FullObjectSlot pointer); FullObjectSlot pointer);
...@@ -2021,6 +2019,7 @@ class Heap { ...@@ -2021,6 +2019,7 @@ class Heap {
V8_EXPORT_PRIVATE void IncrementObjectCounters(); V8_EXPORT_PRIVATE void IncrementObjectCounters();
#endif // DEBUG #endif // DEBUG
std::vector<Handle<NativeContext>> FindAllNativeContexts();
std::vector<WeakArrayList> FindAllRetainedMaps(); std::vector<WeakArrayList> FindAllRetainedMaps();
MemoryMeasurement* memory_measurement() { return memory_measurement_.get(); } MemoryMeasurement* memory_measurement() { return memory_measurement_.get(); }
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "src/logging/log-inl.h" #include "src/logging/log-inl.h"
#include "src/logging/log-utils.h" #include "src/logging/log-utils.h"
#include "src/objects/api-callbacks.h" #include "src/objects/api-callbacks.h"
#include "src/objects/osr-optimized-code-cache.h"
#include "src/profiler/tick-sample.h" #include "src/profiler/tick-sample.h"
#include "src/snapshot/embedded/embedded-data.h" #include "src/snapshot/embedded/embedded-data.h"
#include "src/strings/string-stream.h" #include "src/strings/string-stream.h"
...@@ -1896,17 +1895,6 @@ static int EnumerateCompiledFunctions(Heap* heap, ...@@ -1896,17 +1895,6 @@ static int EnumerateCompiledFunctions(Heap* heap,
} }
} }
for (Handle<NativeContext> native_context : heap->FindAllNativeContexts()) {
OSROptimizedCodeCache::Iterator osr_iterator(native_context);
for (std::pair<SharedFunctionInfo, Code> sfiCodePair = osr_iterator.Next();
!sfiCodePair.first.is_null(); sfiCodePair = osr_iterator.Next()) {
AddFunctionAndCode(sfiCodePair.first,
AbstractCode::cast(sfiCodePair.second), sfis,
code_objects, compiled_funcs_count);
++compiled_funcs_count;
}
}
return compiled_funcs_count; return compiled_funcs_count;
} }
......
...@@ -219,24 +219,5 @@ bool OSROptimizedCodeCache::NeedsTrimming(int num_valid_entries, ...@@ -219,24 +219,5 @@ bool OSROptimizedCodeCache::NeedsTrimming(int num_valid_entries,
return curr_length > kInitialLength && curr_length > num_valid_entries * 3; return curr_length > kInitialLength && curr_length > num_valid_entries * 3;
} }
OSROptimizedCodeCache::Iterator::Iterator(Handle<NativeContext> native_context)
: cache_(native_context->GetOSROptimizedCodeCache(),
native_context->GetIsolate()) {}
std::pair<SharedFunctionInfo, Code> OSROptimizedCodeCache::Iterator::Next() {
while (index_ < cache_->length()) {
if (cache_->Get(index_ + kSharedOffset)->IsCleared() ||
cache_->Get(index_ + kCachedCodeOffset)->IsCleared()) {
index_ += kEntryLength;
continue;
}
auto result = std::make_pair(cache_->GetSFIFromEntry(index_),
cache_->GetCodeFromEntry(index_));
index_ += kEntryLength;
return result;
}
return std::make_pair(SharedFunctionInfo(), Code());
}
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -48,19 +48,6 @@ class V8_EXPORT OSROptimizedCodeCache : public WeakFixedArray { ...@@ -48,19 +48,6 @@ class V8_EXPORT OSROptimizedCodeCache : public WeakFixedArray {
// Remove all code objects marked for deoptimization from OSR code cache. // Remove all code objects marked for deoptimization from OSR code cache.
void EvictMarkedCode(Isolate* isolate); void EvictMarkedCode(Isolate* isolate);
// Iterate over all entries in the cache, skipping cleared or null entries.
class Iterator {
public:
explicit Iterator(Handle<NativeContext> native_context);
// Both results will be null when iteration has finished.
std::pair<SharedFunctionInfo, Code> Next();
private:
Handle<OSROptimizedCodeCache> cache_;
int index_ = 0; // Index into the FixedArray; a multiple of kEntryLength.
};
private: private:
// Functions that implement heuristics on when to grow / shrink the cache. // Functions that implement heuristics on when to grow / shrink the cache.
static int CapacityForLength(int curr_capacity); static int CapacityForLength(int curr_capacity);
......
...@@ -2241,7 +2241,10 @@ static const char* pre_profiling_osr_script = R"( ...@@ -2241,7 +2241,10 @@ static const char* pre_profiling_osr_script = R"(
)"; )";
// Testing profiling of OSR code that was OSR optimized before profiling // Testing profiling of OSR code that was OSR optimized before profiling
// started. // started. Currently the behavior is not quite right so we're currently
// testing a deopt event being sent to the sampling thread for a function
// it knows nothing about. This deopt does mean we start getting samples
// for hot so we expect some samples, just fewer than for notHot.
// //
// We should get something like: // We should get something like:
// 0 (root):0 3 0 #1 // 0 (root):0 3 0 #1
...@@ -2250,6 +2253,15 @@ static const char* pre_profiling_osr_script = R"( ...@@ -2250,6 +2253,15 @@ static const char* pre_profiling_osr_script = R"(
// 85 hot:5 0 4 #6 // 85 hot:5 0 4 #6
// 0 whenPass:2 0 4 #3 // 0 whenPass:2 0 4 #3
// 0 startProfiling:0 2 0 #4 // 0 startProfiling:0 2 0 #4
//
// But currently get something like:
// 0 (root):0 3 0 #1
// 12 (garbage collector):0 3 0 #5
// 57 notHot:22 0 4 #2
// 33 hot:5 0 4 #6
// 0 whenPass:2 0 4 #3
// 0 startProfiling:0 2 0 #4
TEST(StartProfilingAfterOsr) { TEST(StartProfilingAfterOsr) {
i::FLAG_allow_natives_syntax = true; i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
...@@ -2272,8 +2284,10 @@ TEST(StartProfilingAfterOsr) { ...@@ -2272,8 +2284,10 @@ TEST(StartProfilingAfterOsr) {
const CpuProfileNode* root = profile->GetTopDownRoot(); const CpuProfileNode* root = profile->GetTopDownRoot();
const v8::CpuProfileNode* notHotNode = GetChild(env, root, "notHot"); const v8::CpuProfileNode* notHotNode = GetChild(env, root, "notHot");
const v8::CpuProfileNode* hotNode = GetChild(env, notHotNode, "hot"); const v8::CpuProfileNode* hotNode = GetChild(env, notHotNode, "hot");
USE(hotNode);
CHECK_GT(hotNode->GetHitCount(), notHotNode->GetHitCount()); // If/when OSR sampling is fixed the following CHECK_GT could/should be
// uncommented and the node = node line deleted.
// CHECK_GT(hotNode->GetHitCount(), notHotNode->GetHitCount());
} }
TEST(DontStopOnFinishedProfileDelete) { TEST(DontStopOnFinishedProfileDelete) {
......
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