<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>143239</bug_id>
          
          <creation_ts>2015-03-30 16:07:45 -0700</creation_ts>
          <short_desc>No way to quickly make non-enumerable instance properties</short_desc>
          <delta_ts>2015-03-30 18:28:33 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ryosuke Niwa">rniwa</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1081358</commentid>
    <comment_count>0</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2015-03-30 16:07:45 -0700</bug_when>
    <thetext>I was talking with https://twitter.com/stefanpenner (Ember.js core member) and he told me that they currently work around the fact we can&apos;t create a non-enumrerable property fast.

SpiderMonkey bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1088453
V8 bug: https://code.google.com/p/v8/issues/detail?id=3649</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1081362</commentid>
    <comment_count>1</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2015-03-30 16:10:16 -0700</bug_when>
    <thetext>I&apos;ve manually enabled symbols in JSC and got results on https://jsperf.com/symbol-vs-prop-vs-def-prop:

property       68,907,822 ±0.30%  fastest
non-enumerable 4,093,475 ±0.58%   94% slower
symbol         11,586,795 ±0.36%  83% slower
weakmap        5,361,775 ±2.15%   92% slower</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1081363</commentid>
    <comment_count>2</comment_count>
    <who name="Filip Pizlo">fpizlo</who>
    <bug_when>2015-03-30 16:12:43 -0700</bug_when>
    <thetext>That&apos;s super interesting.  I think that the main problem is that making a property non-enumerable doesn&apos;t involve a cached transition.  This means that if you make something non-enumerable, all accesses to the object go slow after that.

Once we fix that, then the next problem is that the call to make it non-enumerable is not intrinsic.  We should make that call be intrinsic.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1081365</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2015-03-30 16:15:08 -0700</bug_when>
    <thetext>Accessing a property using symbol seems pretty fast (http://jsperf.com/symbol-vs-property/13):

symbol    18,871,149 ±0.94%  28% slower
property  18,106,575 ±0.42%  31% slower
.foo      26,093,814 ±0.53%  fastest

(Chrome results are somewhat misleading because it ran on a much faster results; what&apos;s important is the relative perf. of different cases).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1081366</commentid>
    <comment_count>4</comment_count>
    <who name="Filip Pizlo">fpizlo</who>
    <bug_when>2015-03-30 16:15:52 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; I&apos;ve manually enabled symbols in JSC and got results on
&gt; https://jsperf.com/symbol-vs-prop-vs-def-prop:
&gt; 
&gt; property       68,907,822 ±0.30%  fastest
&gt; non-enumerable 4,093,475 ±0.58%   94% slower
&gt; symbol         11,586,795 ±0.36%  83% slower
&gt; weakmap        5,361,775 ±2.15%   92% slower

The best way to benchmark this is to take a medium-sized test that is known to create a lot of objects and access a lot of properties, and modify it to make all of the properties non-enumerable.  Then also make a version that uses symbols.  Then also make a version that uses WeakMap.  That is, uses those things for all of the properties.

I recommend either V8/deltablue or V8/raytrace.  V8/raytrace could be hilarious since in that one we do very aggressive object allocation sinking but we can&apos;t do it if you do things we don&apos;t optimize (like all of the things you list above).  So, just make three new versions of raytrace:

raytrace-non-enum
raytrace-symbol
raytrace-weakmap

I know it&apos;s tedious, but this is what I do when I want to come up with a good story for optimizing a feature.  Like, we have getter-richards for when I was optimizing getters/setters, and now we have deltablue-varargs to help me with my varargs optimization work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1081367</commentid>
    <comment_count>5</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2015-03-30 16:16:57 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; Once we fix that, then the next problem is that the call to make it
&gt; non-enumerable is not intrinsic.  We should make that call be intrinsic.

Since class methods are non-enumerable (bugs 143181), we should add the intrinsic for defineProperty anyway.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1081370</commentid>
    <comment_count>6</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2015-03-30 16:18:02 -0700</bug_when>
    <thetext>Oh these are tests made by Ember.js folks. Also see the original bug report by https://twitter.com/stefanpenner at https://code.google.com/p/v8/issues/detail?id=3649 and https://bugzilla.mozilla.org/show_bug.cgi?id=1088453.

I&apos;ve asked him to file a bug but he&apos;s really busy right now so I&apos;m doing it on his behalf.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1081373</commentid>
    <comment_count>7</comment_count>
    <who name="Filip Pizlo">fpizlo</who>
    <bug_when>2015-03-30 16:21:07 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; Accessing a property using symbol seems pretty fast
&gt; (http://jsperf.com/symbol-vs-property/13):
&gt; 
&gt; symbol    18,871,149 ±0.94%  28% slower
&gt; property  18,106,575 ±0.42%  31% slower
&gt; .foo      26,093,814 ±0.53%  fastest
&gt; 
&gt; (Chrome results are somewhat misleading because it ran on a much faster
&gt; results; what&apos;s important is the relative perf. of different cases).

No.  Relative perf doesn&apos;t matter.  It&apos;s possible that just adding a symbol-keyed property puts the prototype into a slower mode, in which case this test is bogus.

If Chrome is much faster on basic property accesses in your test then one of the following is happening:

- Our property accesses are completely busted and we should go back to the drawing board.  Unlikely, since we are very competitive on property access tests.

- Putting symbols into an object makes accesses to even normal properties slower, in which case &quot;accessing a property using a symbol seems pretty fast&quot; is an incorrect conclusion.

- jsperf puts each microbenchmark snippet into some kind of bizarro loop, and we&apos;re running that loop slowly.  I.e. you&apos;re not even testing property access performance but you&apos;re just testing the performance of the jsperf harness.

Anyway, it&apos;s completely wrong to conclude that something is fast the baseline (accessing .foo) is an order of magnitude slower than Chrome.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1081527</commentid>
    <comment_count>8</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2015-03-30 18:23:02 -0700</bug_when>
    <thetext>Alright, I&apos;ve made a slightly better micro benchmark at https://gist.github.com/rniwa/572ed56668366e6542d3

It doesn&apos;t seem like defining or accessing symbol properties isn&apos;t significantly slower:

Defining string properties: 242 ms 
Accessing string properties: 95 ms 
Defining symbol properties: 271 ms 
Accessing string properties: 143 ms</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1081528</commentid>
    <comment_count>9</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2015-03-30 18:28:33 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt;
&gt; Anyway, it&apos;s completely wrong to conclude that something is fast the
&gt; baseline (accessing .foo) is an order of magnitude slower than Chrome.

I don&apos;t think anyone is claiming that here.

This bug is about Ember.js wanting to define and access non-enumerable property without runtime penalty. Either making defineProperty fast or symbols perform as fast as strings would work (although we should really do both!)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>