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: Return Cow<Signature> where possible #1743

Merged
merged 2 commits into from
Dec 10, 2024
Merged

Conversation

aborgna-q
Copy link
Collaborator

@aborgna-q aborgna-q commented Dec 6, 2024

group                                    cows                                   serialization
-----                                    ----                                   -------------
circuit_roundtrip/capnp/0                1.02      5.3±0.52µs        ? ?/sec    1.00      5.2±0.09µs        ? ?/sec
circuit_roundtrip/capnp/1                1.00     12.5±0.74µs        ? ?/sec    1.14     14.2±0.16µs        ? ?/sec
circuit_roundtrip/capnp/10               1.00     25.9±0.39µs        ? ?/sec    1.31     34.0±0.30µs        ? ?/sec
circuit_roundtrip/capnp/100              1.00    155.8±2.01µs        ? ?/sec    1.47    229.6±2.46µs        ? ?/sec
circuit_roundtrip/capnp/1000             1.00  1483.7±64.06µs        ? ?/sec    1.43      2.1±0.04ms        ? ?/sec
circuit_roundtrip/capnp/10000            1.00     15.9±0.26ms        ? ?/sec    1.49     23.7±1.67ms        ? ?/sec
circuit_roundtrip/capnp/100000           1.00    192.8±2.26ms        ? ?/sec    1.37    264.3±5.44ms        ? ?/sec
circuit_roundtrip/capnp/200000           1.00    411.5±4.77ms        ? ?/sec    1.36   560.4±15.52ms        ? ?/sec
circuit_roundtrip/capnp/300000           1.00    648.9±5.40ms        ? ?/sec    1.34   871.5±10.63ms        ? ?/sec
circuit_roundtrip/json/0                 1.00      8.0±0.18µs        ? ?/sec    1.00      8.0±0.14µs        ? ?/sec
circuit_roundtrip/json/1                 1.00     19.0±0.27µs        ? ?/sec    1.16     22.1±0.33µs        ? ?/sec
circuit_roundtrip/json/10                1.00     50.0±0.68µs        ? ?/sec    1.26     63.0±0.94µs        ? ?/sec
circuit_roundtrip/json/100               1.00    342.5±4.81µs        ? ?/sec    1.30    446.4±4.61µs        ? ?/sec
circuit_roundtrip/json/1000              1.00      3.4±0.03ms        ? ?/sec    1.31      4.5±0.35ms        ? ?/sec
circuit_roundtrip/json/10000             1.00     37.2±0.73ms        ? ?/sec    1.28     47.5±0.45ms        ? ?/sec
circuit_roundtrip/json/100000            1.00    399.3±8.46ms        ? ?/sec    1.27   507.7±16.13ms        ? ?/sec
circuit_roundtrip/json/1000000           1.00       4.5±0.26s        ? ?/sec    1.20       5.4±0.06s        ? ?/sec

Closes #1741

@aborgna-q aborgna-q requested a review from a team as a code owner December 6, 2024 09:04
@aborgna-q aborgna-q requested a review from tatiana-s December 6, 2024 09:04
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 93.54839% with 8 lines in your changes missing coverage. Please review.

Project coverage is 86.28%. Comparing base (f2215e9) to head (a9732c6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
hugr-core/src/ops/constant.rs 40.00% 3 Missing ⚠️
hugr-core/src/extension/resolution/ops.rs 0.00% 2 Missing ⚠️
hugr-core/src/hugr/rewrite/replace.rs 0.00% 2 Missing ⚠️
hugr-core/src/package.rs 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1743      +/-   ##
==========================================
+ Coverage   86.27%   86.28%   +0.01%     
==========================================
  Files         179      179              
  Lines       32476    32513      +37     
  Branches    29388    29425      +37     
==========================================
+ Hits        28018    28054      +36     
- Misses       2758     2759       +1     
  Partials     1700     1700              
Flag Coverage Δ
python 92.42% <ø> (ø)
rust 85.64% <93.54%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@acl-cqc acl-cqc left a comment

Choose a reason for hiding this comment

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

Big +1 to this, although I have not looked in detail.

Should we consider returning a Signature struct that contains Cow<TypeRow>, Cow<TypeRow>, Cow<ExtensionSet>....?

@aborgna-q
Copy link
Collaborator Author

There's another discussion on what to do about type_rows, but yes we should do some sharing at some point.

This was just a really low hanging fruit for optimisation.

@aborgna-q
Copy link
Collaborator Author

I had to add a small workaround for #1758, since now we actually check the extension_reqs that come from the serialized hugr.

I'll fix it in another PR

@aborgna-q aborgna-q force-pushed the ab/optype-signature-cow branch from 2a03217 to a9732c6 Compare December 10, 2024 15:19
@aborgna-q aborgna-q changed the title perf!: Return Cow<Signature> where possible perf: Return Cow<Signature> where possible Dec 10, 2024
@aborgna-q aborgna-q added this pull request to the merge queue Dec 10, 2024
Merged via the queue into main with commit 7a49f05 Dec 10, 2024
24 of 26 checks passed
@aborgna-q aborgna-q deleted the ab/optype-signature-cow branch December 10, 2024 15:29
This was referenced Dec 10, 2024
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.

OpTrait::dataflow_signature should return a Cow
3 participants