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

perf: Make OwningReference/BorrowingReference lock-free, and only allocate memory block once #522

Merged
merged 5 commits into from
Feb 3, 2025

Conversation

mrousavy
Copy link
Owner

@mrousavy mrousavy commented Feb 3, 2025

This should speed up allocations of new OwningReference/BorrowingReference types - which Nitro uses extensively in the codebase.

  • Instead of new bool + new size_t + new size_t + new mutex, we now only allocate a single state block: new ReferenceState - which is a struct. 📈
  • Instead of std::recursive_mutex we now use std::mutex - which is faster and lighter 🪶
  • This PR also removes all mutex locking operations of OwningReference and BorrowingReference! 🥳 Only OwningLock and destroy() need to lock the mutex :)

Copy link

vercel bot commented Feb 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
nitro-docs ⬜️ Skipped (Inspect) Feb 3, 2025 5:08pm

@mrousavy mrousavy changed the title perf: Make OwningReference/BorrowingReference only allocate memory block once perf: Make OwningReference/BorrowingReference only allocate memory block once and remove locking Feb 3, 2025
@mrousavy mrousavy merged commit 1d6f8c3 into main Feb 3, 2025
12 checks passed
@mrousavy mrousavy changed the title perf: Make OwningReference/BorrowingReference only allocate memory block once and remove locking perf: Make OwningReference/BorrowingReference lock-free, and only allocate memory block once Feb 3, 2025
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.

1 participant