Skip to content

perf: FIT-1330: Fix O(n^2) config validation by using Map and Set lookups#9299

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

perf: FIT-1330: Fix O(n^2) config validation by using Map and Set lookups#9299
bmartel wants to merge 1 commit intodevelopfrom
fb-fit-1330

Conversation

@bmartel
Copy link
Contributor

@bmartel bmartel commented Jan 30, 2026

Problem

validateToNameTag() in ConfigValidator.js iterates over all tags to find matching names, creating O(n^2) complexity when validating toName bindings. For 200+ tags, this causes noticeable initialization delays.

Solution

  • Pre-build a Map<name, tag> during validation setup
  • validateToNameTag() now accepts this map for O(1) lookups
  • Optimize validateParentTag() and validateVisualTags() with similar techniques
  • Reduces validation from O(n^2) to O(n) for large configs

Files Changed

  • web/libs/editor/src/core/DataValidator/ConfigValidator.js

Jira

FIT-1330

Made with Cursor

The config validator was using O(n) flatTree.find() inside a loop,
resulting in O(n²) complexity. With large configs (200+ tags), this
caused noticeable delays during config validation.

Changes:
- validateToNameTag: Pre-build name->element Map for O(1) lookup
- validateParentTag: Convert parentTypes to Set for O(1) has() check
- validateVisualTags: Use module-level Set instead of inline array

This reduces validation complexity from O(n²) to O(n).
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...s/editor/src/core/DataValidator/ConfigValidator.js 92.85% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@netlify
Copy link

netlify bot commented Jan 30, 2026

Deploy Preview for label-studio-docs-new-theme ready!

Name Link
🔨 Latest commit f0b657b
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-docs-new-theme/deploys/697c14adf95d20000804e7d0
😎 Deploy Preview https://deploy-preview-9299--label-studio-docs-new-theme.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.

@netlify
Copy link

netlify bot commented Jan 30, 2026

Deploy Preview for label-studio-storybook ready!

Name Link
🔨 Latest commit f0b657b
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-storybook/deploys/697c14ad1cb4390008e68259
😎 Deploy Preview https://deploy-preview-9299--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.

@netlify
Copy link

netlify bot commented Jan 30, 2026

Deploy Preview for label-studio-playground ready!

Name Link
🔨 Latest commit f0b657b
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-playground/deploys/697c14ad30915e000893d9d7
😎 Deploy Preview https://deploy-preview-9299--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.

@netlify
Copy link

netlify bot commented Jan 30, 2026

Deploy Preview for heartex-docs ready!

Name Link
🔨 Latest commit f0b657b
🔍 Latest deploy log https://app.netlify.com/projects/heartex-docs/deploys/697c14ad02a68f0008db9ae4
😎 Deploy Preview https://deploy-preview-9299--heartex-docs.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.

@robot-ci-heartex
Copy link
Collaborator

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants