From accd5fe99e9384233c9601cb38d018e251a06079 Mon Sep 17 00:00:00 2001 From: lkdvos Date: Wed, 29 Jul 2026 13:56:54 -0400 Subject: [PATCH 1/2] cache docstrings --- src/auxiliary/caches.jl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/auxiliary/caches.jl b/src/auxiliary/caches.jl index 03daf6997..6aaebfe27 100644 --- a/src/auxiliary/caches.jl +++ b/src/auxiliary/caches.jl @@ -1,9 +1,32 @@ +""" + const GLOBAL_CACHES + +Registry of the global caches TensorKit maintains, as `name => cache` pairs. + +See also [`empty_globalcaches!`](@ref) and [`global_cache_info`](@ref). +""" const GLOBAL_CACHES = Pair{Symbol, Any}[] + +""" + empty_globalcaches!() + +Empty every global cache in [`GLOBAL_CACHES`](@ref). +Since everything is recomputed on demand, this is purely a memory measure. + +See also [`global_cache_info`](@ref). +""" function empty_globalcaches!() foreach(empty! ∘ last, GLOBAL_CACHES) return nothing end +""" + global_cache_info([io::IO = stdout]) + +Print the hit/miss statistics and current size of every global cache in [`GLOBAL_CACHES`](@ref). + +See also [`empty_globalcaches!`](@ref). +""" function global_cache_info(io::IO = stdout) for (name, cache) in GLOBAL_CACHES println(io, name, ":\t", LRUCache.cache_info(cache)) From 60d06f25e2d790e3434f159411fe2f1599af0f75 Mon Sep 17 00:00:00 2001 From: lkdvos Date: Sat, 15 Aug 2026 11:21:54 +0200 Subject: [PATCH 2/2] more information in cache structures [skip ci] --- src/auxiliary/caches.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/auxiliary/caches.jl b/src/auxiliary/caches.jl index 6aaebfe27..4c5db4652 100644 --- a/src/auxiliary/caches.jl +++ b/src/auxiliary/caches.jl @@ -11,9 +11,12 @@ const GLOBAL_CACHES = Pair{Symbol, Any}[] empty_globalcaches!() Empty every global cache in [`GLOBAL_CACHES`](@ref). +These mostly contain bookkeeping for various different index manipulations and tensor structures, +so clearing this out can free up some memory whenever you have a workflow that involves a large variety of structures. +For example, you may want to clear the cache when working with different symmetries, or in algorithms that dynamically alter the sizes of tensors. Since everything is recomputed on demand, this is purely a memory measure. -See also [`global_cache_info`](@ref). +See also [`global_cache_info`](@ref) to display the status. """ function empty_globalcaches!() foreach(empty! ∘ last, GLOBAL_CACHES)