[meta] Profile JS shell benchmarks with the Gecko profiler.

NEW
Unassigned

Status

()

Core
JavaScript Engine
5 years ago
3 years ago

People

(Reporter: nbp, Unassigned)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

5 years ago
Many solution are working on getting profile information, such as oprofile, or instrumented profilers such as VTune and cachegrind (with a patch) for inspecting the JS events at the assembly level.  Callgrind profiles calls locations and show important locations, but it does not annotate the compiled code and makes JS functions difficult to grasp.

Gecko already has an integrated profiler, which is able to identify C++ and JS frames, and help identifying where issues are located with a call stack representation.  The output of the profiler should also be enough to produce a callgrind like output which might be understandable by kcachegrind or other visualizers.
(Reporter)

Comment 1

5 years ago
Created attachment 678373 [details] [diff] [review]
Support text output for d (dynamic) and n (line) entries.

Currently the TableTicker is extremely tied to XPCom, and it does not sounds to be an easy task to share common pieces between the JS engine and the XPCom profiler.

In the mean time, with this patch, we can dump the output as text from the xpcshell with the following command:

xpcshell -e '
  const Ci = Components.interfaces;
  const Cc = Components.classes;
  var profiler = Cc["@mozilla.org/tools/profiler;1"]
    .getService(Ci.nsIProfiler);
  profiler.StartProfiler(100000, 1, ["js","stackwalk"], 1 /* 2 */);' \
  -f ./run.js \
  -e 'var profileStr = profiler.GetProfile();print(profileStr);'

with run.js being the script that you are trying to profile.
Attachment #678373 - Flags: feedback?(bgirard)
The old format is no longer supported. New features are not supported in this profile and I also want to remove the support from the UI. Right now you can get the profile as a JSObject and should be able to save it as a json string. I've been wanting to add an implemenentation of JSObjectBuilder that doesn't depend on the js engine that can output to a json string directly.
Comment on attachment 678373 [details] [diff] [review]
Support text output for d (dynamic) and n (line) entries.

Let me know if you need more feedback.
Attachment #678373 - Flags: feedback?(bgirard)
(Reporter)

Comment 4

5 years ago
I renamed the bug to make it a meta Bug since I had to fix multiple issues to fix it locally.  I still have to clean-up patches and find the right bug to attach them to and also create a wiki page for documenting this process.
Blocks: 705294
Depends on: 810062
Summary: Integrate the Sampling profiler in the JS shell. → [meta] Profile JS shell benchmarks with the Gecko profiler.
(Reporter)

Updated

5 years ago
Depends on: 709381
(Reporter)

Updated

5 years ago
Depends on: 812063
(Reporter)

Updated

5 years ago
Depends on: 812946
(Reporter)

Comment 5

5 years ago
Created attachment 683345 [details] [diff] [review]
Enable sampling at 100µs.

This patch is a dirty hack to sample the xpcshell with a period below the milli-second.
It would be nice to actually land a patch for microsecond profiling. We can use a feature 'microsecond' to indicate that the interval passes is in non default microsecond units and get feature to indicate that it's supported by the platform.
(Assignee)

Updated

3 years ago
Assignee: general → nobody
You need to log in before you can comment on or make changes to this bug.