Type Alias style::sharing::SharingCache

source ·
type SharingCache<E> = SharingCacheBase<StyleSharingCandidate<E>>;
Expand description

Style sharing caches are are large allocations, so we store them in thread-local storage such that they can be reused across style traversals. Ideally, we’d just stack-allocate these buffers with uninitialized memory, but right now rustc can’t avoid memmoving the entire cache during setup, which gets very expensive. See issues like [1] and [2].

Given that the cache stores entries of type TElement, we transmute to usize before storing in TLS. This is safe as long as we make sure to empty the cache before we let it go.

[1] https://github.com/rust-lang/rust/issues/42763 [2] https://github.com/rust-lang/rust/issues/13707

Aliased Type§

struct SharingCache<E> {
    entries: LRUCache<StyleSharingCandidate<E>, 32>,
}

Fields§

§entries: LRUCache<StyleSharingCandidate<E>, 32>