Skip to content

optimization ideas to improve performance of 2+ hop graph traversals #736

Description

@adsharma

Immediate Improvements

1. Change Default Scan Mode to Sequential

The OnDiskGraphNbrScanState constructor defaults randomLookup to true, causing unordered scans (on_disk_graph.cpp:89-93). Changing this default to false would use scanCommittedInMemSequential by default, which processes rows in order (csr_node_group.cpp:277-304).

// In src/graph/on_disk_graph.cpp, line 91
// Change from: bool randomLookup) {
// To: bool randomLookup = false) {

2. Optimize CSR Index for Sequential Access

The CSR scan checks if row indices are sequential before choosing scan mode (csr_node_group.cpp:257-260). During CSR index construction in updateCSRIndex, ensure adjacency lists are stored contiguously when possible to increase the isSequential hit rate (csr_node_group.cpp:345-373).

3. Implement Chunk Group Prefetching

The random scan frequently switches between chunk groups, causing cache misses (csr_node_group.cpp:318-334). Add prefetching logic when chunkIdx != currentChunkIdx to reduce latency:

// In src/storage/table/csr_node_group.cpp, around line 323
if (chunkIdx != currentChunkIdx) {
    // Add: __builtin_prefetch(chunkedGroups.getGroup(lock, chunkIdx));
    currentChunkIdx = chunkIdx;
    chunkedGroup = chunkedGroups.getGroup(lock, chunkIdx);
}

Structural Improvements

4. Reorganize IceDisk Data Layout

IceDisk CSR scans filter rows by bound node offsets, causing non-sequential access (ice_disk_rel_table.cpp:264-358). Consider:

  • Sorting edges by source node offset within Parquet files
  • Creating node-local partitions to reduce cross-bound-node scanning
  • Implementing zone maps to skip irrelevant row groups

5. Bound Node Reordering for Multi-level Traversals

For 2+ level traversals, reorder bound nodes between levels to maximize locality. The current implementation processes bound nodes sequentially (ice_disk_rel_table.cpp:295-308). Implement a reordering strategy that groups nodes by their physical storage location.

6. Adaptive Scan Mode Selection

Currently, the scan mode is determined at initialization (csr_node_group.cpp:61-84). Implement runtime adaptation:

  • Monitor chunk group switch frequency during scans
  • Dynamically switch between random and sequential modes based on observed locality patterns
  • Use cost-based optimization for multi-hop queries

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions