From ddbfbfac7478c2738322dbb6cfbbbdda99094ed0 Mon Sep 17 00:00:00 2001 From: Gabriele Bozzola Date: Thu, 26 Sep 2024 10:26:40 -0700 Subject: [PATCH] Save ScheduleDiagnostics as Vectors `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`. --- NEWS.md | 3 +++ src/clima_diagnostics.jl | 9 ++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8840da13..a5f6d3ce 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 ------- diff --git a/src/clima_diagnostics.jl b/src/clima_diagnostics.jl index fa3483d1..8b6c40c2 100644 --- a/src/clima_diagnostics.jl +++ b/src/clima_diagnostics.jl @@ -13,12 +13,7 @@ include("reduction_identities.jl") A struct that contains the scheduled diagnostics, ancillary data and areas of memory needed to store and accumulate results. """ -struct DiagnosticsHandler{ - SD <: Tuple, - STORAGE <: Dict, - ACC <: Dict, - COUNT <: Dict, -} +struct DiagnosticsHandler{SD, STORAGE <: Dict, ACC <: Dict, COUNT <: Dict} """An iterable with the `ScheduledDiagnostic`s that are scheduled.""" scheduled_diagnostics::SD @@ -61,7 +56,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