Skip to content

feat(neon): Export LazyLock globals #1111

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

Merged
merged 1 commit into from
Jul 18, 2025
Merged

feat(neon): Export LazyLock globals #1111

merged 1 commit into from
Jul 18, 2025

Conversation

kjvalencik
Copy link
Member

This changes the macro to call try_into_js on a reference and leverage autoref specialization and autoderef to make it work. Since the macro only works on static and const, it already only worked on Copy types which continues to work.

This makes it more flexible so that you can also export types where their reference implements TryIntoJs. I also added a TryIntoJs implementation for LazyLock<T> where &T: TryIntoJs. It only makes sense to implement it for a reference since getting an owned value would require clone.

The combination of these features allows you to export things like LazyLock<Vec<u8>>.

Copy link

github-actions bot commented Jul 16, 2025

🐰 Bencher Report

Branchkv/lazylock
Testbedubuntu-latest
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
nanoseconds (ns)
(Result Δ%)
Lower Boundary
nanoseconds (ns)
(Limit %)
Upper Boundary
nanoseconds (ns)
(Limit %)
ThroughputBenchmark Result
operations / second (ops/s)
(Result Δ%)
Lower Boundary
operations / second (ops/s)
(Limit %)
Upper Boundary
operations / second (ops/s)
(Limit %)
JsFunction::bind📈 view plot
🚷 view threshold
243.91 ns
(+17.58%)Baseline: 207.44 ns
186.70 ns
(76.54%)
414.89 ns
(58.79%)
📈 view plot
🚷 view threshold
4,108,574.90 ops/s
(-14.55%)Baseline: 4,808,028.76 ops/s
0.00 ops/s
(0.00%)
5,288,831.64 ops/s
(77.68%)
JsFunction::call📈 view plot
🚷 view threshold
223.49 ns
(+2.18%)Baseline: 218.73 ns
196.86 ns
(88.08%)
437.46 ns
(51.09%)
📈 view plot
🚷 view threshold
4,459,983.96 ops/s
(-2.03%)Baseline: 4,552,206.20 ops/s
0.00 ops/s
(0.00%)
5,007,426.82 ops/s
(89.07%)
JsFunction::call_with📈 view plot
🚷 view threshold
192.83 ns
(-6.49%)Baseline: 206.23 ns
185.60 ns
(96.25%)
412.45 ns
(46.75%)
📈 view plot
🚷 view threshold
5,176,853.28 ops/s
(+6.78%)Baseline: 4,848,148.80 ops/s
0.00 ops/s
(0.00%)
5,332,963.68 ops/s
(97.07%)
auto-exported-noop📈 view plot
🚷 view threshold
27.83 ns
(-9.14%)Baseline: 30.63 ns
27.57 ns
(99.05%)
61.26 ns
(45.43%)
📈 view plot
🚷 view threshold
35,658,727.42 ops/s
(+6.83%)Baseline: 33,379,784.97 ops/s
0.00 ops/s
(0.00%)
36,717,763.46 ops/s
(97.12%)
hello-world📈 view plot
🚷 view threshold
58.28 ns
(+1.55%)Baseline: 57.39 ns
51.65 ns
(88.63%)
114.78 ns
(50.77%)
📈 view plot
🚷 view threshold
17,193,747.26 ops/s
(-1.12%)Baseline: 17,389,221.97 ops/s
0.00 ops/s
(0.00%)
19,128,144.16 ops/s
(89.89%)
manually-exported-noop📈 view plot
🚷 view threshold
27.85 ns
(-1.95%)Baseline: 28.40 ns
25.56 ns
(91.79%)
56.80 ns
(49.03%)
📈 view plot
🚷 view threshold
35,916,651.55 ops/s
(+2.17%)Baseline: 35,155,384.45 ops/s
0.00 ops/s
(0.00%)
38,670,922.90 ops/s
(92.88%)
🐰 View full continuous benchmarking report in Bencher

Copy link

codecov bot commented Jul 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.85%. Comparing base (da5b61d) to head (f25ac33).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1111      +/-   ##
==========================================
- Coverage   84.34%   82.85%   -1.50%     
==========================================
  Files          74       74              
  Lines        5578     4701     -877     
  Branches     5578     4701     -877     
==========================================
- Hits         4705     3895     -810     
+ Misses        767      713      -54     
+ Partials      106       93      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@dherman dherman left a comment

Choose a reason for hiding this comment

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

Just needs one comment, but otherwise 🚢

@kjvalencik kjvalencik merged commit 2335828 into main Jul 18, 2025
10 checks passed
@kjvalencik kjvalencik deleted the kv/lazylock branch July 18, 2025 18:50
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