Skip to content

Conversation

@Calme1709
Copy link
Contributor

A collection of optimizations to StyleComputer::compute_properties which collectively reduce runtime from ~31.5% to ~17.3% when loading https://en.wikipedia.org/wiki/2023_in_American_television - see individual commits for details.

@Calme1709 Calme1709 requested a review from AtkinsSJ as a code owner January 27, 2026 21:35
The computation context used is the main thing distinguishing the
computation of font/non-font properties so having a generic method to
handle this will allow us to consolidate logic between the two.
Having these numbered doesn't add anything and makes diffs ugly when we
add/remove a step
Previously we computed font properties separately from other properties
for two reasons:
  1) These font properties were computed using a different length
     resolution context than the rest of the properties.
  2) These properties were required to be computed before creating the
     length resolution context for the rest of the properties.

The first issue was solved in the previous commit by introducing a
generic method to get the computation context for a property, and
the second is solved in this commit by computing properties in the
required order.

This simplifies the code a bit and opens up some opportunities for
optimization.
In a future commit we will update `compute_properties` to avoid calling
`compute_property_values` but we still need to store this value
We can avoid some overhead by computing the values immediately instead
of setting them within `ComputedProperties` and then calling
`compute_property_values`
There are cases where we can skip the property value computation process
because we know that the computed value will be equal to the specified
value
Previously we were doing this multiple times per property which was
quite expensive
When we initialize `ComputedProperties` all flags are initially set to
false so we only need to update them if they are true
This saves us having to access the HashMap in the common case there is
no cascaded property
@Calme1709 Calme1709 force-pushed the property-computation-optimizations branch from c71ce64 to 557c820 Compare January 27, 2026 22:40
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.

1 participant