Add support for set_cost action to have row level costs for extraction#343
Merged
saulshanabrook merged 4 commits intomainfrom Sep 3, 2025
Merged
Add support for set_cost action to have row level costs for extraction#343saulshanabrook merged 4 commits intomainfrom
set_cost action to have row level costs for extraction#343saulshanabrook merged 4 commits intomainfrom
Conversation
This re-implements the syntactic macro in the egglog experimental to create a new table for each function to store its cost. It re-uses the custom extractor which looks up in this table. I talked to @yihongz and we discussed different ways to implement this, from changing syntactic macros to take Expr instead of Sexpr, but settled on just having me re-implement the syntax.
Member
Author
|
@actions-user changelog |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for the set_cost action to enable row-level costs for extraction, implementing functionality similar to the egglog experimental feature. The implementation creates individual cost tables for each function and integrates with a custom extractor that looks up costs from these tables.
Key changes:
- Added
set_costaction to set custom costs for specific expressions - Implemented cost table creation and management for functions with custom costs
- Updated extraction logic to use custom extraction when cost tables are present
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| python/tests/test_high_level.py | Adds comprehensive test for dynamic cost functionality with expression costs and extraction validation |
| python/egglog/pretty.py | Updates pretty printing to handle SetCostDecl and adds support for displaying cost functions |
| python/egglog/examples/jointree.py | Provides example usage of set_cost in a join tree optimization scenario |
| python/egglog/egraph_state.py | Implements core cost table management, creation logic, and cost callable tracking |
| python/egglog/egraph.py | Adds set_cost function and modifies extraction to use custom extraction when cost tables exist |
| python/egglog/declarations.py | Defines SetCostDecl data structure for representing cost setting actions |
| docs/reference/egglog-translation.md | Documents the new set_cost feature with usage examples and implementation notes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
CodSpeed Instrumentation Performance ReportMerging #343 will not alter performanceComparing Summary
Footnotes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This re-implements the syntactic macro in the egglog experimental to create a new table for each function to store its cost. It re-uses the custom extractor which looks up in this table.
I talked to @yihongz and we discussed different ways to implement this, from changing syntactic macros to take Expr instead of Sexpr, but settled on just having me re-implement the syntax.
Closes #332