Skip to content

perf: FIT-1296: Consolidate extractNames into single tree traversal#9262

Open
bmartel wants to merge 1 commit intodevelopfrom
fb-fit-1296
Open

perf: FIT-1296: Consolidate extractNames into single tree traversal#9262
bmartel wants to merge 1 commit intodevelopfrom
fb-fit-1296

Conversation

@bmartel
Copy link
Contributor

@bmartel bmartel commented Jan 26, 2026

Problem

extractNames() in Tree.tsx traverses the config tree twice - once to build the names map and once to process toName bindings. For configs with 200+ tags, this doubles the initialization time.

Solution

Consolidate both traversals into a single pass:

  • Use Set for objectTypes lookup (O(1) instead of O(n) includes)
  • Collect control tags during traversal for toName processing afterward
  • Reduces traversal from 400+ node visits to 200+ for large configs

Files Changed

  • web/libs/editor/src/core/Tree.tsx

Previously extractNames() called traverseTree() twice - once to
build the names map and once to process toName bindings. This
doubles the traversal time for large configs.

Changes:
- Consolidate both traversals into a single pass
- Collect control tags during traversal for toName processing
- Use Set for objectTypes lookup (O(1) instead of O(n) includes)
- Process toName bindings in a simple loop after traversal

For configs with 200+ tags, this reduces traversal from 400+ node
visits to 200+.
@netlify
Copy link

netlify bot commented Jan 26, 2026

Deploy Preview for heartex-docs canceled.

Name Link
🔨 Latest commit 8cfe00e
🔍 Latest deploy log https://app.netlify.com/projects/heartex-docs/deploys/6977b0017cc9ec0008333c2f

@netlify
Copy link

netlify bot commented Jan 26, 2026

Deploy Preview for label-studio-docs-new-theme canceled.

Name Link
🔨 Latest commit 8cfe00e
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-docs-new-theme/deploys/6977b001f21e8b00086a5af9

@netlify
Copy link

netlify bot commented Jan 26, 2026

Deploy Preview for label-studio-storybook ready!

Name Link
🔨 Latest commit 8cfe00e
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-storybook/deploys/6977b001f66cfe00081fa78f
😎 Deploy Preview https://deploy-preview-9262--label-studio-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 92.30769% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.69%. Comparing base (609d271) to head (8cfe00e).
⚠️ Report is 8 commits behind head on develop.

Files with missing lines Patch % Lines
web/libs/editor/src/core/Tree.tsx 92.30% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (609d271) and HEAD (8cfe00e). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (609d271) HEAD (8cfe00e)
pytests 1 0
Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #9262       +/-   ##
============================================
- Coverage    66.82%   56.69%   -10.13%     
============================================
  Files          830      561      -269     
  Lines        64879    40560    -24319     
  Branches     10971    11011       +40     
============================================
- Hits         43355    22997    -20358     
+ Misses       21520    17559     -3961     
  Partials         4        4               
Flag Coverage Δ
lsf-e2e 49.76% <53.84%> (-2.24%) ⬇️
lsf-integration 48.28% <92.30%> (+0.01%) ⬆️
lsf-unit 8.85% <0.00%> (-0.02%) ⬇️
pytests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@netlify
Copy link

netlify bot commented Jan 26, 2026

Deploy Preview for label-studio-playground ready!

Name Link
🔨 Latest commit 8cfe00e
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-playground/deploys/6977b0016a6f8b00080dbc87
😎 Deploy Preview https://deploy-preview-9262--label-studio-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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