Skip to content

Comments

Assert that there are no more projection pushdown opportunities at the end of the MIR pipeline, according to Demand#31808

Open
ggevay wants to merge 1 commit intoMaterializeInc:mainfrom
ggevay:assert-demand
Open

Assert that there are no more projection pushdown opportunities at the end of the MIR pipeline, according to Demand#31808
ggevay wants to merge 1 commit intoMaterializeInc:mainfrom
ggevay:assert-demand

Conversation

@ggevay
Copy link
Contributor

@ggevay ggevay commented Mar 9, 2025

This PR adds a check for an optimizer invariant: There should be no more projection pushdown opportunities at the end of the MIR pipeline, according to Demand.

Compared to what we discussed on Friday with @frankmcsherry and @mgree, the only change is that we skip checking the invariant when there is an ArrangeBy on top of a global Get, because a projection might have been lifted away by JoinImplementation to re-use an index.

The first commits are from #31791

Motivation

  • This PR adds a soft assert.

Tips for reviewer

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

@ggevay ggevay requested review from frankmcsherry and mgree March 9, 2025 18:56
@ggevay ggevay requested review from a team as code owners March 9, 2025 18:56
@ggevay ggevay requested a review from aljoscha March 9, 2025 18:56
@ggevay ggevay added the A-CLUSTER Topics related to the CLUSTER layer label Mar 9, 2025
Copy link
Contributor

@mgree mgree left a comment

Choose a reason for hiding this comment

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

Fundamentally okay by me, but see my comment. Is the plan to merge just this and drop #31791.

This feature flag boilerplate is a little much---very redundant changes across 6 files. If feature flags are the way forward for now, we'll likely want to find a nicer way to manage the flagging.

MirRelationExpr::Get { id: Id::Global(id), .. } => {
let demand = demand_on_ids.get(&Id::Global(*id)).expect("`Demand` should have an opinion on all ids");
let actual_proj_above_get = mfp.projection.iter().filter(|c| **c < mfp.input_arity).collect_vec();
soft_assert_or_log!(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should relation.pretty() and expr.pretty() and mfp be redacted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!

  • pretty already redacts in prod: pretty calls ExplainConfig::default(), which has
    redacted: !mz_ore::assert::soft_assertions_enabled().
  • Display for MapFilterProject unfortunately doesn't redact, and would be hard to make it do so properly. But since Display for MapFilterProject is only used in debugging code, I've now tweaked it to just omit the whole MFP if !soft_assertions_enabled().

@ggevay
Copy link
Contributor Author

ggevay commented Mar 13, 2025

Thanks for the review!

Is the plan to merge just this and drop #31791.

No, I will merge that one first, then rebase on main, and then merge this one. (I'm currently fighting it out with Nightly over there.) Edit: Merged that one.

This feature flag boilerplate is a little much---very redundant changes across 6 files. If feature flags are the way forward for now, we'll likely want to find a nicer way to manage the flagging.

Yeah, we could look into this.

@ggevay
Copy link
Contributor Author

ggevay commented Mar 14, 2025

Ran Nightly, and the assert is firing in both RQG and full slt! I'll get back to this a bit later.

@mgree
Copy link
Contributor

mgree commented Mar 18, 2025

This feature flag boilerplate is a little much---very redundant changes across 6 files. If feature flags are the way forward for now, we'll likely want to find a nicer way to manage the flagging.

Yeah, we could look into this.

Made an issue: https://github.com/MaterializeInc/database-issues/issues/9099. Good luck with the RQG 🫣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLUSTER Topics related to the CLUSTER layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants