Skip to content

chore: remove domain iteration macros and address backing memory race#20988

Merged
nishatkoti merged 4 commits intomerge-train/barretenbergfrom
nk/polynomials-pass-two
Mar 4, 2026
Merged

chore: remove domain iteration macros and address backing memory race#20988
nishatkoti merged 4 commits intomerge-train/barretenbergfrom
nk/polynomials-pass-two

Conversation

@nishatkoti
Copy link
Contributor

@nishatkoti nishatkoti commented Mar 2, 2026

  • Replace ITERATE_OVER_DOMAIN_START and ITERATE_OVER_DOMAIN_END macros with a parallel_for loop in ifft()
    • The macro was only used in ifft(). Replacing it with an inline loop makes the control flow clearer and allows removing the unused header.
  • Delete the now-unused iterate_over_domain.hpp
  • Address race condition in try_allocate_file_backed in backing_memory.hpp
  • Remove old improvement note in barycentric.hpp, as it is addressed in PR #20585

@nishatkoti nishatkoti changed the base branch from next to merge-train/barretenberg March 2, 2026 06:51
@nishatkoti nishatkoti marked this pull request as ready for review March 2, 2026 07:15
@nishatkoti nishatkoti requested a review from ledwards2225 March 2, 2026 09:17
Copy link
Contributor

@ledwards2225 ledwards2225 left a comment

Choose a reason for hiding this comment

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

LGTM - seems to me the updated alloc logic is safer but still has some minor flaws to be addressed before merging


// Check if we're under the storage budget
// Check and update storage usage to enforce budget
const size_t current_usage = current_storage_usage.fetch_add(required_bytes);
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree this is better than before but I think this still allows "false negatives" no? If multiple threads access this at once, they might see a current_storage_usage that is artificially inflated from a allocation that's ultimately rejected since we increment the value before checking if its valid.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe @johnathan79717 can weigh in here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A possible fix could be the following. Will wait for @johnathan79717 to take a look and confirm.

size_t current_usage = current_storage_usage.load();
while (true) {
    if (current_usage + required_bytes > storage_budget) {
        return false;
    }
    if (current_storage_usage.compare_exchange_weak(current_usage, current_usage + required_bytes)) {
        break;
    }
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry somehow missed the notification for this. Taking a look.

Copy link
Contributor

Choose a reason for hiding this comment

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

The while loop fix LGTM!

@nishatkoti nishatkoti force-pushed the nk/polynomials-pass-two branch from f7216ba to 9d632a4 Compare March 4, 2026 11:34
@nishatkoti nishatkoti force-pushed the nk/polynomials-pass-two branch from 9d632a4 to d5a5c8d Compare March 4, 2026 11:50
@nishatkoti nishatkoti merged commit c9ad84c into merge-train/barretenberg Mar 4, 2026
10 checks passed
@nishatkoti nishatkoti deleted the nk/polynomials-pass-two branch March 4, 2026 12:09
johnathan79717 pushed a commit that referenced this pull request Mar 4, 2026
…#20988)

- Replace `ITERATE_OVER_DOMAIN_START` and `ITERATE_OVER_DOMAIN_END`
macros with a `parallel_for` loop in `ifft()`
- The macro was only used in `ifft()`. Replacing it with an inline loop
makes the control flow clearer and allows removing the unused header.
- Delete the now-unused `iterate_over_domain.hpp`
- Address race condition in `try_allocate_file_backed` in
`backing_memory.hpp`
- Remove old improvement note in `barycentric.hpp`, as it is addressed
in PR
[#20585](#20585)
github-merge-queue bot pushed a commit that referenced this pull request Mar 6, 2026
BEGIN_COMMIT_OVERRIDE
fix: add -g0 to zig presets to eliminate 11GB debug info bloat (#21071)
fix: resolve flaky p2p_client test race condition on ARM64 (#21088)
chore: remove domain iteration macros and address backing memory race
(#20988)
fix: [ECCVM] added domain separation for the multiset equality check.
(#20352)
feat: hybrid CRS hash verification — 8MB chunks, parallel, span-based
(#21113)
chore: unify splitting scalars interface (#20805)
chore: add a unique id to each origin tag (#20924)
chore: Native curve audit (#20936)
chore: Update bootstrap in test vk haven't changed script (#21153)
fix: use reduced form in WASM FromMontgomeryForm test (#21164)
chore: erase ephemeral secrets from memory in schnorr and aes (#21106)
chore: suppress clangd target triple version diagnostic (#21180)
feat: Optimise new claim calculation (#21179)
docs: add Quick Start build instructions to barretenberg README (#20951)
feat: batched chonk verification (#21083)
fix: link libc++ instead of libstdc++ for Rust FFI on Linux (#21203)
fix: [ECCVM] in the transcript table, no-ops force the next accumulator
to be 0. (#20849)
fix: resolve merge-train conflict with next (zig wrapper scripts + -g0)
(#21201)
fix: [ECCVM] rare edge case completeness issue when `z1 == 0` but `z2 !=
0` (#20858)
fix: use actual data extent for CommitmentKey in HypernovaDeciderProver
(#21206)
END_COMMIT_OVERRIDE
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.

3 participants