[compile-time experiment] Dedupe repeated per-longhand code in generated properties.rs - #4
Draft
nicoburns wants to merge 1 commit into
Draft
[compile-time experiment] Dedupe repeated per-longhand code in generated properties.rs#4nicoburns wants to merge 1 commit into
nicoburns wants to merge 1 commit into
Conversation
…red helpers Compile-time experiment: deduplicate the per-property cascade glue, import boilerplate, and vector-longhand list machinery emitted by the mako templates into shared handwritten helpers.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Compile-time experiment: shrink the mako-generated
properties.rsby factoring code that was emitted once per longhand into shared handwritten helpers, and measure the effect on build times.What was deduplicated (all in
helpers.mako.rs'slonghand()/shorthand()defs):CSSWideKeywordmatch in eachcascade_propertyis replaced by one call to a new sharedPropertyDeclaration::cascade_simple_wide_keyword(context, id, is_inherited, inherit_or_reset, reinherit_with_zoom)instyle/properties/mod.rs. Per-property behavior (inherit vs reset, zoom-dependent re-inheritance, debug asserts,for_non_inherited_property) is passed via fn pointers/flags. Zoom-dependent longhands emit a tiny localreinherit_with_zoomfn.uselines per longhand module (and ~8 per shorthand module) become a single glob import of newlonghand_prelude/shorthand_preludemodules.OwnedList<T>struct +Animate/ComputeSquaredDistance/ToAnimatedZero/Fromimpls emitted for each vector longhand are replaced by three shared generic types in newstyle/properties/longhand_lists.rs(NonEmptyCommaList,EmptyCommaList,EmptySpaceList), chosen per property in the template. The shared-ArcSliceComputedListpath (onlytext-shadowin servo) stays templated.from_gecko_keyword(already#[cfg(feature = "gecko")]) is now only emitted for gecko-engine builds.Note: the shared list types now carry
Animate/ToAnimatedZeroblanket impls for anyTmeeting the bounds, whereas previously those impls only existed for longhands with a vectoranimation_type. This is a strict superset (no existing behavior changes).Measurements
2-core linux VM, default (
servo) features, protocol: coldrm -rf target && cargo build --timings;cargo checkwarm, thentouch style/lib.rs && time cargo check(both with incremental on and withCARGO_INCREMENTAL=0).properties.rslinescargo build(total)stylounit time (cargo-timings)touch style/lib.rs+cargo check(incremental)CARGO_INCREMENTAL=0Conclusion: the generated file shrinks by ~11%, but compile times are unchanged within noise. The deduplicated code was cheap-to-compile boilerplate; stylo's compile time appears dominated by the remaining giant match-based dispatch (
PropertyDeclaration/AnimationValue/LonghandIdimpls), derives, and the per-field style-struct accessors, which are out of scope here (table-driven dispatch is being explored separately).Testing
cargo check: clean, no new warnings.cargo test --workspace --exclude stylo: all pass.cargo test -p stylofails to compile onmainas well (pre-existingPseudoElement::MozRubyText/FirstLineerrors inselector_parser.rstests), unchanged by this PR.Link to Devin session: https://app.devin.ai/sessions/4acc993f357a4cd9ac8e17704aa71ed6
Requested by: @nicoburns