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

Custom Atom type to replace unsound API #377

Merged
merged 4 commits into from
Feb 9, 2024
Merged

Custom Atom type to replace unsound API #377

merged 4 commits into from
Feb 9, 2024

Conversation

Rigidity
Copy link
Contributor

@Rigidity Rigidity commented Feb 9, 2024

This PR changes the way a.atom(ptr) works to return an Atom type that can convert small integers to byte slices. This prevents a memory safety issue on the edge case where you exceed the temp vec length and references are left dangling.

Overall, the performance is actually improved slightly for the majority of benchmarks.

group                                                          after                                before
-----                                                          -------                                ------
deserialize/node_from_bytes                                    1.03    119.7±2.17µs        ? ?/sec    1.00    116.6±0.82µs        ? ?/sec
deserialize/node_from_bytes_backrefs                           1.00    141.8±4.51µs        ? ?/sec    1.19    168.8±1.96µs        ? ?/sec
deserialize/node_from_bytes_backrefs-compressed                1.00    144.6±4.76µs        ? ?/sec    1.00    144.5±7.68µs        ? ?/sec
deserialize/serialized_length_from_bytes                       1.03     98.8±2.57µs        ? ?/sec    1.00     95.9±1.70µs        ? ?/sec
deserialize/serialized_length_from_bytes-compressed            1.00    112.2±2.75µs        ? ?/sec    1.00    112.3±0.85µs        ? ?/sec
deserialize/serialized_length_from_bytes_trusted               1.03     27.2±0.99µs        ? ?/sec    1.00     26.5±0.05µs        ? ?/sec
deserialize/serialized_length_from_bytes_trusted-compressed    1.14     25.4±5.93µs        ? ?/sec    1.00     22.3±0.51µs        ? ?/sec
deserialize/tree_hash_from_stream                              1.02      2.0±0.02ms        ? ?/sec    1.00   1975.8±4.71µs        ? ?/sec
run_program/block-2000                                         1.01     99.1±1.26ns        ? ?/sec    1.00     98.2±0.39ns        ? ?/sec
run_program/compressed-2000                                    1.00    353.8±4.83ms        ? ?/sec    1.08    381.5±2.64ms        ? ?/sec
run_program/concat                                             1.00    262.1±2.85ms        ? ?/sec    1.00    261.1±1.98ms        ? ?/sec
run_program/count-even                                         1.00      5.6±0.04ms        ? ?/sec    1.05      5.9±0.01ms        ? ?/sec
run_program/factorial                                          1.00    106.5±0.05ms        ? ?/sec    1.01    107.2±0.31ms        ? ?/sec
run_program/hash-string                                        1.00    215.9±0.21ns        ? ?/sec    1.00    215.6±0.88ns        ? ?/sec
run_program/hash-tree                                          1.00     16.8±0.06ms        ? ?/sec    1.05     17.7±0.87ms        ? ?/sec
run_program/large-block                                        1.00     87.1±0.41ms        ? ?/sec    1.00     86.8±0.03ms        ? ?/sec
run_program/loop_add                                           1.00  1311.2±37.06ms        ? ?/sec    1.05   1380.9±3.58ms        ? ?/sec
run_program/loop_ior                                           1.00  1254.7±10.61ms        ? ?/sec    1.18   1482.9±3.57ms        ? ?/sec
run_program/loop_not                                           1.00  1283.7±10.03ms        ? ?/sec    1.07  1372.0±11.66ms        ? ?/sec
run_program/loop_sub                                           1.00  1403.8±29.64ms        ? ?/sec    1.03   1450.4±6.99ms        ? ?/sec
run_program/loop_xor                                           1.00  1372.0±18.20ms        ? ?/sec    1.06  1459.6±15.68ms        ? ?/sec
run_program/matrix-multiply                                    1.00     96.2±3.67ms        ? ?/sec    1.00     96.6±0.32ms        ? ?/sec
run_program/point-pow                                          1.00    135.9±0.56ms        ? ?/sec    1.00    136.3±1.38ms        ? ?/sec
run_program/pubkey-tree                                        1.00     73.5±0.47ms        ? ?/sec    1.01     74.1±0.88ms        ? ?/sec
run_program/shift-left                                         1.02   1067.5±6.91ms        ? ?/sec    1.00   1051.2±4.25ms        ? ?/sec
run_program/substr                                             1.00      2.9±0.03ms        ? ?/sec    1.09      3.2±0.02ms        ? ?/sec
run_program/substr-tree                                        1.00     64.3±1.46ms        ? ?/sec    1.05     67.4±0.42ms        ? ?/sec
run_program/sum-tree                                           1.00    142.7±1.79ms        ? ?/sec    1.05    150.1±1.01ms        ? ?/sec

@Rigidity Rigidity requested a review from arvidn February 9, 2024 04:03
Copy link

coveralls-official bot commented Feb 9, 2024

Pull Request Test Coverage Report for Build 7847070939

Warning: This coverage report may be inaccurate.

We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
To ensure accuracy in future PRs, please see these guidelines.
A quick fix for this PR: rebase it; your next report should be accurate.

  • -11 of 222 (95.05%) changed or added relevant lines in 13 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.1%) to 94.361%

Changes Missing Coverage Covered Lines Changed/Added Lines %
wasm/src/lazy_node.rs 0 1 0.0%
src/runtime_dialect.rs 0 3 0.0%
src/allocator.rs 135 142 95.07%
Files with Coverage Reduction New Missed Lines %
src/allocator.rs 2 98.37%
Totals Coverage Status
Change from base Build 7837886158: -0.1%
Covered Lines: 5756
Relevant Lines: 6100

💛 - Coveralls

Copy link
Contributor

@arvidn arvidn left a comment

Choose a reason for hiding this comment

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

looks good!

src/allocator.rs Show resolved Hide resolved
@Rigidity Rigidity marked this pull request as ready for review February 9, 2024 13:49
@Rigidity Rigidity requested a review from arvidn February 9, 2024 13:49
Copy link
Contributor

@arvidn arvidn left a comment

Choose a reason for hiding this comment

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

I have one comment that I think might be important to address

src/bls_ops.rs Outdated Show resolved Hide resolved
@Rigidity Rigidity merged commit 07e9213 into main Feb 9, 2024
27 checks passed
@Rigidity Rigidity deleted the node-conversions branch February 9, 2024 23:40
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.

None yet

2 participants