Skip to content

Commit 9a903a2

Browse files
author
bors-servo
authored
Auto merge of #3340 - gw3583:size-test, r=jrmuizel
Add unit test to detect size changes in critical structures. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3340) <!-- Reviewable:end -->
2 parents 1ad9b79 + aa16f4d commit 9a903a2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

webrender/src/prim_store.rs

+19
Original file line numberDiff line numberDiff line change
@@ -3717,3 +3717,22 @@ fn update_opacity_binding(
37173717
binding.current
37183718
}
37193719
}
3720+
3721+
#[test]
3722+
#[cfg(target_os = "linux")]
3723+
fn test_struct_sizes() {
3724+
// The sizes of these structures are critical for performance on a number of
3725+
// talos stress tests. If you get a failure here on CI, there's two possibilities:
3726+
// (a) You made a structure smaller than it currently is. Great work! Update the
3727+
// test expectations and move on.
3728+
// (b) You made a structure larger. This is not necessarily a problem, but should only
3729+
// be done with care, and after checking if talos performance regresses badly.
3730+
assert_eq!(mem::size_of::<PrimitiveContainer>(), 256, "PrimitiveContainer size changed");
3731+
assert_eq!(mem::size_of::<PrimitiveInstance>(), 120, "PrimitiveInstance size changed");
3732+
assert_eq!(mem::size_of::<PrimitiveInstanceKind>(), 16, "PrimitiveInstanceKind size changed");
3733+
assert_eq!(mem::size_of::<PrimitiveTemplate>(), 176, "PrimitiveTemplate size changed");
3734+
assert_eq!(mem::size_of::<PrimitiveTemplateKind>(), 112, "PrimitiveTemplateKind size changed");
3735+
assert_eq!(mem::size_of::<PrimitiveKey>(), 152, "PrimitiveKey size changed");
3736+
assert_eq!(mem::size_of::<PrimitiveKeyKind>(), 112, "PrimitiveKeyKind size changed");
3737+
assert_eq!(mem::size_of::<Primitive>(), 280, "Primitive size changed");
3738+
}

0 commit comments

Comments
 (0)