Commit e1512c2
committed
perf: hash-adjacency overhaul — agehash + flat-array VertexEdgeArray
Replaces the per-graph adjacency map with a Robin Hood open-addressing
hashtable (agehash) and an embedded flat-array edge list, removing the
hottest dynahash path on IC1 and shrinking the largest hashtable AGE
keeps. Stages land as one commit:
S1 MurmurHash3 fmix64 for graphid hashtables (replaces tag_hash)
S2 Precompute graphid hash; share across paired DFS lookups
S3 Replace ListGraphId adjacency with embedded flat-array
VertexEdgeArray (single palloc, contiguous iteration)
S4 Batched MLP lookup pipeline in add_valid_vertex_edges
S5/C1 agehash library: INLINE Robin Hood hashtable with
_with_hash API, freeze, iter, and a regress-only selftest
S5/C2 Wire global graph edge_hashtable through agehash;
drop edge_id from edge_entry (key lives in slot header);
AGEHASH_MAX_LOAD=0.85; MemoryContextAllocHuge for SF10+
Performance (SF3 LDBC SNB, 5 runs/3 warmup, vs clean master baseline_v2):
IC1 8,625 → 7,117 ms −17.49 % (the headline; hashtable-bound)
IU1 40 → 35 ms −11.86 % (heaviest update; lookup-bound)
IC sum 198,958 → 197,367 ms −0.80 % (suite-level noise)
IS sum 1,009 → 1,028 ms +1.86 % (IS3 jitter; sub-ms)
IU sum 77 → 72 ms −6.64 %
IC2/3/4/5/6/7/8/9/10/11/12: parity (within ±3.3 %, mostly ±1.5 %)
The VLE-DFS-heavy queries (IC3/5/6/9/11) sit at parity: with
hash_search_with_hash_value at ≤1 % inclusive on their baseline
flames, no hashtable swap can recover meaningful wall-time on them.
Memory: removing edge_id from edge_entry saves ~416 MB on SF3 and
~1.4 GB on SF10 for the global graph's edge_hashtable. Slot capacity
uses MemoryContextAllocHuge so SF10+ edge tables can be built.
Adds:
src/backend/utils/cache/agehash.c, src/include/utils/agehash.h
regress/sql/agehash.sql + expected/agehash.out (boundary selftest)
_agehash_self_test() in both fresh-install and upgrade SQL
Tested on PostgreSQL 18.3 (REL_18_STABLE): all 35 regression tests
pass (installcheck), warning-free build.
Co-authored-by: Claude <noreply@anthropic.com>
modified: Makefile
modified: age--1.7.0--y.y.y.sql
new file: regress/expected/agehash.out
new file: regress/sql/agehash.sql
modified: sql/age_main.sql
modified: src/backend/utils/adt/age_global_graph.c
modified: src/backend/utils/adt/age_vle.c
new file: src/backend/utils/cache/agehash.c
modified: src/include/utils/age_global_graph.h
new file: src/include/utils/agehash.h1 parent a1b749a commit e1512c2
10 files changed
Lines changed: 1372 additions & 173 deletions
File tree
- regress
- expected
- sql
- sql
- src
- backend/utils
- adt
- cache
- include/utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| |||
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| 157 | + | |
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
89 | 99 | | |
90 | 100 | | |
91 | 101 | | |
| |||
0 commit comments