Replace DataStructures.jl with BinaryHeaps.jl to cut invalidations#3407
Open
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:masterfrom
Open
Conversation
Swaps the `DataStructures` dependency for the lightweight [BinaryHeaps.jl](https://github.com/SciML/BinaryHeaps.jl) package, which contains the same `BinaryHeap` / `BinaryMinHeap` / `FasterForward` code extracted from DataStructures.jl (same upstream source). DataStructures.jl causes 6 method invalidation trees (from unrelated OrderedCollections, Accumulators, and SortedContainers code). BinaryHeaps.jl causes zero invalidations. Changes: - OrdinaryDiffEqCore: `using DataStructures: BinaryHeap, FasterForward` → `using BinaryHeaps: BinaryHeap, FasterForward`; drop `DataStructures.FasterForward()` qualifier. - DelayDiffEq: `using DataStructures: BinaryMinHeap` → `using BinaryHeaps: BinaryMinHeap`. - StochasticDiffEqCore: removed unused `DataStructures` import. - Project.tomls updated accordingly; top-level `OrdinaryDiffEq/Project.toml` drops the unused `DataStructures` entry. Requires BinaryHeaps.jl v1.0.0 to be registered. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Swaps the
DataStructuresdependency for the new lightweight SciML/BinaryHeaps.jl, which contains the sameBinaryHeap/BinaryMinHeap/FasterForwardcode extracted directly from DataStructures.jl (same upstream source, MIT-licensed, original copyright preserved).Depends on: SciML/BinaryHeaps.jl#1 being merged and v1.0.0 registered in General.
Motivation
Loading
DataStructures.jlcauses 6 method invalidation trees from code that is completely unrelated to heap functionality:OrdinaryDiffEq only uses
BinaryHeap{T}(FasterForward()),BinaryMinHeap{T},push!,pop!,first,isempty,empty!,sizehint!— a tiny slice of DataStructures. Pulling in the full package costs 6 invalidation trees and their associated first-call latency for zero benefit.BinaryHeaps.jlprovides the exact same API with zero invalidations.Changes
using DataStructures: BinaryHeap, FasterForward→using BinaryHeaps: BinaryHeap, FasterForward; threeDataStructures.FasterForward()→FasterForward()insolve.jl.using DataStructures: BinaryMinHeap→using BinaryHeaps: BinaryMinHeap.DataStructuresimport (it was unused — nothing from the package was referenced).OrdinaryDiffEq/Project.tomldrops the unusedDataStructuresentry.Diff is 8 files, +10 / -15 lines.
Verification
Locally tested with
BinaryHeaps.jldev-installed:OrdinaryDiffEqTsit5loads and runs withtstops/saveat(both useBinaryHeap{T}(FasterForward())):DelayDiffEqloads and runs a DDE with a constant lag (usesBinaryMinHeapfor propagated discontinuities):Test plan
tstops/saveatworksconstant_lagsworks🤖 Generated with Claude Code