Bug 21172 - Profiler has a significant impact on performance
Summary: Profiler has a significant impact on performance
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://nerget.com/rayjs3/rayjs.html
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2008-09-27 01:11 PDT by Oliver Hunt
Modified: 2014-12-16 00:18 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Hunt 2008-09-27 01:11:37 PDT
If you run my 100% real world webpage with the profiler enabled you can see the JS Profiler has a huge (~2x slower) performance impact.  This makes me sad.

To reproduce
1. Click the "render" link and wait for the render to complete
2. Click the "render with profiler" link and once again wait for the render to complete
3. notice that the second time is ~2x larger than the first

Note: this should be done with a new window, and no other windows open.  The inspector should not have been opened as that will trigger excessive GC cost due to the DOM, which is a completely separate issue.
Comment 1 Mark Rowe (bdash) 2008-09-27 14:24:32 PDT
<rdar://problem/6252644>
Comment 2 Oliver Hunt 2008-09-28 20:11:34 PDT
Okay, i'm looking at this and i believe the problem is that the profiler does far too much work on entry/exit.  Requesting the name of a Function is a generic property lookup, and hence is a far too heavy cost for function entry and exit.  I think a better approach would be just to store the function pointer, and retrieve the actual information once profiling is complete.
Comment 3 Kevin McCullough 2008-09-29 10:18:36 PDT
Can you guarantee the function pointer will be valid after profiling is complete?  Will GC collect stuff?  WIll context be lost?

Also is it so bad to slow down while profiling?  As long as profiling doesn't affect the relative speeds of the parts of the code being profiled the numbers will be accurate.

We of course should want JS executing as fast as possible even with the profiler running, so if you have a good solution we should jump on it.

If we can get names after the fact, we need something unique to store in ProfileGenerator that we can compare to see if the same function was called multiple times and then when StopProfiling is called we would convert all of those unique things to strings when storing them in the actual Profile.

Maybe these unique things can simply be stored in the CallIdentifier?
Comment 4 Oliver Hunt 2008-09-29 12:04:39 PDT
Because all of the overhead of the inspector happens on call entry and return the profiler will greatly exaggerate the runtime cost of call heavy code.

To be able to store just the function object pointer you'll need to be add logic so that we can gc any objects that the profile references (i imagine once profileEnd() occurs you can immediately actually extract all the profile info, and drop the funciton object references, but you'll probably want to wait until there are no active profiles)
Comment 5 Kevin McCullough 2008-09-29 13:26:57 PDT
I talked with Geoff a little and he had some good ideas here.  He said we should shoot for the profiler costing 10% overhead.

He also agreed with the idea of holing the JSFunction pointers while collecting the profile and figuring out the names after the fact.  We don't even need to see if there are function duplicates we could collapse them when the profile stops.

Basically he supported the idea of doing as little work as possible during the collection phase; however this does mean we will need to let the Garbage Collector know which functions we are holding onto so that they don't disappear on us!
Comment 6 Brian Burg 2014-12-16 00:18:45 PST
Closing this in preference for integrating DFG/FTL performance data directly, rather than making the unrealistic interpreter times slightly more realistic.