Skip to content

Commit

Permalink
Save ScheduleDiagnostics as Vectors
Browse files Browse the repository at this point in the history
`ScheduleDiagnostic`s with `NetCDFWriter`s have a complex type structure
that can lead to significant compile time. We originally saved
`ScheduleDiagnostic`s internally as tuples to improve inferrability, but
this does not seem to scale well with lots of diagnostics.

In the future, we might want to consider looking at the type signature
and move the reference to the writer outside of `ScheduleDiagnostic`s
and into the `DiagnosticHandler`.
  • Loading branch information
Sbozzolo committed Sep 26, 2024
1 parent c1cc7c3 commit 25945d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

main
-------
## Bug fixes

- `scheduled_diagnostics` are now internally saved as vectors instead of tuples.
This has significant compile-time/inference benefits.

v0.2.6
-------
Expand Down
4 changes: 2 additions & 2 deletions src/clima_diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ A struct that contains the scheduled diagnostics, ancillary data and areas of me
to store and accumulate results.
"""
struct DiagnosticsHandler{
SD <: Tuple,
SD,
STORAGE <: Dict,
ACC <: Dict,
COUNT <: Dict,
Expand Down Expand Up @@ -61,7 +61,7 @@ function DiagnosticsHandler(scheduled_diagnostics, Y, p, t; dt = nothing)
accumulators = Dict()
counters = Dict()

unique_scheduled_diagnostics = Tuple(unique(scheduled_diagnostics))
unique_scheduled_diagnostics = unique(scheduled_diagnostics)
if length(unique_scheduled_diagnostics) != length(scheduled_diagnostics)
@warn "Given list of diagnostics contains duplicates, removing them"
end
Expand Down

0 comments on commit 25945d9

Please sign in to comment.