Skip to content

Optimize out degree count query#646

Open
adsharma wants to merge 8 commits into
mainfrom
outdegree_optimizer
Open

Optimize out degree count query#646
adsharma wants to merge 8 commits into
mainfrom
outdegree_optimizer

Conversation

@adsharma

@adsharma adsharma commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

If your node table is sorted by primary key, we can avoid joins and CSR indptr to answer.
Note that you have to ensure the following invariant for correctness:

a.primary_key == a.rowid

So it's more than just sorting in ascending order.

Before:

--- 9. Out-degree for 100 nodes (id 1..100) ---
    run 1: 54.9 ms
    run 2: 54.7 ms
    run 3: 54.5 ms
    => best:  54.5 ms
    => worst: 54.9 ms
    => avg (warm): 54.8 ms
  Sum of out-degrees for 100 nodes: 500

after:

--- 9. Out-degree for 100 nodes (id 1..100) ---
  run 1: 28.1 ms
  run 2: 25.9 ms
  run 3: 26.2 ms
  => best:  25.9 ms
  => worst: 28.1 ms
  => avg (warm): 27.1 ms
Sum of out-degrees for 100 nodes: 500

adsharma added 6 commits July 3, 2026 07:39
…gration

Instead of throwing RuntimeException when a WAL record's declared length is
shorter than what the current deserializer expects (e.g. v42->v43), enforce
the readLimit at the Deserializer::read() level. If a read would exceed the
declared record boundary, only the available bytes are read from the stream
and the remainder of the output buffer is zero-filled. This gives new fields
default (zero) values and keeps the stream positioned at the correct record
boundary, so the next record in the WAL is not corrupted during replay or
checkpoint.

Key changes:
- Deserializer::read() truncates reads at the readLimit boundary
- deserializeValue<T>() and the std::string specialization route through
  the enforcing read() method instead of reader->read() directly
- skipReadLimit() no longer throws (the over-read case cannot occur)
- WALRecordDeserializeHandlesSizeMismatch test verifies silent handling
  with correct stream positioning
@adsharma adsharma force-pushed the outdegree_optimizer branch from 81948a2 to 36d671c Compare July 3, 2026 14:39
@adsharma adsharma force-pushed the outdegree_optimizer branch from 36d671c to 695a7a8 Compare July 3, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant