-
Notifications
You must be signed in to change notification settings - Fork 3.4k
perf: FIT-1330: Fix O(n^2) config validation by using Map and Set lookups #9299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
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 Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9299 +/- ##
============================================
- Coverage 66.82% 56.04% -10.78%
============================================
Files 830 575 -255
Lines 64879 41460 -23419
Branches 10971 11465 +494
============================================
- Hits 43355 23238 -20117
+ Misses 21520 18218 -3302
Partials 4 4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
✅ Deploy Preview for label-studio-docs-new-theme ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for label-studio-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for label-studio-playground ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for heartex-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Problem
validateToNameTag()inConfigValidator.jsiterates 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
Map<name, tag>during validation setupvalidateToNameTag()now accepts this map for O(1) lookupsvalidateParentTag()andvalidateVisualTags()with similar techniquesFiles Changed
web/libs/editor/src/core/DataValidator/ConfigValidator.jsJira
FIT-1330
Made with Cursor