Giter VIP home page Giter VIP logo

Comments (9)

harthur avatar harthur commented on May 18, 2024

I came across this when searching for other projects having issues with GetIdentityHash. Circling back around just to say that I found out it's only 21 bits now, so we in another project were having issues with collisions in just hundreds of instances.

from rusty_v8.

ry avatar ry commented on May 18, 2024

Ok thanks - good to know.

from rusty_v8.

zbendefy avatar zbendefy commented on May 18, 2024

Hi! Is there an estimate on this issue? We're using GetIdentityHash() to identify objects, and we would like to know if we can rely on it or not.

from rusty_v8.

ry avatar ry commented on May 18, 2024

@zbendefy I've had no problems with it.

from rusty_v8.

zbendefy avatar zbendefy commented on May 18, 2024

@ry We'll use potentially thousands of objects, that we are identifying (for storage in a hashmap) using GetIdentityHash(). We didn't do thorough testing yet, but having a Stable way to identify JS objects would be nice.

I presume that we cannot use the underlying pointer values behind a Local<> or Persistent<> handle?

from rusty_v8.

lucacasonato avatar lucacasonato commented on May 18, 2024

@ry Is this still relevant?

from rusty_v8.

ry avatar ry commented on May 18, 2024

Yes

from rusty_v8.

kitsonk avatar kitsonk commented on May 18, 2024

These bindings are now in rust_v8 so I moved it.

from rusty_v8.

bnoordhuis avatar bnoordhuis commented on May 18, 2024

This is not for rusty_v8 to fix. The identity hash itself isn't buggy but it can be used in a way that introduces bugs.

To summarize:

  1. An object's identity hash is a 21 or 22 bits random number (on 32 and 64 bits architectures respectively)

  2. Per the Birthday Paradox, that means the chance of a collision is > 50% with approx. 1700 or 2400 objects.

You can use it to store objects in a hashmap but you need to additionally check with a.same_value(b) if the object already exists in the hashmap bucket.

from rusty_v8.

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.