Repository navigation
Conversation
asinghvi17
reviewed
Sep 15, 2026
asinghvi17
reviewed
Sep 15, 2026
- Define `DiskArrayEngineBackend` in DiskArrays itself and add a MethodError
hint pointing to DiskArrayEngine.jl. Drops the DiskArrayEngine dependency
and extension, which only existed to import the type.
- `DynamicBackend` now holds a `Union{DefaultBackend,DiskArrayEngineBackend}`
so dispatch on it is union-split into a branch instead of a dynamic
dispatch. `set_dynamic_backend!` switches it at runtime.
- Backends unknown to DiskArrays are attached per array with
`withbackend(array, backend)`. Entry points find the backend with
`get_backend(array)`, which walks up `parent` until `parent(a) === a`.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ra7EAJeFE1dtekwf4Tzxh
asinghvi17
added this pull request to stack #314
September 18, 2026 15:46
The union-split branch costs ~nothing (measured: same time and allocations as a hard-coded DefaultBackend), so runtime switching no longer needs a "dynamic" preference. The preference now only selects the backend that is active at load time, and `set_backend` also switches the running session instead of asking for a restart. Also force specialization on `f` in the `sum`/`prod`/.../`extrema`/`mean` entry points. `f::Function` is only passed through there, so Julia did not specialize on it and the inner call was a dynamic dispatch: `sum(a)` on a 2-element array goes from 142 ns / 11 allocs to 61 ns / 7 allocs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ra7EAJeFE1dtekwf4Tzxh
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ra7EAJeFE1dtekwf4Tzxh
- `unique` visits chunks in a different order than an Array's elements, so test with `issetequal` (of the `f` values for `unique(f, x)`, where the first representative differs) instead of `@test_broken ... ==`, which passed or failed depending on the random data. - Qualify `Base.mapreducedim!`, size the output from `ndims` instead of assuming 3 dimensions, and start the reference from `zero(R)` instead of uninitialized memory. - Only test `median(dims=2)` for ndims >= 2 and `cumsum`/`cumprod` without `dims` for vectors. - `init=0.0` for float data, an Int `init` with `dims` throws in Base too. - Compare chunked float reductions with `≈`, and do not `count` floats. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ra7EAJeFE1dtekwf4Tzxh
…I on stacked PRs `count`, `unique`, `extrema` and `mean` were only defined for `DefaultBackend`, so unlike the other hooks a backend had to implement them or they threw a MethodError. They now have a `::ComputeBackend` fallback like `sum`, `mapreduce` etc. CI only ran for pull requests into `main`, so stacked PRs were never tested. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ra7EAJeFE1dtekwf4Tzxh
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ra7EAJeFE1dtekwf4Tzxh
…erred` On Julia 1.10 the default `sum` over chunks infers `Any`, also on `main` and with a hard-coded `DefaultBackend`. What the backend tests should guarantee is that the indirection through `DynamicBackend` does not change the inferred type. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ra7EAJeFE1dtekwf4Tzxh
meggart
marked this pull request as ready for review
September 21, 2026 15:06
Collaborator
Author
|
Replaced by #316 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As part of the discussion in #273 we discussed the necessity for optional compute backends. This is a draft implementation that let's users switch backends using Preferences.jl. It is also possible to set the backend to "dynamic", which let's you switch backends at runtime but involves some dynamic dispatch each time a computation is triggered (a cost which should be negligible, given we are concerned with operations that involve IO). A first backend would be DiskArrayEngine, the PR is here: meggart/DiskArrayEngine.jl#69