Skip to content
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

Improve ADT validators' performance #1573

Merged
merged 13 commits into from
Mar 11, 2025
Merged

Improve ADT validators' performance #1573

merged 13 commits into from
Mar 11, 2025

Conversation

kubukoz
Copy link
Member

@kubukoz kubukoz commented Aug 8, 2024

Closes #1319. Also actually prevents ADTs from being mixins, which shouldn't have been possible in the first place.

Tested on a model with 92k shapes (including 78k members) using 288 @adtMembers and 33 @adts.

Before: 11+ seconds

image

The original implementation was spending most its time in the getReferences method:

image

which had linear time complexity on the number of member shapes in the model, which let's be honest - are the most common type of shape by far in any realistic model.

After: <200ms

image

In the new implementation, there's no sharing of code (the validation patterns are different, so I didn't think it's worth sharing), and we utilize things like getShapesWithTrait and selectors to get better perf. Probably linear in the number of shapes annotated with each of the ADT traits.

PR Checklist (not all items are relevant to all PRs)

  • Added unit-tests (for runtime code)
  • Added bootstrapped code + smoke tests (when the rendering logic is modified)
  • Added build-plugins integration tests (when reflection loading is required at codegen-time)
  • Added alloy compliance tests (when simpleRestJson protocol behaviour is expanded/updated)
  • Updated dynamic module to match generated-code behaviour
  • Added documentation
  • Updated changelog

@kubukoz
Copy link
Member Author

kubukoz commented Mar 6, 2025

So far, so good - AdtTraitValidator is all but gone from the flame graph.

image

Baseline: #1319 (comment)

@kubukoz kubukoz changed the title wip adt validator perf Improve ADT validator performance Mar 6, 2025
@kubukoz
Copy link
Member Author

kubukoz commented Mar 6, 2025

Got the AdtMemberTraitValidator too.

image

@kubukoz kubukoz changed the title Improve ADT validator performance Improve ADT validators' performance Mar 6, 2025
@kubukoz kubukoz marked this pull request as ready for review March 6, 2025 20:15
@kubukoz kubukoz merged commit d9d20f7 into series/0.18 Mar 11, 2025
11 checks passed
@kubukoz kubukoz deleted the adt-validator-perf branch March 11, 2025 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AdtMemberTraitValidator is a bit slow
2 participants