Truly independent web browser
LibWeb: Give each run cache slot a cache line of its own
Aliaksandr Kalenik7dd1d0353764
diff --git a/Libraries/LibWeb/Rust/Cargo.toml b/Libraries/LibWeb/Rust/Cargo.tomlindex aadf58988ef..07cd9444e84 100644--- a/Libraries/LibWeb/Rust/Cargo.toml+++ b/Libraries/LibWeb/Rust/Cargo.toml@@ -25,7 +25,7 @@ libweb_html_tokenizer = { path = "../HTML/Parser/Rust" }rayon = "1.12"rustc-demangle = "0.1"serde_json = { version = "1", features = ["float_roundtrip", "preserve_order"] }-smallvec = { version = "1.16.3", features = ["const_generics"] }+smallvec = { version = "1.16.3", features = ["const_generics", "union"] }[build-dependencies]cbindgen = "0.29"diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rsindex 386f2922bf9..20049328c91 100644--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs@@ -474,6 +474,9 @@ impl StoredEntrySummary {type EarlierEntriesOfBox = smallvec::SmallVec<[std::sync::Arc<FcRunCacheEntry>; EARLIER_ENTRIES_PER_BOX]>;+// NB: Each slot takes one cache line of its own, so storing a box's entries never dirties the line of a neighbouring+// box's slot, which another thread may be reading.+#[repr(align(64))]#[derive(Clone, Default)]struct FcRunCacheSlot {latest: Option<std::sync::Arc<FcRunCacheEntry>>,@@ -483,6 +486,8 @@ struct FcRunCacheSlot {earlier: EarlierEntriesOfBox,}+const _: () = assert!(size_of::<FcRunCacheSlot>() == 64);+impl FcRunCacheSlot {fn refresh_summaries(&mut self) {self.committed_summary = StoredEntrySummary::of(self.committed.as_deref());