Liking cljdoc? Tell your friends :D

What the process holds beside the stores

  • Covers: the cache register (vaelii.impl.caches) — how a derived, droppable structure declares itself, what a descriptor says (:scope :unit :limit :counters :note), the one bound policy (wholesale clear, never eviction), the two reads caches / clear-caches, and a snapshot roster of every registered cache with its bound.
  • Not here: what the stores cost — the JVM heap figure and a loaded KB's estimated footprint → catalog.md; what the index isindexing.md, density.md; readings about the traffic rather than the held answers → profile.md; readings about the knowledgequality.md.
  • Assumes: sentex, handle, generation, the genlCx closure, the change clock → glossary.md, taxonomy.md.

A cache is a map of answers the engine would otherwise recompute — a dozen atoms and two static maps, none of them a store, all of them droppable without moving a belief. They do not show up in a heap figure as anything but bytes, and "the second query was fast" is a demo until a hit rate says why. This is the register that names them and the read that counts them.

The register

vaelii.impl.caches requires nothing. Every namespace that holds a cache requires it and calls register-cache once at load, so there is no list here for a new cache to be added to twice and no require edge from the reader down to the caches. The register is open: a cache in a namespace this process never loaded — a qualitative calculus nobody touched — is simply absent from the read, which is the honest answer rather than a row of zeroes.

Each descriptor carries what a reader needs to compare rows that count different things:

  • :scope:kb for a cache hanging off one KB record, :process for a static one every KB in the JVM shares. It says what :entries counts.
  • :unit — what one entry is: a literal, a network, a symbol, a mask. A column of bare integers compares none of them, so the unit rides every row.
  • :limit — entries held before the cache is cleared, or nil for one bounded by something other than a count (a generation, the store lifecycle), named in :note.
  • :counters:kb, :process, or nil: what a row's :hits / :misses count, which is not always what its :entries count. The literal cache is the awkward case — per-KB entries, process-wide AtomicLong counters — and conflating them would bill one KB for another's hits.
  • :note — one line: what it holds and what retires an entry.

A row whose :entries is nil cannot be counted from outside — it is scope-bound, alive for the length of one chaining run or one search step and garbage when it returns. It is registered all the same, so the list is complete rather than merely finite.

The bound: cleared wholesale, not evicted

A counted cache past its bound is dropped whole (assoc-bounded), not trimmed to the one entry that would make room. Evicting exactly the right entry costs more bookkeeping than the entry saves, and a cache that has outgrown its bound is one whose questions have moved on. A nil bound is not unbounded neglect: those caches are retired by a generation bump (a taxonomy edge or context change retires every closure read at once), by the change clock (a per-placement stamp, so a chaining run meets its own reads cold), or they are structural (the symbol pool, the compiled algebras) where dropping entries costs the sharing they exist for.

Reading them

  • (caches kb) — one row per registered cache: :entries :limit :unit :hits :misses :hit-rate, plus :scope / :counters / :note, and :error where a row's own read threw (one broken descriptor costs its row, not the answer). Each row is a count off a map the engine already holds, O(1), so the page that shows it can poll.
  • (clear-caches kb) — drop every cache that offers a clear and say what went. Bare, not !: every entry is derived and no belief moves, which makes a clear a measuring instrument — clear, ask the same question again, watch the miss the second ask no longer skips. Scoped to kb; {:counters? true} also zeroes the process-wide rates, in a call that says out loud it reaches past its argument.

Both are on the remote surface (vaelii.impl.serve) and drive the browser's caches page.

The roster (a snapshot — caches is the truth)

This list drifts; the register does not. Treat the table as orientation and (caches kb) as authority. Presence depends on what is loaded: the qualitative caches need the QCN/temporal reasoners, hot-records needs a disk-backed store.

KB-scoped — one set per KB:

CacheUnitBoundRetired by
Literal matches :literal-matchesliterals4096wholesale clear; each entry clock-stamped, so any state change drops it
Taxonomy closures :taxonomy-closuresreach setstaxonomy generation bump
Taxonomy closures, scoped :taxonomy-scoped-closuresvisibility sets128 / relationflush past budget, or generation bump
Taxonomy visibility sets :taxonomy-visibilityrelation/context pairsgeneration bump
Closure answers :closure-answersclosures100 000 memberswholesale drop; a single reach past the bound is never stored
Resident derived values :residentnetworks & passes256wholesale clear
Hot records :hot-recordsrecords65 536 / kindper-kind LRU (vaelii.disk.cache, 0 disables); disk stores only

Process-scoped — shared by every KB in the JVM:

CacheUnitBoundRetired by
Symbol pool :symbol-poolsymbols1 000 000wholesale clear
Relation decode tables :relation-decodemasks8192wholesale clear
Compiled algebras :compiled-algebrasalgebras64wholesale clear
Path-consistency passes :path-consistencynetworks256wholesale clear
Network support passes :network-supportnetworks256wholesale clear
Metric closures :metric-closuresnetworks256wholesale clear
Stored handles :stored-handlessentencesstructural
Closure neighbours :closure-neighboursneighbour setsstructural
Pinned values :pinned-valuesresident valuesstructural
Justification dedup :justification-dedupconclusionsstructural

The units do not sum: seventeen rows counting seventeen different things. A total across them is a number of nothing.

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close