--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/ezwpu2bqbv7zau2uzqesynuaxpi7irjg2u2ojsshuktmjjkg4u%40oy2xauimoxhn.
On Thu, Nov 27, 2025 at 03:46:37PM -0500, Jeremy Roman wrote:
> Curious about the motivation here, beyond switching from a hashtable to an
> array. Is the tracing cost that large?
We won ~70 kB of APK size, and 2%+ style performance on some pages. The
tracing cost should be roughly the same. (The project was finished last
week, and Supplementable is gone.)
> It seems like it forces a lot more boilerplate in very central classes and
> may make some of them considerably larger because they need space for
> members, some of which are nearly always absent.
Are you asking about the change from a hashtable to an array, or the change
from an array to explicit members?
The size (which changed from hashtable to array) diff was generally small,
and often negative. The hash table was not free, even less so if you had
1–2 members set and needed to go to a heap allocation. In any case, unused
padding in these objects is probably much more significant if we care about
the RAM usage in the 2–3 Document objects we have in a typical renderer
process.
The boilerplate (which changed from array to explicit members) the same as
every other getter and setter, so normal Google/Chromium/Blink style.
I don't think there's been a push for trying to e.g. add macros to reduce
the boilerplate for a typical class, or for that matter, making the members
public? I mean, Supplementable comes purely from a desire to be able to embed
classes across layers, right?
> We have a similar concept outside Blink, in the form of
> base::SupportsUserData, for similar reasons (and we presumably wouldn't
> want WebContentsImpl to have members for every possible user data it might
> have.
There are valid reasons for having a sparse structure; in particular,
there are things like ElementRareData or NodeData where it genuinely saves
memory (and has seen different implementations as we've been tuning things).
But we have _lots_ of Elements, so the tradeoff is very different IMO.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
There's going to be a bunch of new getters and setters (and Members)
showing up, but they already existed through template magic; they are
just becoming visible now and given names and types (as opposed to being
string-keyed, which risks type confusion). We expect a tiny further
decrease in binary size and no significant change in compilation time.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/64st4nwknc2eq5vb7seb6ri5d6qb4l4nsqqpo7yvjhqhwmkepk%40hoayrxvm5v5k.
On Thu, Nov 27, 2025 at 04:42:58PM -0800, Daniel Cheng wrote:
> I think there's a balance to be struck here, and defaulting everything to a
> member of LocalDOMWindow/Document/LocalFrame/Navigator doesn't really seem
> like a maintainable approach, even if it's good for benchmarks.
To be clear, I considered the change to increase maintainability and
readability; benchmarks was only a part of the equation. Size decrease was a
nice bonus.
These members were there all along. It's just that they are more visible now
instead of being hidden away by compiler-generated code; I consider that a
good thing. We haven't created more layer violations -- if A is not allowed
to hold B, it shouldn't be allowed to do so through a Supplementable-like
system either IMO (and Supplementable had big warnings on it that it was
prone to type confusion if used with inheritance).
To put it another way: If you came to the current Blink code base with no
knowledge of the past, would anyone say that we should take a lot of the
members on ExecutionContext and stick them into an untyped hash table?
(If so, should e.g. OriginTrialContext have been part of this table,
which it wasn't before?) A lot of stuff was stuck into ExecutionContext's
Supplementable without even being in different layers, and I'm not sure what
distinguished them from the other Members that were there before. And I've
honestly never seen this pattern recommended anywhere else before; it looked
odd to me all along, which is why I invested time in removing it.
But as others have pointed out, it's water under the bridge. I guess it _is_
possible to revert it still if you wish, but it would be very conflict-prone.