Skip to content

Disable allocation logging if reshape allocates #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 10, 2025
Merged

Conversation

j-fu
Copy link
Member

@j-fu j-fu commented Jul 8, 2025

try to mitigate JuliaLang/julia#58634

@j-fu j-fu requested a review from Copilot July 8, 2025 20:14
Copy link
Contributor

@Copilot 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 introduces a mechanism to disable allocation logging when certain operations (like reshape) unexpectedly allocate, mitigating JuliaLang issue #58634. It adds a global flag to control allocation checks, updates the solver and tests to respect this flag, and adds a CI helper to auto-disable checks when reshape allocates.

  • Introduce check_allocs flag and control functions in VoronoiFVM.jl
  • Extend solver’s allocation warning to honor check_allocs
  • Add CI logic in tests to detect reshape allocations and disable checks

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/test_inplacelu.jl Switched allocation macros and wrapped tests in check_allocs guard
test/alltests.jl New helper functions to detect reshape allocations and disable checks
src/vfvm_solver.jl Updated allocation warning condition to include check_allocs()
src/VoronoiFVM.jl Added _check_allocs global and check_allocs/check_allocs! APIs
docs/src/internal.md Documented the new check_allocs APIs
Comments suppressed due to low confidence (6)

test/alltests.jl:6

  • [nitpick] The function name treshape is ambiguous. Consider renaming to test_reshape or measure_reshape_alloc for clarity.
function treshape(X::AbstractArray, n, m)

test/alltests.jl:12

  • [nitpick] The name talloc is not descriptive. You might use measure_allocations or test_allocations to convey its purpose.
function talloc(; n = 10, m = 20)

test/test_inplacelu.jl:167

  • The macro @allocations is not defined in Base; this will error. Replace it with @allocated or import/define @allocations if you need a custom macro.
    m1 = @allocations inplacelu_piv_stridearray(10, Float64)

src/VoronoiFVM.jl:68

  • There's a typo in the docstring: alllocations should be allocations (one fewer "l").
Should alllocations be checked ?

test/alltests.jl:3

  • Importing the module name via using VoronoiFVM: VoronoiFVM is invalid. You can either using VoronoiFVM or explicitly import only check_allocs!.
using VoronoiFVM: VoronoiFVM, check_allocs!

test/alltests.jl:20

  • [nitpick] Consider capitalizing "Julia" in the warning message for consistency: "Disabling allocation checks due to Julia issue #58634".
    @warn "Disabling allocation checks due to julia issue #58634"

@j-fu j-fu requested a review from pjaap July 8, 2025 20:20
@j-fu
Copy link
Member Author

j-fu commented Jul 8, 2025

For more explanations:
Currently, allocations in assembly loop are reported on Julia 1.12, 1.13 when the code runs with --check-bounds=yes (as by default in CI). This spoils the CI output. They can be tracked down to a reshape call in ForwardDiff. So this is can be tested at the start of CI, aid allocation warnings can be disabled. No user facing changes.

The problem is reporte in JuliaLang/julia#58634 and seems to improve with recent nightly.

@j-fu
Copy link
Member Author

j-fu commented Jul 9, 2025

Ready to merge...

@j-fu j-fu merged commit 29ab244 into master Jul 10, 2025
15 checks passed
@j-fu j-fu deleted the jf/mitigate-1-12-allocs branch July 10, 2025 12:52
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