Skip to content

perf: Improve pest AST parsing - #3235

Merged
aborgna-q merged 3 commits into
mainfrom
ab/bump-pest
Sep 3, 2026
Merged

perf: Improve pest AST parsing#3235
aborgna-q merged 3 commits into
mainfrom
ab/bump-pest

Conversation

@aborgna-q

@aborgna-q aborgna-q commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

#3212 tried to bump the pest version to 2.9.0 but 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, so 2.9.0 doesn'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.

@codspeed-hq

codspeed-hq Bot commented Sep 2, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by ×3.5

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 4 improved benchmarks
✅ 39 untouched benchmarks

Performance Changes

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)

Open in CodSpeed

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.63%. Comparing base (6230f00) to head (5aaa71a).
⚠️ Report is 1 commits behind head on main.

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           
Flag Coverage Δ
python 89.38% <ø> (ø)
rust 80.43% <ø> (ø)

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

☔ View full report in Codecov by Harness.
📢 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.

@aborgna-q
aborgna-q marked this pull request as ready for review September 2, 2026 16:02
@aborgna-q
aborgna-q requested a review from a team as a code owner September 2, 2026 16:02

@maximilianruesch maximilianruesch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?)

@aborgna-q

aborgna-q commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

The relevant pest fix is at pest#1184.
That change caused the big performance drop in our parser.

Now that the benchmarks ran with the pinned 2.8.8 version, the slowdowns are gone.

@aborgna-q
aborgna-q added this pull request to the merge queue Sep 3, 2026
Merged via the queue into main with commit b146d6c Sep 3, 2026
32 checks passed
@aborgna-q
aborgna-q deleted the ab/bump-pest branch September 3, 2026 08:09
github-merge-queue Bot pushed a commit that referenced this pull request Sep 4, 2026
## 🤖 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/).
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