Bug 123255 - Add result caching for Math.cos
Summary: Add result caching for Math.cos
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-24 01:03 PDT by Iago Toral
Modified: 2013-10-31 11:49 PDT (History)
3 users (show)

See Also:


Attachments
Adds result caching for Math.cos (1.63 KB, patch)
2013-10-24 01:13 PDT, Iago Toral
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Iago Toral 2013-10-24 01:03:55 PDT
Currently JavaScriptCore caches results for Math.sin, as introduced by the patch for bug #38714. I think it makes sense to do the same for Math.cos, since the same rationale used for Math.sin applies to Math.cos and also because these two functions are typically used together, for example to compute rotation transformations.

I'll upload a patch shortly.
Comment 1 Iago Toral 2013-10-24 01:13:52 PDT
Created attachment 215035 [details]
Adds result caching for Math.cos

A quick test consisting of averaging 5 consecutive runs of Sunspider shows a 1.9% benefit in my case.
Comment 2 Brent Fulgham 2013-10-30 10:06:05 PDT
Comment on attachment 215035 [details]
Adds result caching for Math.cos

r=me
Comment 3 WebKit Commit Bot 2013-10-30 10:45:49 PDT
Comment on attachment 215035 [details]
Adds result caching for Math.cos

Clearing flags on attachment: 215035

Committed r158281: <http://trac.webkit.org/changeset/158281>
Comment 4 WebKit Commit Bot 2013-10-30 10:45:51 PDT
All reviewed patches have been landed.  Closing bug.
Comment 5 Filip Pizlo 2013-10-30 16:44:44 PDT
Was this based on any benchmarking?  If so, why aren't the benchmarks part of the patch?
Comment 6 Iago Toral 2013-10-31 00:04:59 PDT
(In reply to comment #5)
> Was this based on any benchmarking?  If so, why aren't the benchmarks part of the patch?

I ran the sunspider benchmark to assess performance improvement, my tests showed a 1.9% performance improvement on this benchmark as I mention in comment #1.

I did not know there was a policy to include the benchmark results in the ChangeLog as part of the patch, so that was my bad :(
Comment 7 Filip Pizlo 2013-10-31 09:22:24 PDT
(In reply to comment #1)
> Created an attachment (id=215035) [details]
> Adds result caching for Math.cos
> 
> A quick test consisting of averaging 5 consecutive runs of Sunspider shows a 1.9% benefit in my case.

It's customary to post full performance results to bugzilla for optimizations like these.

It's customary to run more than just SunSpider.  It's unwise to rely on a single benchmark for optimizations.  For example, Octane, JSBench, and Kraken are also important benchmarks.
Comment 8 Filip Pizlo 2013-10-31 09:23:40 PDT
Anyway, see: https://bugs.webkit.org/show_bug.cgi?id=123574
Comment 9 Filip Pizlo 2013-10-31 11:49:34 PDT
(In reply to comment #7)
> (In reply to comment #1)
> > Created an attachment (id=215035) [details] [details]
> > Adds result caching for Math.cos
> > 
> > A quick test consisting of averaging 5 consecutive runs of Sunspider shows a 1.9% benefit in my case.
> 
> It's customary to post full performance results to bugzilla for optimizations like these.
> 
> It's customary to run more than just SunSpider.  It's unwise to rely on a single benchmark for optimizations.  For example, Octane, JSBench, and Kraken are also important benchmarks.

Also, I cannot reproduce the speed-up that you're reporting.  I'm seeing a 0.35% difference before and after your patch and that difference is in the noise.