Skip to content

fix(studio): eliminate per-render scans and mutation in data views#395

Open
aray12 wants to merge 1 commit into
mainfrom
astd-235-fix-per-render-scans-and-mutation-in-data-views
Open

fix(studio): eliminate per-render scans and mutation in data views#395
aray12 wants to merge 1 commit into
mainfrom
astd-235-fix-per-render-scans-and-mutation-in-data-views

Conversation

@aray12

@aray12 aray12 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor
  • Replace four sequential .find() passes in buildCustomModelsFilter with a single Map built in useMemo for O(1) lookups
  • Pre-build Map<modelId, Map<adapterName, Adapter>> so adapter lookups in rowActions and onRowClick are O(1) instead of scanning adapters on every row render
  • Replace in-place models.sort() in InferenceProviderDetailsSidePanel with useMemo(() => [...models].sort(), [models]) to avoid mutating the memoized array and re-sorting on every render

Summary by CodeRabbit

  • Bug Fixes

    • Fixed array mutation issue in model list display to ensure stable rendering.
  • Refactor

    • Optimized filter query construction and adapter mapping logic for improved performance in the custom models view.

- Replace four sequential `.find()` passes in `buildCustomModelsFilter`
  with a single `Map` built in `useMemo` for O(1) lookups
- Pre-build `Map<modelId, Map<adapterName, Adapter>>` so adapter lookups
  in `rowActions` and `onRowClick` are O(1) instead of scanning adapters
  on every row render
- Replace in-place `models.sort()` in `InferenceProviderDetailsSidePanel`
  with `useMemo(() => [...models].sort(), [models])` to avoid mutating the
  memoized array and re-sorting on every render

Fixes ASTD-235

Signed-off-by: Alex Ray <alray@nvidia.com>
@aray12 aray12 requested review from a team as code owners June 22, 2026 22:58
@github-actions github-actions Bot added the fix label Jun 22, 2026
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0fbc5c0a-afa6-491f-b68b-258eab2720d7

📥 Commits

Reviewing files that changed from the base of the PR and between 7ef7c77 and 8ed8048.

📒 Files selected for processing (2)
  • web/packages/studio/src/components/dataViews/CustomModelsDataView/index.tsx
  • web/packages/studio/src/routes/InferenceProvidersListRoute/InferenceProviderDetailsSidePanel/index.tsx

📝 Walkthrough

Walkthrough

Two refactors: CustomModelsDataView pre-indexes column filters into a Map and builds a nested adapterMap memo for O(1) adapter lookups, replacing repeated .find() calls. InferenceProviderDetailsSidePanel sorts a copy of the memoized models array instead of mutating it in place.

Changes

CustomModelsDataView: Map-based lookups

Layer / File(s) Summary
Pre-indexed filter Map and adapterMap memo
web/packages/studio/src/components/dataViews/CustomModelsDataView/index.tsx
filterQuery builds a Map from debouncedColumnFilters before extracting typed values; new adapterMap memo creates a nested Map<modelId, Map<adapterName, adapter>> from modelsResponse.
Adapter resolution in row actions and click handler
web/packages/studio/src/components/dataViews/CustomModelsDataView/index.tsx
"Model details" action and onRowClick now resolve adapters via adapterMap.get(id)?.get(name) instead of .find() on parentModel.adapters.

InferenceProviderDetailsSidePanel: sort mutation fix

Layer / File(s) Summary
Non-mutating sortedModels memo
web/packages/studio/src/routes/InferenceProvidersListRoute/InferenceProviderDetailsSidePanel/index.tsx
New sortedModels memo copies then sorts models; the "Served models" display joins sortedModels instead of calling models.sort() inline.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title accurately describes the main performance optimization focus: eliminating scans and mutations in data views components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch astd-235-fix-per-render-scans-and-mutation-in-data-views

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 21176/27762 76.3% 61.2%
Integration Tests 12216/26531 46.0% 19.5%

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