Skip to content

Commit 9a07b99

Browse files
committed
Reduce default max cache size for DataHandlers
This should reduce the memory footprint for long simulations
1 parent d889c5c commit 9a07b99

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ to learn more about this.
6767

6868
This capability is only available for the `InterpolationsRegridder`.
6969

70+
#### Reduced default size of cache in `DataHandler`. PR [#133](https://github.com/CliMA/ClimaUtilities.jl/pull/133)
71+
72+
The default cache size for regridded fields in `DataHandler` was reduced from
73+
128 to 2, reducing the memory footprint. You can pass the `cache_max_size`
74+
keyword argument to control this value.
75+
7076
v0.1.19
7177
------
7278

ext/DataHandlingExt.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ end
130130
target_space::ClimaCore.Spaces.AbstractSpace;
131131
start_date::Dates.DateTime = Dates.DateTime(1979, 1, 1),
132132
regridder_type = nothing,
133-
cache_max_size::Int = 128,
133+
cache_max_size::Int = 2,
134134
regridder_kwargs = (),
135135
file_reader_kwargs = ())
136136
@@ -144,7 +144,9 @@ different files.
144144
the latter case, the entries of `file_paths` and `varnames` are expected to match based on
145145
position.
146146
147-
The DataHandler maintains an LRU cache of Fields that were previously computed.
147+
The DataHandler maintains an LRU cache of Fields that were previously computed. The default
148+
size for the cache is only two fields, so if you expect to re-use the same fields often,
149+
increasing the cache size can lead to improved performances.
148150
149151
Creating this object results in the file being accessed (to preallocate some memory).
150152
@@ -202,7 +204,7 @@ function DataHandling.DataHandler(
202204
target_space::ClimaCore.Spaces.AbstractSpace;
203205
start_date::Union{Dates.DateTime, Dates.Date} = Dates.DateTime(1979, 1, 1),
204206
regridder_type = nothing,
205-
cache_max_size::Int = 128,
207+
cache_max_size::Int = 2,
206208
regridder_kwargs = (),
207209
file_reader_kwargs = (),
208210
compose_function = identity,

0 commit comments

Comments
 (0)