Skip to content

Avoid per-result byte array allocation in EvaluateFilter#1571

Merged
hailangx merged 2 commits intohaixu/vector-filter-postprocessingfrom
copilot/sub-pr-1570
Feb 20, 2026
Merged

Avoid per-result byte array allocation in EvaluateFilter#1571
hailangx merged 2 commits intohaixu/vector-filter-postprocessingfrom
copilot/sub-pr-1570

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

EvaluateFilter was calling attributeJson.ToArray() on every filtered VSIM result before passing to JsonDocument.Parse, allocating a new byte[] per result on the hot path.

Change

Replace the allocating parse with a zero-copy parse using Utf8JsonReader + JsonDocument.ParseValue:

// Before
using var jsonDoc = JsonDocument.Parse(attributeJson.ToArray());

// After
var reader = new Utf8JsonReader(attributeJson);
using var jsonDoc = JsonDocument.ParseValue(ref reader);

Utf8JsonReader accepts ReadOnlySpan<byte> directly, so ParseValue parses in-place without materializing an intermediate array, eliminating the per-result GC allocation on the VSIM post-filter path.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

… with ParseValue

Co-authored-by: hailangx <3389245+hailangx@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix feedback on post-filter support for VSIM vector search results Avoid per-result byte array allocation in EvaluateFilter Feb 20, 2026
Copilot AI requested a review from hailangx February 20, 2026 01:09
@hailangx hailangx marked this pull request as ready for review February 20, 2026 01:09
@hailangx hailangx merged commit faad189 into haixu/vector-filter-postprocessing Feb 20, 2026
1 check passed
@hailangx hailangx deleted the copilot/sub-pr-1570 branch February 20, 2026 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants