Skip to content

refactor!!: make scope traversal significantly faster#7196

Merged
tobymao merged 1 commit intomainfrom
toby/scope
Mar 4, 2026
Merged

refactor!!: make scope traversal significantly faster#7196
tobymao merged 1 commit intomainfrom
toby/scope

Conversation

@tobymao
Copy link
Owner

@tobymao tobymao commented Mar 4, 2026

mypyc has an issue with the nested generators, so inlining a DFS search gives signifcant gains

┌──────────────────────────────────────┬─────────────────┬─────────────────┐
│ Version │ median │ best │
├──────────────────────────────────────┼─────────────────┼─────────────────┤
│ Unrolled walk_in_scope │ 1.381ms (1.84x) │ 1.376ms (1.65x) │
├──────────────────────────────────────┼─────────────────┼─────────────────┤
│ expression.walk() delegation (tuple) │ 2.333ms (1.09x) │ 1.847ms (1.23x) │
├──────────────────────────────────────┼─────────────────┼─────────────────┤
│ Baseline (8db0323) │ 2.550ms │ 2.271ms │
└──────────────────────────────────────┴─────────────────┴─────────────────┘

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

SQLGlot Integration Test Results

Comparing:

  • this branch (sqlglot:toby/scope, sqlglot version: toby/scope)
  • baseline (main, sqlglot version: 29.0.2.dev29)

⚠️ Limited to dialects: duckdb, snowflake

By Dialect

dialect main sqlglot:toby/scope transitions links
duckdb -> duckdb 4003/4003 passed (100.0%) 4003/4003 passed (100.0%) No change full result / delta
snowflake -> duckdb 1589/2596 passed (61.2%) 1599/2596 passed (61.6%) 10 fail -> pass full result / delta
snowflake -> snowflake 2817/2817 passed (100.0%) 2817/2817 passed (100.0%) No change full result / delta

Overall

main: 9416 total, 8409 passed (pass rate: 89.3%), sqlglot version: 29.0.2.dev29

sqlglot:toby/scope: 9416 total, 8419 passed (pass rate: 89.4%), sqlglot version: toby/scope

Transitions:
10 fail -> pass

Copy link
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

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

Great!

mypyc has an issue with the nested generators, so inlining a DFS search gives signifcant gains

┌──────────────────────────────────────┬─────────────────┬─────────────────┐
│               Version                │     median      │      best       │
├──────────────────────────────────────┼─────────────────┼─────────────────┤
│ Unrolled walk_in_scope               │ 1.381ms (1.84x) │ 1.376ms (1.65x) │
├──────────────────────────────────────┼─────────────────┼─────────────────┤
│ expression.walk() delegation (tuple) │ 2.333ms (1.09x) │ 1.847ms (1.23x) │
├──────────────────────────────────────┼─────────────────┼─────────────────┤
│ Baseline (8db0323)                  │ 2.550ms         │ 2.271ms         │
└──────────────────────────────────────┴─────────────────┴─────────────────┘
@tobymao tobymao merged commit ac2ed90 into main Mar 4, 2026
9 checks passed
@tobymao tobymao deleted the toby/scope branch March 4, 2026 16:11
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.

3 participants