perf: Improve pest AST parsing - #3235
Conversation
Merging this PR will improve performance by ×3.5
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | serialization/big_hugr/1048576/sexpr/without_extensions/decode |
256.7 ms | 28.6 ms | ×9 |
| ⚡ | serialization/big_hugr/1048576/sexpr/with_extensions/decode |
256.8 ms | 28.7 ms | ×8.9 |
| ⚡ | serialization/big_hugr/1024/sexpr/without_extensions/decode |
738.5 µs | 513.6 µs | +43.79% |
| ⚡ | serialization/big_hugr/1024/sexpr/with_extensions/decode |
845.9 µs | 619.4 µs | +36.55% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing ab/bump-pest (5aaa71a) with main (cb9a6a1)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3235 +/- ##
=======================================
Coverage 81.63% 81.63%
=======================================
Files 242 242
Lines 47659 47659
Branches 41252 41252
=======================================
Hits 38906 38906
Misses 6729 6729
Partials 2024 2024
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
maximilianruesch
left a comment
There was a problem hiding this comment.
Approved assuming our own CI performance warning goes away.
Is there some issue from pest you can link here? (maybe via invisible link so that it does not show up in the pest repo?)
|
The relevant pest fix is at pest#1184. Now that the benchmarks ran with the pinned |
## 🤖 New release * `hugr-model`: 0.30.1 -> 0.30.2 * `hugr-core`: 0.30.1 -> 0.30.2 (✓ API compatible changes) * `hugr-llvm`: 0.30.1 -> 0.30.2 * `hugr`: 0.30.1 -> 0.30.2 (✓ API compatible changes) * `hugr-cli`: 0.30.1 -> 0.30.2 * `hugr-persistent`: 0.7.10 -> 0.7.11 <details><summary><i><b>Changelog</b></i></summary><p> ## `hugr-model` <blockquote> ## [0.30.0](hugr-model-v0.29.4...hugr-model-v0.30.0) - 2026-09-03 ### New Features - *(hugr-model)* Allow parsing literals as constants ([#3230](#3230)) ### Performance - Improve `pest` AST parsing ([#3235](#3235)) </blockquote> ## `hugr-core` <blockquote> ## [0.30.2](hugr-core-v0.30.1...hugr-core-v0.30.2) - 2026-09-04 ### New Features - Improve extension resolution errors ([#3247](#3247)) </blockquote> ## `hugr-llvm` <blockquote> ## [0.30.0](hugr-llvm-v0.29.4...hugr-llvm-v0.30.0) - 2026-09-03 ### Performance - [**breaking**] Reuse shared `Type`s during HUGR import ([#3215](#3215)) ### Refactor - [**breaking**] Remove deprecated definitions ([#3232](#3232)) </blockquote> ## `hugr` <blockquote> ## [0.30.2](hugr-v0.30.1...hugr-v0.30.2) - 2026-09-04 ### New Features - Improve extension resolution errors ([#3247](#3247)) </blockquote> ## `hugr-cli` <blockquote> ## [0.30.0](hugr-cli-v0.29.4...hugr-cli-v0.30.0) - 2026-09-03 ### New Features - *(cli)* Include edge counts in `describe` output ([#3209](#3209)) - [**breaking**] Read the extension version as optional in `ExtensionDesc` metadata ([#3231](#3231)) </blockquote> ## `hugr-persistent` <blockquote> ## [0.7.0](hugr-persistent-v0.6.1...hugr-persistent-v0.7.0) - 2026-06-05 ### New Features - [**breaking**] do not require an Order edge for each nonlocal `Ext` edge; compute on demand in scheduling_graph() ([#2951](#2951)) - *(hugr-llvm)* [**breaking**] Add support for emitting debug locations ([#3026](#3026)) - [**breaking**] Add extension versions to hugr-model elements ([#3080](#3080)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/).
#3212 tried to bump the
pestversion to2.9.0but found out that a soundness fix in it produced a 15-25% slowdown on sexpr decoding.This PR pins the pest version to
=2.8.8, so2.9.0doesn't get used for now.While looking into that problem, I found out that a slight semantic-preserving change in the grammar may speed up things, so it's included here.