Status: New
Owner: ----

New issue 3903 by [email protected]: Math.log10 is unexpectedly slow
https://code.google.com/p/v8/issues/detail?id=3903

[Version:] 40.0.2214.111 m
[OS:] Win8.1 x64
[Architecture:] X86_64 i7 3770k Ivy Bridge

[What steps will reproduce the problem?]
1. Just open the attached .html file which shows it clearly.  Or...
2. Using Float64Arrays, loop and perform Math.log10 on large random sample set. 3. Create another test for a polyfill approximation of Math.log10 using Math.log(x) * 1/Math.LN10.
4. Run loops, time, etc.

[What is the expected output?]
Expected: Math.log10, being native code etc, is much faster than a JS polyfill. Most implementations of log10 seem to be about 10 ops followed by log, which is not as significant of a difference as seen here.

[What do you see instead?]
Actual: Polyfill is >20% faster than the real Math.log10 in multiple tests on multiple platforms. (For the included sample project, Math.log10 performed an estimated 83 ops per element, 128 passes on 262144 elements. In 4455ms that's about 0.6 GFLOPS.)

[Please use labels and text to provide additional information.]

Please see attached sample file which demonstrates this and benchmarks performance.

As a point of comparison, Firefox 35.0.1 x86 was faster than Chrome executing Math.log10, and the difference between the polyfill and Math.log10 on Firefox was < 2%.

In inspecting the V8, SpiderMonkey, and JavaScriptCore sources, what I see as maybe being the issue (or not) is Math.log10 spends more time bouncing around in .js wrappers before hitting native code, whereas SpiderMonkey and JSC have fewer function calls and less ops before invoking whatever math.h/stdlib function got compiled in.

In terms of algorithms all VM and gcc log/log10 implementations looked more or less the same.

Attachments:
        log_perf_sample.html  4.6 KB

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to