Skip to content

MOD-17912 Improve get_index performance (backport to 8.6) - #1634

Merged
AvivDavid23 merged 1 commit into
8.6from
cherry-pick-21568f4e-to-8.6
Aug 23, 2026
Merged

AvivDavid23 merged 1 commit into
8.6from
cherry-pick-21568f4e-to-8.6

Conversation

@AvivDavid23

@AvivDavid23 AvivDavid23 commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Backport of 21568f4 (#1631) to 8.6.

IValue::get_index was arr.iter().nth(index). ArrayIter implements only next(), so nth() falls back to the Iterator default and walks the array one element at a time; on a packed typed array each skipped element is also materialized into an owned IValue (a heap allocation). Reading a whole vector was therefore quadratic. This is the LLAPI getAt path RediSearch uses to ingest JSON vector fields — see RED-213492, where dim-1280 embeddings cost ~16 ms per vector and ~4,300 s of a ~4,500 s RDB load.

Adaptations for 8.6:

  • Test rewritten for this branch's SelectValue API: get_long/get_double/as_str are non-Option here, and JSONArrayType/get_array_type (V7 getArray, 8.8+) do not exist — the packed-array assertion uses ijson's ArraySliceRef::is_typed instead.

The fix itself is byte-identical to master; the ijson pinned here (5676f592) has the same ArraySliceRef variants.

Test plan

  • cargo test -p json_path — passes (8.6)
  • cargo fmt --check clean
  • CI

🤖 Generated with Claude Code


Note

Low Risk
Performance-only indexing change with tests; no auth, persistence, or API contract changes. Typed elements still allocate one owned IValue per lookup, matching prior iterator behavior.

Overview
Fixes quadratic IValue::get_index on packed typed arrays by indexing the backing ArraySliceRef instead of iter().nth(), which walked (and allocated) every skipped element.

This is the LLAPI getAt path used to ingest JSON vector fields. Heterogeneous arrays still borrow; typed numeric slices wrap a single owned IValue. Adds coverage for mixed, float, and long arrays, plus a non-array case. Also lists rust-analyzer in rust-toolchain.toml.

Reviewed by Cursor Bugbot for commit 2bd8c56. Bugbot is set up for automated code reviews on this repo. Configure here.

* MOD-17912 Improve `get_index` performance

* fmt

(cherry picked from commit 21568f4)
Test adapted to the 8.6 SelectValue API: get_long/get_double/as_str are
non-Option there, and JSONArrayType/get_array_type (V7 getArray, 8.8+) do not
exist, so the packed-array assertion uses ijson's ArraySliceRef::is_typed.
@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.59%. Comparing base (105ab5e) to head (2bd8c56).

Additional details and impacted files
@@           Coverage Diff           @@
##              8.6    #1634   +/-   ##
=======================================
  Coverage   77.59%   77.59%           
=======================================
  Files          15       15           
  Lines        3878     3879    +1     
=======================================
+ Hits         3009     3010    +1     
  Misses        869      869           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2bd8c56. Configure here.

Comment thread rust-toolchain.toml
@@ -1,2 +1,3 @@
[toolchain]
channel = "1.92"
components = ["rust-analyzer"] No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unrelated toolchain component added

Low Severity

components = ["rust-analyzer"] appears in this backport with no mention in the PR description or test plan. It is unrelated to the get_index fix and forces rustup to install an IDE LSP component whenever the toolchain syncs, which can slow or fail CI/dev installs without changing RedisJSON behavior.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2bd8c56. Configure here.

@AvivDavid23
AvivDavid23 merged commit 6eac4a3 into 8.6 Aug 23, 2026
60 of 61 checks passed
@AvivDavid23
AvivDavid23 deleted the cherry-pick-21568f4e-to-8.6 branch August 23, 2026 07:50
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.

1 participant