Skip to content

feat: analyse callgraph to infer effects (and reduce order edges)#2035

Draft
acl-cqc wants to merge 13 commits into
acl/order_by_effectsfrom
acl/callgraph
Draft

feat: analyse callgraph to infer effects (and reduce order edges)#2035
acl-cqc wants to merge 13 commits into
acl/order_by_effectsfrom
acl/callgraph

Conversation

@acl-cqc

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

Copy link
Copy Markdown
Contributor

follows #2024, includes cherry-pick of #2034.
closes #1748.

check_call and synthesize_call take an extra parameter that identifies the callee (and the caller is in the Context), this is then added to the callgraph inside the ENGINE. After checking is finished, we process that to calculate effects and put that in the CompilerContext.

There are quite a few places where we have to fall back to using [Effect.ANY], which I guess is much where we are before the PR, but it's not clear how to move them forward; e.g. nested functions.

Tracing is a serious issue; IIUC we have done callgraph analysis before we do any tracing. We should probably rerun it - after every new function/instantiation is checked by tracing, and before the traced function calls it - but how? The big tracing refactor seems like a good solution...

Also needs some more refactoring, there's a lot of instanceof - I think adding a def effects to CallableDef (not just CompiledCallableDef) would help, will do that shortly.

@acl-cqc acl-cqc changed the base branch from main to acl/order_by_effects July 10, 2026 18:56
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchacl/callgraph
TestbedLinux

🚨 1 Alert

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
tests/benchmarks/test_big_array.py::test_big_array_compilehugr_bytes
bytes x 1e3
📈 plot
🚷 threshold
🚨 alert (🔔)
148.89 x 1e3
(+23.39%)Baseline: 120.67 x 1e3
121.87 x 1e3
(122.16%)

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
🚨 view alert (🔔)
148.89 x 1e3
(+23.39%)Baseline: 120.67 x 1e3
121.87 x 1e3
(122.16%)

📈 view plot
🚷 view threshold
5,659.00
(0.00%)Baseline: 5,659.00
5,715.59
(99.01%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile📈 view plot
🚷 view threshold
35.52 x 1e3
(-1.85%)Baseline: 36.19 x 1e3
36.55 x 1e3
(97.17%)
📈 view plot
🚷 view threshold
1,582.00
(0.00%)Baseline: 1,582.00
1,597.82
(99.01%)
tests/benchmarks/test_queue_push_pop.py::test_queue_push_benchmark_compile📈 view plot
🚷 view threshold
9.76 x 1e3
(-1.91%)Baseline: 9.95 x 1e3
10.05 x 1e3
(97.12%)
📈 view plot
🚷 view threshold
347.00
(0.00%)Baseline: 347.00
350.47
(99.01%)
tests/benchmarks/test_queue_push_pop.py::test_queue_push_pop_benchmark_compile📈 view plot
🚷 view threshold
13.71 x 1e3
(-2.78%)Baseline: 14.11 x 1e3
14.25 x 1e3
(96.26%)
📈 view plot
🚷 view threshold
470.00
(0.00%)Baseline: 470.00
474.70
(99.01%)
🐰 View full continuous benchmarking report in Bencher

@codecov-commenter

codecov-commenter commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.06349% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.10%. Comparing base (6b66fd4) to head (f9d5e56).

Files with missing lines Patch % Lines
...ls/src/guppylang_internals/checker/expr_checker.py 76.47% 8 Missing ⚠️
...src/guppylang_internals/checker/effects_checker.py 97.77% 1 Missing ⚠️
...s/src/guppylang_internals/std/_internal/checker.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##           acl/order_by_effects    #2035      +/-   ##
========================================================
+ Coverage                 93.06%   93.10%   +0.03%     
========================================================
  Files                       154      155       +1     
  Lines                     14749    14833      +84     
========================================================
+ Hits                      13726    13810      +84     
  Misses                     1023     1023              

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

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.

Build callgraph of guppy functions, use to calculate effects of unannotated funcs

2 participants