Dashboard

cache_dashboard opens a terminal dashboard of the global caches, to browse them, watch their hit rates live, and empty or resize them while your program runs. It is a package extension on Tachikoma.jl, so load Tachikoma first:

using MemoizationKit, Tachikoma
cache_dashboard()                                # refreshes every second
cache_dashboard(; interval = 0.2, filter = "fs") # faster, only functions whose name contains "fs"

It has two tabs, for the caches in RAM and on disk.

Narrow terminals shorten names and drop columns. The minimum size is 40×8.

KeyAction
Tab, 1 / 2switch to the next tab / the RAM or Disk tab
↑ ↓, PgUp PgDn, Home Endselect a row
Enterresize the selected cache, in RAM
eempty the selected cache, in RAM
s / rsort by the next column / reverse the order, per tab
/filter by function name, on both tabs (Enter applies, Esc cancels)
grefresh now
q, Escquit

Statistics are copied under brief locks, so the dashboard can run while other tasks use the caches.

RAM caches

With a few example caches, the RAM tab looks like this (rendered while building these docs):

[RAM] │  Disk
 4 caches · 325 entries · 175KiB in byte-measured caches · recent hit rate 70.3%
 Name ▲               Hit rate      Size                   Kind       Activity
▌Main.fib             █████60%░░░░░ ▏░░░░░░░3/10k░░░░░░░░░ LRU+disk   ███████
 Main.label           ████100%█████ ▏░░░░░░░6/10k░░░░░░░░░ Clock      ▇█ ▁▃▄▅▇
 Main.matrix          ████100%█████ ███▊175KiB/1.0MiB░░░░░ Clock      ▆▇█▁▂▃▄▄
 Main.weights         █████67%▊░░░░ ▋░░░░░░276/10k░░░░░░░░ Clock      ▄█▆▃▇▅▂▆



╭─  Main.fib  ─────────────────────────────────────────────────────────────────────────────────────╮
│LRU+disk · 3 of 10000 entries · 89 hits · 69 misses                                               │
│hit rate: recent 60.0% · lifetime 56.3% · 0.0 hits/s                                              │
│████████ █████████ █████████ █████████                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
 ⇥ tab  ↑↓ select  ⏎ resize  e empty  s sort  r reverse  / filter  g refresh  q quit

The RAM tab shows one row per function and container type: recent hit rate, size against its limit, cache kind, and hits per second. The header totals entries and byte-measured values; the selected row's details include lifetime statistics. Recent hit rates cover the last 10 refreshes. Task-local caches are not shown.

In resize mode, ← / → halve or double the limit, [ / ] adjust it by 10%, Enter applies, and Esc cancels. The preview uses the cache's current measure (entries or bytes); applying calls set_cache_size!.

Emptying and resizing act on RAM only.

Disk caches

The Disk tab lists the disk caches opened in this process, including functions without a RAM cache:

 RAM  │ [Disk]
 2 disk caches · 85 entries · 821KiB · 144 hits · 85 misses (62.9%)
 Name ▲               Entries  Size     Hit rate      Activity
▌Main.fib             61       519KiB   ██▏░░17%░░░░░        █
 Main.kernel          24       302KiB   ████100%█████ ▇█▃▄▅▇█▃


 ⇥ tab  ↑↓ select  s sort  r reverse  / filter  g refresh  q quit

The Disk tab shows database entries and size (including the write-ahead log), hit rate, and activity. The selected row adds the database path. Hit/miss counters cover this process; entries and sizes describe the database shared on this machine.

Database sizes and entry counts are read in the background, at most every 10 seconds while the tab is shown, or on g. … appears until they arrive. The header indicates when disable_disk_caches! has turned disk caching off.

Use empty_disk_caches! to clear persistent results outside the dashboard.