8000 fix(query): pre-compile regex patterns at parse time (issue #36) by adityamukho · Pull Request #67 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

fix(query): pre-compile regex patterns at parse time (issue #36) - #67

Merged
adityamukho merged 1 commit into
mainfrom
fix/issue-36-regex-precompile
Apr 3, 2026
Merged

adityamukho merged 1 commit into
mainfrom
fix/issue-36-regex-precompile

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Summary

  • Pre-compile regex patterns at parse time instead of on every match evaluation
  • Modified BinOp::Matches to hold a pre-compiled regex_lite::Regex + pattern string for equality/hashing
  • Updated parser to compile regex early (after validation) in parse_expr
  • Updated executor to use the pre-compiled regex directly in eval_binop

This fixes the performance issue where regex was being compiled for every binding evaluation during query execution.

Issue: regex was compiled on every match evaluation in executor.rs
- Modified BinOp::Matches to hold pre-compiled regex + pattern string
- Updated parser to compile regex at parse time (after validation)
- Updated executor to use pre-compiled regex directly
- Added manual PartialEq/Eq/Hash impls for BinOp (regex doesn't impl these)
@adityamukho
adityamukho merged commit 11ebb1f into main Apr 3, 2026
10 checks passed
@adityamukho
adityamukho deleted the fix/issue-36-regex-precompile branch April 3, 2026 03:11
@codecov
codecov Bot commented Apr 3, 2026
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.25926% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.21%. Comparing base (89464f8) to head (edfee4a).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/query/datalog/types.rs 0.00% 10 Missing ⚠️
src/query/datalog/parser.rs 93.33% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (59.25%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #67      +/-   ##
==========================================
- Coverage   84.38%   84.21%   -0.18%     
==========================================
  Files          25       25              
  Lines        4374     4390      +16     
==========================================
+ Hits         3691     3697       +6     
- Misses        683      693      +10     
Files with missing lines Coverage Δ
src/query/datalog/executor.rs 93.21% <100.00%> (-0.03%) ⬇️
src/query/datalog/parser.rs 85.98% <93.33%> (+0.14%) ⬆️
src/query/datalog/types.rs 87.50% <0.00%> (-6.53%) ⬇️
🚀 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.

1 participant

0