Skip to content

Conversation

@TonytheMacaroni
Copy link
Contributor

This PR changes StyleImpl.BuilderImpl to use a DecorationMap instead of an EnumMap for decorations. Awhile ago, I noticed that converting the DecorationMap used in Style to the EnumMap used in the builder took up a substantial portion of time when merging styles. Comparing using the ComponentCompactionBenchmark.moreComplex benchmark:

Before

Benchmark                                           Mode      Cnt     Score   Error  Units
ComponentCompactionBenchmark.moreComplex          sample  7851094     2.041 ± 0.007  us/op
ComponentCompactionBenchmark.moreComplex:p0.00    sample              1.700          us/op
ComponentCompactionBenchmark.moreComplex:p0.50    sample              2.000          us/op
ComponentCompactionBenchmark.moreComplex:p0.90    sample              2.100          us/op
ComponentCompactionBenchmark.moreComplex:p0.95    sample              2.100          us/op
ComponentCompactionBenchmark.moreComplex:p0.99    sample              2.600          us/op
ComponentCompactionBenchmark.moreComplex:p0.999   sample              3.900          us/op
ComponentCompactionBenchmark.moreComplex:p0.9999  sample             56.000          us/op
ComponentCompactionBenchmark.moreComplex:p1.00    sample           1206.272          us/op

After

Benchmark                                           Mode      Cnt     Score   Error  Units
ComponentCompactionBenchmark.moreComplex          sample  6582923     0.636 ± 0.006  us/op
ComponentCompactionBenchmark.moreComplex:p0.00    sample              0.500          us/op
ComponentCompactionBenchmark.moreComplex:p0.50    sample              0.600          us/op
ComponentCompactionBenchmark.moreComplex:p0.90    sample              0.700          us/op
ComponentCompactionBenchmark.moreComplex:p0.95    sample              0.700          us/op
ComponentCompactionBenchmark.moreComplex:p0.99    sample              0.800          us/op
ComponentCompactionBenchmark.moreComplex:p0.999   sample              1.600          us/op
ComponentCompactionBenchmark.moreComplex:p0.9999  sample             17.668          us/op
ComponentCompactionBenchmark.moreComplex:p1.00    sample           1267.712          us/op

Copy link
Member

@kezz kezz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the PR :D

@zml2008 zml2008 self-assigned this Apr 13, 2025
@zml2008 zml2008 added this pull request to the merge queue Apr 13, 2025
Merged via the queue into PaperMC:main/4 with commit 0b07e19 Apr 13, 2025
3 checks passed
@TonytheMacaroni TonytheMacaroni deleted the style-builder-optimization branch May 4, 2025 21:08
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.

3 participants