Skip to content

rust: Convert cheap debug_asserts into soft_asserts - #38172

Open
def- wants to merge 1 commit into
MaterializeInc:mainfrom
def-:pr-soft-assert
Open

rust: Convert cheap debug_asserts into soft_asserts#38172
def- wants to merge 1 commit into
MaterializeInc:mainfrom
def-:pr-soft-assert

Conversation

@def-

@def- def- commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

debug asserts are only available in cargo test, soft asserts are also enabled in our e2e tests in CI

Nightly run: https://buildkite.com/materialize/nightly/builds/18058 (failures are unrelated and just fixed on main)

@def-
def- marked this pull request as ready for review August 12, 2026 08:51
@def-
def- requested review from a team, aljoscha and sjwiesman as code owners August 12, 2026 08:51

@antiguru antiguru left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems fine. Not all asserts are free, but if measurements don't turn up any regression I'm OK with accepting them.

impl Ord for Top1Monoid {
fn cmp(&self, other: &Self) -> Ordering {
debug_assert_eq!(self.order_key, other.order_key);
mz_ore::soft_assert_eq_no_log!(self.order_key, other.order_key);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Potentially expensive, but as we're allocating two vectors just next, I don't mind this cost.

/// (time, data)-order, to ensure the chain remains sorted.
fn push_chunk(&mut self, chunk: Chunk<D>) {
debug_assert!(self.can_accept_chunk(&chunk));
mz_ore::soft_assert_no_log!(self.can_accept_chunk(&chunk));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Potentially expensive, and checks a precondition. Accept.

Comment thread src/persist-client/src/internal/machine.rs Outdated
Comment thread src/persist-client/src/internal/state.rs Outdated
Comment thread src/persist/src/file.rs Outdated
Comment thread src/storage-types/src/errors.rs Outdated
Comment thread src/timely-util/src/columnar/chunk.rs Outdated
Comment thread src/timely-util/src/columnar/chunk.rs Outdated
Comment thread src/timely-util/src/columnar/chunk.rs
@def-

def- commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Not all asserts are free, but if measurements don't turn up any regression I'm OK with accepting them.

Benchmarks in CI run with soft assertions off, so the overhead for them should just be a quick check of whether soft assertions are on, not the actual assertion body.

@def-
def- force-pushed the pr-soft-assert branch 2 times, most recently from 5170dba to 688eb3b Compare August 12, 2026 12:39
@def-

def- commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

I'll wait a day before merging in case anyone wants to veto.

debug asserts are only available in cargo test, soft asserts are also
enabled in our e2e tests in CI
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.

2 participants