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

Update RCA for mutable Result, array, and tuple variables #1571

Merged
merged 5 commits into from
May 29, 2024

Conversation

swernli
Copy link
Collaborator

@swernli swernli commented May 24, 2024

This change strengthens RCA checks around use of mutable Result, array, and tuple variables in a dynamic context to make them consistent with how we verify the use of other dynamic value types like Int and Double. This gives users compile time feedback when updating a mutable value in a dynamic context will not produce QIR, rather than a codegen failure with an unexpected error occurred related to: re-assignment within a dynamic branch is unsupported for type <type> error.

This change strengthens RCA checks around use of mutable `Result`, array, and tuple variables in a dynamic context to make them consistent with how we verify the use of other dynamic value types like `Int` and `Double`. This gives users compile time feedback when updating a mutable value in a dynamic context will not produce QIR, rather than a codegen failure with `an unexpected error occurred related to: re-assignment within a dynamic branch is unsupported for type <type>` error.
Copy link

Benchmark for c10e886

Click to view benchmark
Test Base PR %
Array append evaluation 330.0±3.47µs 329.9±3.23µs -0.03%
Array literal evaluation 179.8±4.49µs 171.1±7.34µs -4.84%
Array update evaluation 411.9±3.28µs 413.8±9.02µs +0.46%
Core + Standard library compilation 18.5±0.32ms 18.6±0.26ms +0.54%
Deutsch-Jozsa evaluation 5.2±0.12ms 5.1±0.14ms -1.92%
Large file parity evaluation 34.1±0.06ms 33.9±0.49ms -0.59%
Large input file compilation 12.5±0.30ms 12.4±0.14ms -0.80%
Large input file compilation (interpreter) 45.7±0.54ms 48.3±1.39ms +5.69%
Large nested iteration 32.3±0.12ms 32.6±1.05ms +0.93%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1565.0±32.78µs 1558.1±29.84µs -0.44%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.09ms 7.9±0.16ms +1.28%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1428.8±33.93µs 1419.1±25.39µs -0.68%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.4±0.80ms 27.9±0.17ms -1.76%
Teleport evaluation 90.9±3.60µs 87.9±3.66µs -3.30%

Copy link

Benchmark for b2acc95

Click to view benchmark
Test Base PR %
Array append evaluation 337.1±3.85µs 340.8±10.95µs +1.10%
Array literal evaluation 180.3±1.11µs 171.0±1.81µs -5.16%
Array update evaluation 417.0±2.32µs 420.8±14.27µs +0.91%
Core + Standard library compilation 19.1±0.55ms 18.9±0.65ms -1.05%
Deutsch-Jozsa evaluation 5.2±0.07ms 5.2±0.30ms 0.00%
Large file parity evaluation 34.2±0.12ms 33.9±0.07ms -0.88%
Large input file compilation 13.2±0.59ms 13.1±0.57ms -0.76%
Large input file compilation (interpreter) 47.8±1.51ms 49.2±1.87ms +2.93%
Large nested iteration 32.8±0.96ms 32.9±0.15ms +0.30%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1587.3±113.44µs 1568.8±59.29µs -1.17%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.9±0.13ms 7.8±0.15ms -1.27%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1422.9±36.92µs 1422.5±37.02µs -0.03%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.7±0.29ms 28.6±0.34ms -0.35%
Teleport evaluation 90.4±4.37µs 90.6±4.19µs +0.22%

compiler/qsc_rca/src/core.rs Outdated Show resolved Hide resolved
Copy link

Benchmark for 0da1cce

Click to view benchmark
Test Base PR %
Array append evaluation 332.4±2.20µs 329.4±6.13µs -0.90%
Array literal evaluation 190.1±2.20µs 170.6±1.27µs -10.26%
Array update evaluation 415.0±2.08µs 409.4±3.82µs -1.35%
Core + Standard library compilation 19.3±1.43ms 23.0±2.85ms +19.17%
Deutsch-Jozsa evaluation 5.2±0.06ms 5.2±0.08ms 0.00%
Large file parity evaluation 34.2±0.12ms 33.9±0.41ms -0.88%
Large input file compilation 14.2±1.29ms 14.2±1.35ms 0.00%
Large input file compilation (interpreter) 47.9±2.31ms 50.2±3.67ms +4.80%
Large nested iteration 32.7±0.16ms 32.5±0.15ms -0.61%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1601.5±91.37µs 1629.0±251.81µs +1.72%
Perform Runtime Capabilities Analysis (RCA) on large file sample 8.4±0.47ms 8.0±0.30ms -4.76%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1442.0±85.28µs 1450.7±97.11µs +0.60%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.7±0.58ms 29.0±0.61ms +1.05%
Teleport evaluation 91.8±4.05µs 91.3±3.57µs -0.54%

Copy link

Benchmark for 84dae98

Click to view benchmark
Test Base PR %
Array append evaluation 332.3±3.21µs 330.2±5.46µs -0.63%
Array literal evaluation 192.8±1.98µs 170.5±1.05µs -11.57%
Array update evaluation 413.8±2.62µs 410.7±6.39µs -0.75%
Core + Standard library compilation 19.8±1.01ms 18.7±0.34ms -5.56%
Deutsch-Jozsa evaluation 5.2±0.06ms 5.2±0.05ms 0.00%
Large file parity evaluation 34.2±0.12ms 34.0±0.71ms -0.58%
Large input file compilation 13.1±0.68ms 12.5±0.27ms -4.58%
Large input file compilation (interpreter) 51.5±2.25ms 48.3±1.32ms -6.21%
Large nested iteration 32.8±0.17ms 32.9±1.53ms +0.30%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1563.0±49.62µs 1567.7±47.25µs +0.30%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.9±0.33ms 7.7±0.09ms -2.53%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1432.5±78.87µs 1426.4±30.36µs -0.43%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.8±0.95ms 28.5±1.01ms -1.04%
Teleport evaluation 90.8±4.30µs 91.5±4.72µs +0.77%

@swernli swernli added this pull request to the merge queue May 29, 2024
Merged via the queue into main with commit cc88c80 May 29, 2024
16 checks passed
@swernli swernli deleted the swernli/rca-result-array-updates branch May 29, 2024 23:10
swernli added a commit that referenced this pull request Jun 3, 2024
This fixes a panic that was introduced in #1571, where if the content being used to update an array was a dynamic, non-array value it would panic when trying to aggreate a default array type into a element type. To make sure the update matches the chosen type, generate the `ValueKind` from the matching expression type. Added unit tests for both array and non-array dynamic update types.
github-merge-queue bot pushed a commit that referenced this pull request Jun 3, 2024
This fixes a panic that was introduced in #1571, where if the content
being used to update an array was a dynamic, non-array value it would
panic when trying to aggreate a default array type into a element type.
To make sure the update matches the chosen type, generate the
`ValueKind` from the matching expression type. Added unit tests for both
array and non-array dynamic update types.
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

3 participants