fix: expand Pyramid ef search for large topk#2162
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR ensures Pyramid KNN search uses an effective ef that is at least topk, preventing searches from returning fewer than k results when ef_search < k.
Changes:
- Update Pyramid
KnnSearchto set internaleftomax(ef_search, k). - Add a functional test that asserts
KnnSearchreturnstopkresults even whenef_searchis smaller thantopk.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/test_pyramid.cpp | Adds coverage for the ef_search < topk scenario to ensure topk results are returned. |
| src/algorithm/pyramid.cpp | Adjusts internal search parameters so ef is at least k. |
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Require kind labelWonderful, this rule succeeded.
🟢 Require version labelWonderful, this rule succeeded.
|
There was a problem hiding this comment.
Code Review
This pull request ensures that search_param.ef is at least as large as k by setting it to the maximum of parsed_param.ef_search and k, and adds a corresponding unit test. Feedback suggests clamping k to at least 0 before casting to uint64_t to prevent potential wrap-around issues if k is negative.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
7c2d9a1 to
aceb8ff
Compare
Signed-off-by: JiangChao <jacllovey@qq.com> Assisted-by: Codex:GPT-5
aceb8ff to
9e34107
Compare
Change Type
Linked Issue
What Changed
efto at leasttopk, matching HGraph behavior whentopk > ef_search.ef_search < topkand asserting KNN returnstopkresults when enough data exists.Test Evidence
make fmtmake lintmake testmake cov, run tests, and collect coverageTest details:
Compatibility Impact
topkexceedsef_search, so it can return the requestedtopkresults instead of being capped byef_search.Performance and Concurrency Impact
topk > ef_searchmay do more work, consistent with the larger requested result count.Documentation Impact
README.mdDEVELOPMENT.mdCONTRIBUTING.mdRisk and Rollback
Checklist
kind/bugandkind/feature; see "Linked Issue" above)[skip ci]prefix)