-
Notifications
You must be signed in to change notification settings - Fork 3.4k
perf: FIT-1329: Add caching for MST union types to avoid recreation #9298
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
Large labeling configs create many identical union types, each requiring expensive MST type construction. This adds multi-level caching to avoid recreating identical types. Changes: - Cache unionArray() results by sorted array key - Cache oneOfTags union types in _oneOf() - Cache unionTag() enumeration types - Cache tagsTypes() frozen types - Cache allModelsTypes() result (invalidates when Registry changes) - Convert O(n) arr.find()/includes() to O(1) Set.has() lookups - Add Set-based lookups in getParentOfTypeString/getParentTagOfTypeString With 200+ tags, this dramatically reduces tree building time by avoiding redundant type construction and linear searches.
✅ Deploy Preview for heartex-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ 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-playground 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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9298 +/- ##
============================================
- Coverage 66.82% 55.88% -10.95%
============================================
Files 830 575 -255
Lines 64879 41500 -23379
Branches 10971 11473 +502
============================================
- Hits 43355 23192 -20163
+ Misses 21520 18304 -3216
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:
|
Problem
unionArray(),unionTag(), andtagsTypes()create new MST union types on every call. During tree building with large configs, identical unions are recreated thousands of times.Solution
Add module-level caching:
unionArray()results by array contentsunionTag()results by tag typetagsTypes()resultsgetParentOfTypeString()andgetParentTagOfTypeString()to use Set lookupsFiles Changed
web/libs/editor/src/core/Types.jsJira
FIT-1329
Made with Cursor