perf(ui): replace O(n*e) edge mapping with binary search#170
Open
Selene29 wants to merge 1 commit intoDeusData:mainfrom
Open
perf(ui): replace O(n*e) edge mapping with binary search#170Selene29 wants to merge 1 commit intoDeusData:mainfrom
Selene29 wants to merge 1 commit intoDeusData:mainfrom
Conversation
The layout endpoint's edge-to-node mapping used a linear scan over all nodes for every edge, producing O(n*e) iterations. For large projects (100K+ nodes, 400K+ edges) this caused multi-second hangs or timeouts. Replace the two-pass fetch-then-map approach with a single-pass filter-during-fetch using a sorted node-ID array and binary search: - Build a sorted node_id_entry_t map after querying nodes - For each fetched edge, binary search both endpoints — O(log n) each - Only keep edges where both endpoints are in the selected node set - Compute degree inline, eliminating the separate mapping loop - Free rejected edges immediately to minimize peak memory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #169
Summary
Test plan
scripts/test.sh SANITIZE=passes (2507 passed, 61 skipped)