Skip to content

refactor: do tracing during checking - #2104

Draft
acl-cqc wants to merge 41 commits into
mainfrom
acl/tracing_refactor
Draft

refactor: do tracing during checking#2104
acl-cqc wants to merge 41 commits into
mainfrom
acl/tracing_refactor

Conversation

@acl-cqc

@acl-cqc acl-cqc commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Big step towards #1592, but perhaps not a total solution - at the least, I expect/hope this to enable more cleanups, but perhaps they could follow in later PRs....

The "99%" performance degradation is for a benchmark that just calls check() so since this now executes the user's python code (whereas it didn't before)....that's expected. (Albeit 😆 🤣 )

acl-cqc added 30 commits July 8, 2026 14:48
add abstractproperty CompiledCallableDef.call_effects, some breaks + typeignore
modifier_compiler: grab effects out of FunctionBuilder (via private field)
WIP what LocalCalls are there
add effects= to hugr_op, order QAlloc/QFree - fixes test_array.py::test_take_put
#: Reference to the global compilation context.
ctx: CompilerContext
#: Context used to translate Guppy types into HUGR types.
ctx: ToHugrContext

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We might wanna get rid of this first; None implements ToHugrContext 😆

TraceableCall: TypeAlias = GlobalCall | AbortExpr | StateOutputExpr


@dataclass(frozen=True)

@acl-cqc acl-cqc Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, so a bunch of these dataclasses were written by AI...I have tidied them up a bit (and fixed its TraceCall which was totally wrong ;-) )...I think they are correct now!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moreover, these might be better in a separate tracing/builder.py; I did start off with that and had circular-import problems but these could be solved (just, all the four methods in TraceBuilder will have to locally import from state.py)

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectguppylang
Branchacl/tracing_refactor
TestbedLinux
Click to view all benchmark results
Benchmarkhugr_bytesBenchmark Result
bytes x 1e3
(Result Δ%)
Upper Boundary
bytes x 1e3
(Limit %)
hugr_nodesBenchmark Result
nodes
(Result Δ%)
Upper Boundary
nodes
(Limit %)
tests/benchmarks/test_big_array.py::test_big_array_compile📈 view plot
🚷 view threshold
66.41 x 1e3
(0.00%)Baseline: 66.41 x 1e3
67.07 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
4,595.00
(0.00%)Baseline: 4,595.00
4,640.95
(99.01%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile📈 view plot
🚷 view threshold
28.78 x 1e3
(0.00%)Baseline: 28.78 x 1e3
29.06 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
1,301.00
(0.00%)Baseline: 1,301.00
1,314.01
(99.01%)
tests/benchmarks/test_queue_push_pop.py::test_queue_push_benchmark_compile📈 view plot
🚷 view threshold
7.84 x 1e3
(0.00%)Baseline: 7.84 x 1e3
7.92 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
310.00
(0.00%)Baseline: 310.00
313.10
(99.01%)
tests/benchmarks/test_queue_push_pop.py::test_queue_push_pop_benchmark_compile📈 view plot
🚷 view threshold
10.77 x 1e3
(0.00%)Baseline: 10.77 x 1e3
10.88 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
411.00
(0.00%)Baseline: 411.00
415.11
(99.01%)
🐰 View full continuous benchmarking report in Bencher

returns = self.compile_abort(node)
return self._pack_returns(returns, get_type(node))

def compile_abort(self, node: AbortExpr) -> list[Wire]:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These helpers are a bit ugly....could do with a neater way

@codecov-commenter

codecov-commenter commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.87179% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.28%. Comparing base (47205e9) to head (6e8d926).

Files with missing lines Patch % Lines
...rnals/src/guppylang_internals/definition/traced.py 85.24% 9 Missing ⚠️
...nternals/src/guppylang_internals/tracing/object.py 95.00% 1 Missing ⚠️
...internals/src/guppylang_internals/tracing/state.py 98.71% 1 Missing ⚠️
...rnals/src/guppylang_internals/tracing/unpacking.py 95.65% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2104      +/-   ##
==========================================
+ Coverage   93.27%   93.28%   +0.01%     
==========================================
  Files         154      154              
  Lines       14807    14966     +159     
==========================================
+ Hits        13811    13961     +150     
- Misses        996     1005       +9     

☔ 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.

@codspeed-hq

codspeed-hq Bot commented Jul 28, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 99.14%

❌ 1 regressed benchmark
✅ 10 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
test_circuit_comptime_check 3.7 ms 429.1 ms -99.14%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing acl/tracing_refactor (6e8d926) with main (47205e9)

Open in CodSpeed

@acl-cqc
acl-cqc requested a review from mark-koch July 28, 2026 16:28
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