CpuProfiler not collecting data in jitless mode (iOS)

34 views
Skip to first unread message

Darin Dimitrov

unread,
Nov 6, 2019, 2:58:20 AM11/6/19
to v8-users
I am trying to collect function execution data using the CpuProfiler class.

I ran the following test (taken from here https://github.com/v8/v8/blob/master/test/cctest/test-cpu-profiler.cc#L677):

const char* src =
   
"function loop(timeout) {\n"
   
"  this.mmm = 0;\n"
   
"  var start = Date.now();\n"
   
"  do {\n"
   
"    var n = 1000;\n"
   
"    while(n > 1) {\n"
   
"      n--;\n"
   
"      this.mmm += n * n * n;\n"
   
"    }\n"
   
"  } while (Date.now() - start < timeout);\n"
   
"}\n"
   
"function delay() { loop(10); }\n"
   
"function bar() { delay(); }\n"
   
"function baz() { delay(); }\n"
   
"function foo() {\n"
   
"  delay();\n"
   
"  bar();\n"
   
"  delay();\n"
   
"  baz();\n"
   
"}\n"
   
"function start(duration) {\n"
   
"  var start = Date.now();\n"
   
"  do {\n"
   
"    foo();\n"
   
"  } while (Date.now() - start < duration);\n"
   
"}\n";

Script::Compile(context, v8::String::NewFromUtf8(isolate, src).ToLocalChecked()).ToLocalChecked()->Run(context).ToLocalChecked();
Local<v8::Function> startFunc = context->Global()->Get(context, v8::String::NewFromUtf8(isolate, "start").ToLocalChecked()).ToLocalChecked().As<v8::Function>();

Local<v8::String> title = v8::String::NewFromUtf8(isolate, "my_trace").ToLocalChecked();
CpuProfiler* profiler = CpuProfiler::New(isolate);
profiler
->StartProfiling(title, false);

Local<Value> result;
Local<Value> args[] = { Number::New(isolate, 200) };
assert(startFunc->Call(context, context->Global(), 1, args).ToLocal(&result));

const CpuProfile* profile = profiler->StopProfiling(title);
const CpuProfileNode* root = profile->GetTopDownRoot();
int count = root->GetChildrenCount();
for (int i = 0; i < count; ++i) {
   
const CpuProfileNode* child = root->GetChild(i);
    v8
::String::Utf8Value str(isolate, child->GetFunctionName());
   
const char* funcName = *str;
    printf
("%s\n", funcName);
}



The root CpuProfileNode contains only a single child element called "(program)".

If I execute the same code on Android, I correctly get the following child functions: "(program)", "start" and "(garbage collector)".

Do you have any idea what might be wrong with the CpuProfiler class in v8 in jitless mode? Is CpuProfiler the correct class to use to collect function execution times or is there some newer method?

Jakob Gruber

unread,
Nov 6, 2019, 3:26:41 AM11/6/19
to v8-u...@googlegroups.com, Peter Marshall

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/798f9464-88a1-464f-8fb8-6aa223ce5e57%40googlegroups.com.

Darin Dimitrov

unread,
Nov 6, 2019, 7:44:46 AM11/6/19
to v8-users
I managed to find the reason for this. I forgot to enter the isolate after creating it:

isolate->Enter()

All looks good now. Sorry for the false alert.



On Wednesday, November 6, 2019 at 10:26:41 AM UTC+2, Jakob Gruber wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to v8-u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages