Skip to content

Conversation

@CascadingRadium
Copy link
Member

@CascadingRadium CascadingRadium commented Dec 22, 2025

  • Reuse DocumentMatch objects in FilteringSearcher to avoid triggering DocumentMatchPoolTooSmall when documents fail the filter function and are not recycled, which previously caused repeated DocumentMatch allocations.
  • Move the DocValueVisitor closure out of the hot path to avoid per-document heap allocations caused by closure escape; the closure is now allocated once and reused, eliminating runtime.newobject calls in the critical loop.
  • Avoid unnecessary slice creation in the DocValuesVisitor.
  • Reduce garbage created when sorting by GeoDistance by avoiding unnecessary string and slice creation and by reusing byte buffers.

@coveralls
Copy link

coveralls commented Dec 22, 2025

Coverage Status

coverage: 53.702% (-0.02%) from 53.722%
when pulling 0ef6f22 on geo
into 9808f42 on master.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes performance for geo-spatial queries by addressing heap allocation bottlenecks. The key objective is to reduce allocations in hot paths during document filtering and geo-spatial calculations.

  • Reuses DocumentMatch objects in FilteringSearcher to prevent pool exhaustion
  • Extracts DocValues visitor closures out of per-document loops to eliminate repeated closure allocations
  • Optimizes slice filtering in snapshot_index.go to avoid unnecessary allocations

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
search/searcher/search_filter.go Adds DocumentMatchPool.Put() calls to recycle rejected document matches, preventing pool exhaustion
search/searcher/search_geoshape.go Moves dvVisitor closure outside the filter function loop to avoid per-document allocations; adds early exit optimization
search/searcher/search_geopolygon.go Extracts dvVisitor and rayIntersectsSegment closures outside the filter function to eliminate repeated allocations
search/searcher/search_geopointdistance.go Moves dvVisitor closure outside filter function and removes unused field parameter
search/searcher/search_geoboundingbox.go Extracts dvVisitor closure outside filter function and removes unused field parameter
search/query/boolean.go Adds DocumentMatchPool.Put() call to recycle refDoc when behind current document
index/scorch/snapshot_index.go Optimizes slice filtering to use in-place mutation instead of allocating new slices; adds fast path for empty updatedFields

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CascadingRadium CascadingRadium changed the title Geo-spatial queries performance optimization Improve performance of Geo-Spatial search Dec 22, 2025
@CascadingRadium CascadingRadium changed the title Improve performance of Geo-Spatial search Improve performance of Geospatial Search Dec 22, 2025
@CascadingRadium CascadingRadium changed the title Improve performance of Geospatial Search MB-59633: Improve performance of Geospatial Search Dec 26, 2025
@CascadingRadium CascadingRadium added the geoV2 Geospatial Search V2 label Dec 26, 2025
@CascadingRadium CascadingRadium removed the geoV2 Geospatial Search V2 label Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants