[Webkit-unassigned] [Bug 116764] == and === should have more comparable performance when both sides are strings

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat May 25 17:26:14 PDT 2013


https://bugs.webkit.org/show_bug.cgi?id=116764





--- Comment #4 from Filip Pizlo <fpizlo at apple.com>  2013-05-25 17:24:44 PST ---
(In reply to comment #3)
> (In reply to comment #0)
> > I stumbled across a micro-benchmark today comparing == and === between strings. Chrome and Firefox have nearly equivalent performance for each, while the WebKit Nightly showed `===` being noticeably better than `==`. It seems we could improve `==` in such cases to match `===`:
> > <http://jsperf.com/comparison-of-comparisons>
> > 
> > WebKit Nightly r150579 / Safari 6.0.4:
> > ==: 260,969,330
> > ===: 420,311,703
> > difference: ~61% more
> > 
> > Chrome Canary 29.0.1518.2:
> > ==: 367,785,800
> > ===: 375,298,004
> > difference: ~2% more
> > 
> > Firefox Nightly 23.0a1 (2013-04-28):
> > ==: 776,644,421
> > ===: 777,027,376
> > difference: ~0% more
> > 
> > 
> > JSBench Test
> > 
> > Setup:
> > <script>
> >   Benchmark.prototype.setup = function() {
> >     var a = 'hello';
> >     var b = 'world';
> >     var c = 'hello';
> >   };
> > </script>
> > 
> > Test1: "Identity"
> > a === b;
> > a === c;
> > 
> > Test2: "Equality"
> > a == b;
> > a == c;
> 
> Lol.  This is just us being dumb.  We have separate implementations of == and === and we added more optimizations to one and not the other, I guess.

Lololololo.

Here's why.

CompareStrictEq (i.e. ===) is a DCE candidate.  So we dead-code eliminate it.

CompareEq isn't, because it could possibly be effectful.  We're being slightly more paranoid than we need to be.

In any case, it appears that this silly test that just checks if the relevant op can be dead-code eliminated, and after it is eliminated, it tests how ridiculously good of a job the VM's top tier compiler does at killing the entire test loop.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list