Skip to main content

predict

Function predict 

Source
pub fn predict(tree: &SerializedTree, feats: &TreeFeats) -> u64
Expand description

Walk a serialized tree and predict the next burst, the Rust mirror of mlfq_tree_walk() in src/bpf/intf.h (the BPF wrapper adds only the meta gate and the map lookup around this walk).

The walk descends at most MLFQ_TREE_MAX_DEPTH internal nodes, masking every index with MLFQ_TREE_MAX_NODES - 1, splitting on feature & 0xF, and returning left for a leaf (right == 0). A masked index past the live nodes of an unpadded tree reads like a zeroed store node (a leaf predicting 0). Depth exhausted, the last reachable node’s left is returned only when that node is a leaf; an internal node there (a tree deeper than the bound) yields 0, matching the BPF side.

An empty tree predicts 0, mirroring the untrained store.