Module optimizations

Module optimizations 

Source
Expand description

Internal performance optimizations for the native backend.

This module contains various in-memory optimizations that accelerate graph traversal without changing the on-disk format or public APIs. All optimizations are internal implementation details only.

§INLINE HINT STRATEGY (Phase 13 Step 5)

§Tier A: Tiny Hot Path Functions (#[inline(always)])

  • unlikely(): Simple boolean wrapper used frequently in hot paths
  • get_outgoing_edges(), get_incoming_edges(): Simple HashMap access
  • get(), put(): Simple cache operations
  • Thread-local access wrappers: Minimal overhead functions

§Tier B: Small Helper Functions (#[inline] or compiler-driven)

  • register_edge(): Moderate complexity but hot path
  • Cache management functions: Used frequently but larger logic

§Tier C: Large Functions (no inline hints)

  • Cache eviction logic: Complex algorithms left to compiler discretion

Structs§

NeighborPointerTable
Neighbor pointer table mapping node IDs to lists of edge file offsets This enables O(1) adjacency lookup without scanning edge slots
NodeHot
Hot-field node cache containing frequently accessed node metadata This avoids full node deserialization for adjacency operations
NodeHotCache

Functions§

clear_all_caches
Clear all optimization caches (useful for testing)
extract_node_hot
Extract hot metadata from a node record
get_incoming_edge_offsets
Get incoming edge offsets for a node from the pointer table
get_node_hot
Get hot metadata for a node from the cache
get_outgoing_edge_offsets
Get outgoing edge offsets for a node from the pointer table
put_node_hot
Put hot metadata for a node in the cache
register_edge_offset
Register an edge in the neighbor pointer table This should be called whenever an edge is written to disk Optimized with cold-path offloading for cache management
with_neighbor_pointer_table
Get access to the global neighbor pointer table
with_node_hot_cache
Get access to the global node hot cache