Under the Hood: Fused SIMD-Accelerated Scoring Pipeline
Traditional retrieval architectures use a two-phase pipeline: first, retrieve the top-K elements by vector similarity; second, filter and rerank those results based on metadata, recency, and other parameters.
While simple, this setup suffers from the Truncation Trap—critical, older memories can be eliminated in the first phase because their vector similarity score is slightly lower, even if their recency, valence, or importance weights would have made them the top choice.
To solve this, Spector implements a fused scoring pipeline. In a single, SIMD-accelerated off-heap pass, every candidate memory is evaluated against all parameters simultaneously.
Here is how the pipeline achieves ultra-low sub-millisecond latency at scale inside the JVM.
The 6-Phase Scoring Funnel
Spector executes six operations for every memory segment evaluated:
[Memory Candidate]
|
v
1. Panama Memory Read ------> (Reads float array zero-copy from off-heap)
|
v
2. SIMD Vector Similarity --> (AVX-512/AVX2 dot product/cosine computation)
|
v
3. Temporal Decay Rating ---> (Ebbinghaus Power-Law decay multiplier)
|
v
4. Amygdala Valence Check --> (Shift scores based on valence bias and arousal)
|
v
5. Hebbian Graph Weight ----> (Boost score based on active node association counts)
|
v
6. Selection Threshold ------> (If final score exceeds threshold, keep Candidate)
1. Project Panama Zero-Copy Reads
Unlike standard Java databases that represent vectors as standard float[] objects (which are subject to JVM heap garbage collection overhead), Spector stores all vectors off-heap.
Using Java 25's Panama Foreign Function & Memory (FFM) API, memory is mapped directly to off-heap byte segments (MemorySegment). This allows Spector to stream vector coordinates directly to CPU registers without creating objects on the heap—completely eliminating GC pauses.
2. SIMD-Accelerated Math
Once the memory is read, Spector executes vector similarity using the Java Vector API (jdk.incubator.vector).
The JIT compiler translates these Java operations directly into hardware-native SIMD instructions (AVX-512 on modern Intel/AMD processors, or NEON on ARM architecture):
// Simplified SIMD dot-product representation in Spector
var species = FloatVector.SPECIES_PREFERRED;
int bound = species.loopBound(vectorLength);
FloatVector sum = FloatVector.zero(species);
for (int i = 0; i < bound; i += species.length()) {
var v1 = FloatVector.fromMemorySegment(species, segment1, i * Float.BYTES, ByteOrder.nativeOrder());
var v2 = FloatVector.fromMemorySegment(species, segment2, i * Float.BYTES, ByteOrder.nativeOrder());
sum = v1.fma(v2, sum); // Fused Multiply-Add instruction
}
float similarity = sum.reduceLanes(VectorOperators.ADD);
3. Power-Law Temporal Decay
Once similarity is calculated, the score is multiplied by the Ebbinghaus decay value:
\[S_{decay} = S_{similarity} \times (t - t_{last})^{-\lambda}\]
Where:
- \(t - t_{last}\) is the time elapsed since the memory was last accessed
- \(\lambda\) is the Ebbinghaus decay rate from the active Cognitive Profile
Because the decay function is applied during the vector pass, older memories that are highly similar are scaled down naturally without requiring a separate database filter.
4. Emotional Valence & Amygdala Modeling
Next, the score is adjusted by the emotional properties of the memory:
- If the active Cognitive Profile has a negative valence bias (e.g., Debugging Mode) and the memory has a negative valence rating (e.g., an error), the score is boosted.
- High-arousal memories (flashbulb memories) bypass decay calculations entirely and are given a permanent score boost.
5. Hebbian Association Boost
Finally, the memory's Hebbian association graph is queried. If other memories linked to the current memory are active in the agent's Working Memory, the candidate memory receives a spreading activation boost, proportional to the co-activation link weights.
The Performance Result
By merging all five dimensions—vector distance, time, valence, arousal, and associations—into a single JIT-compiled loop, Spector eliminates intermediate array allocations and nested logic loops.
This fused design allows Spector to maintain a p50 search latency of 0.13 milliseconds over a partition of 1,000,000 memories, providing AI agents with instantaneous, context-rich recall.