Bug 97122 - JS binding through JSC API is much slower than binding through WebCore
Summary: JS binding through JSC API is much slower than binding through WebCore
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar, Performance
Depends on:
Blocks:
 
Reported: 2012-09-19 11:08 PDT by Chang Shu
Modified: 2013-07-11 17:21 PDT (History)
6 users (show)

See Also:


Attachments
Code does the binding through both JSC API and WebCore that demonstrates the performance. (8.60 KB, patch)
2012-09-19 11:08 PDT, Chang Shu
no flags Details | Formatted Diff | Diff
Profiling result (1.76 MB, application/x-tar)
2012-09-24 07:01 PDT, Chang Shu
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chang Shu 2012-09-19 11:08:16 PDT
Created attachment 164757 [details]
Code does the binding through both JSC API and WebCore that demonstrates the performance.

While using JSC API for JS binding, I found the performance is quite slow comparing to binding the same interface inside WebCore. I have attached a test file that adds a MyTest object that does doSqrt() inside WebCore and also hacks a doSqrt() in TestRunner in WebKitTestRunner.
Run "WebKitBuild/Release/WebKitTestRunner LayoutTests/MyTest.html" shows that the latter is 7-8 times slower.
Comment 1 Geoffrey Garen 2012-09-20 12:47:21 PDT
<rdar://problem/12339275>
Comment 2 Sam Weinig 2012-09-23 00:07:04 PDT
Do you have any samples that might indicate where the time might be going?
Comment 3 Chang Shu 2012-09-24 07:01:14 PDT
Created attachment 165371 [details]
Profiling result

I did some profiling but didn't seem to find the bottleneck.
Comment 4 Geoffrey Garen 2013-07-11 14:33:33 PDT
One thing I see here is that JSWrapper::unwrap unnecessarily checks for null and calls JSValueToObject. It should just ASSERT non-null and ASSERT JSValueIsObjectOfClass, since this is guaranteed by the code generator. Then, it should static_cast to JSObjectRef.

This is not very important, since it's only test code, but if you're going to this piece of the test infrastructure for performance investigations, you should optimize it, so we don't get bogus results.