Skip to content

Allow opting out of enumerable-safety#9702

Merged
stefanpenner merged 2 commits intoemberjs:masterfrom
stefanpenner:__defineNonEnumerable
Dec 21, 2014
Merged

Allow opting out of enumerable-safety#9702
stefanpenner merged 2 commits intoemberjs:masterfrom
stefanpenner:__defineNonEnumerable

Conversation

@stefanpenner
Copy link
Member

Introduce a __defineNonEnumerable hook. This allows parts of Ember to opt-out of enumerable safety (marking internal properties as non-enumerable).

Unfortunately at this time there is no way to create fast, non-enumerable properties. Historically Ember has this to allow people to merge, extend and JSON.stringify Ember objects, which requires being careful about enumerability.

Unfortunately, classes like Ember.View should do not be used in these contexts, but still suffer from the pretty hefty overhead.

This PR Reduces the cost of view allocation by 300% -> 400%.

Micro bench (creating 10,000 views):

before: 120ms
after:   35ms

the 25ms of the remaining is mostly funkyness we do in Ember.View and CoreView ourselves. We can be careful and clean lots of that up still.

  • make it work
  • consider more objects
  • only enabled in test mode?
  • more refactorings
  • add support for symbols if they are available

…pt-out of the enumerable safety. Unfortunately at this time there is not way to create fast non-enumerable properties. Historically ember has this to allow people to merge, extend and JSON.stringify. Unfortunately some things like Ember.Views should do not need this but still suffer from the pretty hefty overhead.

This PR Reduces the cost of view allocation by 300% -> 400%.

Micro bench (creating 10,000 views):

before: 120ms
after:   35ms
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment needed? I thought perhaps it was from a refactor/test and might be able to be removed now....

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its for perfs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So sorry, better leave it in then. 😉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is really going on here? Why not use the commented line instead of defineProp? Mixins don't care if they have extra enumerable props, yes? This line is responsible for a very large number of defineProp calls in my testing.

@rwjblue
Copy link
Member

rwjblue commented Nov 25, 2014

Seems pretty darn good.

@wycats wycats changed the title define non enumerable Allow opting out of enumerable-safety Nov 25, 2014
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't included in my above #'s but it helps

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this was already merged in https://github.com/emberjs/ember.js/pull/9701/files.

@wagenet
Copy link
Member

wagenet commented Dec 18, 2014

@stefanpenner status?

@stefanpenner
Copy link
Member Author

likely a final set of benchmarks, maybe expand it to other objects.

@ebryn
Copy link
Member

ebryn commented Dec 21, 2014

Let's merge this bad boy!

@mixonic
Copy link
Member

mixonic commented Dec 21, 2014

as [BUGFIX beta] please :-D

@stefanpenner
Copy link
Member Author

as [BUGFIX beta] please :-D

In the meeting we discussed this as a full canary cycle change, if @wycats is already with it being rushed to beta, thats ok.

@mixonic
Copy link
Member

mixonic commented Dec 21, 2014

Ah, did not realize that was the consensus.

@stefanpenner
Copy link
Member Author

@eviltrout got time to run this through your benchmarks?

stefanpenner added a commit that referenced this pull request Dec 21, 2014
@stefanpenner stefanpenner merged commit b865478 into emberjs:master Dec 21, 2014
@stefanpenner stefanpenner deleted the __defineNonEnumerable branch December 21, 2014 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants