Giter Club home page Giter Club logo

Comments (12)

ericelliott avatar ericelliott commented on June 9, 2024 1

Looks like the null prototype is the problem. Try it with {} as the prototype?

from stampit.

koresar avatar koresar commented on June 9, 2024 1

descriptor.methods ? Object.create(descriptor.methods) : {} and
descriptor.methods ? {__proto__: descriptor.methods} : {}; and
{__proto__: descriptor.methods}
are identical in my benchmark.

The last one is less code though. Tested in IE11, it works.

from stampit.

koresar avatar koresar commented on June 9, 2024 1

Tested against all node.js LTS 4,6,8. Property access of plain and stampit objects identical now in all three.

Node v7 did not have that problem. Only 8.x had.

from stampit.

koresar avatar koresar commented on June 9, 2024

Created a bug in V8 bugtracker: https://bugs.chromium.org/p/v8/issues/detail?id=6909

from stampit.

ericelliott avatar ericelliott commented on June 9, 2024

It sounds like V8 implemented some optimizations that are not available for objects created with Object.assign(). Probably not a bug in v8 -- they just opened up a new fast path.

A performance degradation would mean that something got slower between v7 and v8. Sounds like the opposite happened?

from stampit.

koresar avatar koresar commented on June 9, 2024

It got x3 faster for plain objects, but x6 times slower for Obejct.assign-ed objects.

It happened after they moved to the new pipeline in V8 v6.0: https://v8project.blogspot.com.au/2017/05/launching-ignition-and-turbofan.html

from stampit.

ericelliott avatar ericelliott commented on June 9, 2024

Oh, I see:
Before: Stampit x 90,346,971 ops/sec
After: Stampit x 19,520,623 ops/sec

from stampit.

koresar avatar koresar commented on June 9, 2024

I will try.

from stampit.

koresar avatar koresar commented on June 9, 2024

Ok. Fixed it.
Instead of Object.create(descriptor.methods || null) I put descriptor.methods ? Object.create(descriptor.methods) : {}.
The performance is back!

from stampit.

koresar avatar koresar commented on June 9, 2024

Even better:

descriptor.methods ? {__proto__: descriptor.methods} : {};

Now, that's fast in any case! :)

from stampit.

ericelliott avatar ericelliott commented on June 9, 2024

Did you test the {__proto__: descriptor.methods} : {}; vs descriptor.methods ? Object.create(descriptor.methods) : {}? Was there any perf difference?

from stampit.

ericelliott avatar ericelliott commented on June 9, 2024

Faster in Node v7, too?

from stampit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.