← BACK TO NOTES
2026-08-30 |
HDK HOUDINI

Caching: Making a Heavy Node Feel Light

A heavy node, say one that erodes terrain, can take hundreds of milliseconds to a few seconds per cook.
If you wait that long every time you nudge a parameter, tuning goes nowhere. So the node remembers its last result and skips the parts that have not changed.

Not Houdini's own cache

Houdini already returns the cooked result as is when neither the inputs nor the parameters changed.
But that works per node. If you only change a color curve, redoing the height preprocessing is wasteful, and Houdini cannot tell the difference. The cache inside a node is yours to build.

My repo (the terrain nodes, prefix TERA) has three kinds, each for a different purpose:

  • Output cache inside a node. If the inputs are the same, return the previous output.
  • Frame cache for simulations. Things computed frame by frame, like a river flow, are remembered per frame.
  • Disk cache. The terrain is split into small tiles, and each tile is written to its own file (.bgeo.sc).

The hard part is always the same: how do you decide "same as last time"? I ended up with three kinds of key.

Key 1: are the inputs the same? (a pointer)

The color node TERA_Tint remembers a pointer to the contents of each of its four inputs.
It rebuilds only the inputs whose pointer changed, and if none did, it writes the stored output straight back (shortened here).

for (int c = 0; c < 4; ++c)
    if (myCache.snapshots[c].get() != inputs[c].get()) {
        myCache.outputValid = false;      // the previous output is no longer usable
        // rebuild just this input
    }

if (myCache.outputValid)
    // write the stored output straight back

Comparing a pointer is far cheaper than comparing contents.
The price is relying on one assumption: when Houdini rebuilds an input, the pointer changes too.

Key 2: are the settings the same? (a signature)

The river simulation mixes the input curve's points, the terrain resolution and heights, every parameter and the ramp values into one 64-bit signature.
If the signature differs from last time, the whole cache is thrown away.

void RiverSimulationCache::setSignature(uint64_t signature) {
    if (signature != mySignature) {
        clear();
        mySignature = signature;
    }
}

If a parameter is missing from the signature, moving it changes nothing.
That is how cache bugs usually look.

Key 3: is the file the same? (modification time and size)

Tiles read from disk are also kept in memory.
Whether that in-memory copy is still fresh is decided by whether the file's modification time and size are what they were when it was loaded.

bool TileBgeoLoadCache::entryIsFresh(const Entry &entry) const {
    // ...
    return modTime == entry.modTime && fileSize == entry.fileSize;
}

Never write from a cook

The tile files are written only when you press a button such as "Cache All" or "Cache Single".
Nothing is written inside the cook. A cook can run any time and any number of times, and I do not want it to have the side effect of rewriting files.

Stop it from growing

A cache eats memory if you let it.
The river simulation takes a limit in MB and drops the oldest frames first when it is exceeded. TERA_Tint stops at 256 MiB for its mask intermediates.

Actual numbers

For a node that colors riverbanks (CPU version), here is recomputing after a curve change against a cache hit:

Terrain resolution Recompute after curve change Cache hit
1025² 519.89 ms 1.86 ms
2049² 868.58 ms 5.03 ms

Even a cache hit is not zero, because the output geometry still has to be rebuilt every time.

A hit is not "faster"

The repo has a rule: do not report a cache-hit time as a speedup.
The reason is simple. Not doing the same work twice is not the same as doing the work faster. When I measure, I write three numbers separately: the first cook, a cook after a settings change, and a cache hit.

Next up is the other way to make the work itself faster: the GPU.

Related articles

2026-08-26

Houdini to Unreal: Nodes That Carry Intent by Name

To hand Houdini geometry to Unreal Engine correctly, you have to write attribute and group names correctly. Here are the naming rules for collision, materials and landscapes, and the nodes that write them.

2026-09-08

Four Traps of Attributes and Groups in C++

What I made into rules for handling Houdini geometry attributes and groups in C++, and the four places I actually got stuck (handles outside loops, announcing changes, group name collisions, and mixing up points and vertices).

2026-08-21

Making a Node Use All 12 Threads

A Houdini node cooks on one thread unless you tell it otherwise. Here is the loop that spreads the work over every core, how fast it got on my PC, and the one thing that made Houdini crash on me.

Comments