Commit 92c1d8d
perf(hnsw): deduplicate neighbor updates and fix error handling (#9664)
## Summary
- **Deduplicate `addNeighbors` calls**: Replace `nnUidArray` (which
accumulated duplicate UIDs when the same neighbor appeared across
multiple HNSW layers) with direct iteration over
`inboundEdgesAllLayersMap` keys, ensuring each neighbor is processed
exactly once
- **Fix error handling for `addNeighbors(inUuid, ...)`**: The error was
previously checked *after* the neighbor loop instead of immediately,
allowing unnecessary work on failure
- **Fix silent error swallowing**: `searchPersistentLayer` errors were
returned as `layerErr` (always `nil`) instead of `err`, masking real
failures
## Test plan
- [ ] Verify existing HNSW vector index tests pass (`go test
./tok/hnsw/...`)
- [ ] Confirm `addNeighbors` is called once per unique neighbor UID (no
redundant writes)
- [ ] Validate error propagation from `searchPersistentLayer` is no
longer swallowed
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 1b40e85 commit 92c1d8d
2 files changed
Lines changed: 88 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
596 | | - | |
597 | | - | |
598 | 596 | | |
599 | 597 | | |
600 | 598 | | |
| |||
617 | 615 | | |
618 | 616 | | |
619 | 617 | | |
620 | | - | |
621 | 618 | | |
622 | 619 | | |
623 | 620 | | |
| |||
626 | 623 | | |
627 | 624 | | |
628 | 625 | | |
629 | | - | |
| 626 | + | |
630 | 627 | | |
631 | 628 | | |
632 | 629 | | |
633 | 630 | | |
634 | 631 | | |
635 | 632 | | |
636 | | - | |
637 | 633 | | |
638 | 634 | | |
639 | 635 | | |
640 | 636 | | |
641 | 637 | | |
642 | | - | |
643 | | - | |
644 | 638 | | |
645 | 639 | | |
646 | 640 | | |
647 | 641 | | |
648 | 642 | | |
649 | | - | |
650 | | - | |
651 | | - | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
652 | 649 | | |
653 | 650 | | |
654 | 651 | | |
655 | 652 | | |
656 | 653 | | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | 654 | | |
662 | 655 | | |
663 | 656 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
456 | 537 | | |
457 | 538 | | |
458 | 539 | | |
| |||
0 commit comments