Skip to content

Conversation

@saulshanabrook
Copy link
Member

@saulshanabrook saulshanabrook commented Sep 3, 2025

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

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.
@saulshanabrook
Copy link
Member Author

@actions-user changelog

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_cost action 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.

@saulshanabrook saulshanabrook merged commit 5dc516e into main Sep 3, 2025
18 checks passed
@saulshanabrook saulshanabrook deleted the set-cost branch September 3, 2025 01:55
@codspeed-hq
Copy link

codspeed-hq bot commented Sep 3, 2025

CodSpeed Instrumentation Performance Report

Merging #343 will not alter performance

Comparing set-cost (2dd4fe1) with main (d3761d6)1

Summary

✅ 7 untouched benchmarks

Footnotes

  1. No successful run was found on main (2dd4fe1) during the generation of this report, so d3761d6 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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.

Feature request: with-dynamic-cost support

3 participants