Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Cache toObject(...) using jsi::WeakObject and correctly set externalExternalMemoryPressure #13

Merged
merged 2 commits into from
Aug 8, 2024

Conversation

mrousavy
Copy link
Owner

@mrousavy mrousavy commented Aug 8, 2024

This PR now improves performance of passing HybridObjects to JS.

  1. jsi::Object instances of a given HybridObject are now cached using WeakObject, and can be re-used in subsequent calls.
    Subsequent calls use the cached object and return it to JS, which avoids going the long prototype assignment route.
  2. Additionally, setExternalMemoryPressure can now finally be used properly, since we know that we only have one jsi::Object instance of the same HybridObject in memory, so it will no longer track memory for the same object twice/thrice/...! 🥳
  3. And lastly; obj.foo == obj.foo now works, since we actually return the same jsi::Object! It's cached in a weakref, so that finally works. cc @wcandillon

@mrousavy
Copy link
Owner Author

mrousavy commented Aug 8, 2024

cc @hannojg because setExternalMemoryPressure now works
cc @wcandillon because obj.foo == obj.foo now works

@wcandillon
Copy link

nice :)

@mrousavy mrousavy merged commit c101faf into main Aug 8, 2024
@mrousavy
Copy link
Owner Author

mrousavy commented Aug 8, 2024

released in 0.2.0

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.

2 participants