Skip to content

Optimize normal-fit neighborhood sampling in vc_ngrids#725

Open
giorgioangel wants to merge 1 commit intomainfrom
codex/add-thread-local-cache-for-sample-queries
Open

Optimize normal-fit neighborhood sampling in vc_ngrids#725
giorgioangel wants to merge 1 commit intomainfrom
codex/add-thread-local-cache-for-sample-queries

Conversation

@giorgioangel
Copy link
Copy Markdown
Member

Motivation

  • Reduce repeated ngv.query_nearest(...) lookups and avoid rebuilding sample vectors for each radius step to cut CPU overhead when fitting normals.
  • Trade a bounded amount of per-sample memory for large preprocessing savings when adaptive radius expansion revisits overlapping neighborhoods.

Description

  • Add a per-thread cache keyed by a packed (plane_idx, slice_idx) for ngv.query_nearest(...) results and a query_nearest_cached(...) helper to reuse resolved grids across radius steps and nearby samples.
  • Introduce SegmentCandidate to store per-segment metadata (dir_unit, delta_xyz, weight, dist2, is_short_path) and add gather_segment_candidates(...) that collects and sorts all candidates once for the maximum radius.
  • Refactor radius handling so gather_samples_for_radius(...) advances per-plane cursors through the distance-sorted candidate lists and appends only newly in-range segments for larger radii, rather than rebuilding vectors from scratch.
  • Extend per-thread FitBuffers to persist candidates and per-plane candidate_cursor so candidate lists and cursors survive across radius iterations inside a sample evaluation.
  • Preserve existing adaptive-radius logic and fitting call sites (the solver uses the same dirs_unit, weights, and deltas_xyz inputs after the refactor).

Testing

  • Attempted to configure the project with cmake -S volume-cartographer -B volume-cartographer/build -DCMAKE_BUILD_TYPE=Release, but the build configuration failed because dependency fetches from GitHub were blocked (CONNECT tunnel failed, response 403 for xtl.git), so a full compile/run verification could not be completed.
  • No automated unit tests were executed in this environment due to the configuration/build failure; changes were validated by static inspection of the modified source to ensure API usages match the original flow.

Codex Task

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
scrollprize-org Ignored Ignored Preview Feb 16, 2026 6:20pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant