Store the ElementRareDataVector pointers in AdditionalBytes. [chromium/src : main]

0 views
Skip to first unread message

Steinar H Gunderson (Gerrit)

unread,
Jan 16, 2026, 9:25:57 AM (yesterday) Jan 16
to chrom...@appspot.gserviceaccount.com, Menard, Alexis, chromium...@chromium.org, Xida Chen, apavlo...@chromium.org, blink-re...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org
Attention needed from Joey Arhar

Steinar H Gunderson added 1 comment

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Steinar H Gunderson . resolved

I'm aware that this feels a bit complicated; I'm open to ideas for how to improve the API if you can think of anything. I thought of maybe taking in a ElementRareData*& so that the setters could just update the pointers themselves, but Node stores the member compressed, so then they'd have to take in Member<ElementRareData>& instead and that didn't feel ideal…

Open in Gerrit

Related details

Attention is currently required from:
  • Joey Arhar
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I9c3221ff200aa7a7c1cb0a78c84785cc2baf07ec
Gerrit-Change-Number: 7486769
Gerrit-PatchSet: 2
Gerrit-Owner: Steinar H Gunderson <se...@chromium.org>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-CC: Xida Chen <xida...@chromium.org>
Gerrit-Attention: Joey Arhar <jar...@chromium.org>
Gerrit-Comment-Date: Fri, 16 Jan 2026 14:25:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Joey Arhar (Gerrit)

unread,
Jan 16, 2026, 12:54:49 PM (24 hours ago) Jan 16
to Steinar H Gunderson, chrom...@appspot.gserviceaccount.com, Menard, Alexis, chromium...@chromium.org, Xida Chen, apavlo...@chromium.org, blink-re...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org
Attention needed from Steinar H Gunderson

Joey Arhar voted and added 2 comments

Votes added by Joey Arhar

Code-Review+1

2 comments

Patchset-level comments
File-level comment, Patchset 2:
Steinar H Gunderson . unresolved

I'm aware that this feels a bit complicated; I'm open to ideas for how to improve the API if you can think of anything. I thought of maybe taking in a ElementRareData*& so that the setters could just update the pointers themselves, but Node stores the member compressed, so then they'd have to take in Member<ElementRareData>& instead and that didn't feel ideal…

Joey Arhar

Not using UNSAFE_BUFFERS would be ideal, but I did enjoy seeing memcpy() for the first time since school :)

I like how UnpackAndRefresh abstracts away a lot of the std::pair ugliness. I wonder if we should also try to further abstract away how some fields have the std::pair listed in the header and some don't - it might make it confusing to add a new field later, but I guess its probably fine as-is.

File third_party/blink/renderer/core/dom/element_rare_data_vector.h
Line 587, Patchset 3 (Latest):#endif
Joey Arhar . unresolved

So this copies the memory of the members of the old ElementRareDataVector into the new ElementRareDataVector, right? And we don't need to call constructors or destructors on all those members?

Open in Gerrit

Related details

Attention is currently required from:
  • Steinar H Gunderson
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I9c3221ff200aa7a7c1cb0a78c84785cc2baf07ec
Gerrit-Change-Number: 7486769
Gerrit-PatchSet: 3
Gerrit-Owner: Steinar H Gunderson <se...@chromium.org>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-CC: Xida Chen <xida...@chromium.org>
Gerrit-Attention: Steinar H Gunderson <se...@chromium.org>
Gerrit-Comment-Date: Fri, 16 Jan 2026 17:54:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Steinar H Gunderson <se...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Steinar H Gunderson (Gerrit)

unread,
Jan 16, 2026, 1:00:37 PM (24 hours ago) Jan 16
to chrom...@appspot.gserviceaccount.com, Menard, Alexis, chromium...@chromium.org, Xida Chen, apavlo...@chromium.org, blink-re...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org
Attention needed from Joey Arhar

Steinar H Gunderson added 2 comments

Steinar H Gunderson . resolved

I see we're failing some tests, so I'll need to figure out in which patch that starts happening. Hopefully, it's nothing large.

File third_party/blink/renderer/core/dom/element_rare_data_vector.h
Joey Arhar . unresolved

So this copies the memory of the members of the old ElementRareDataVector into the new ElementRareDataVector, right? And we don't need to call constructors or destructors on all those members?

Steinar H Gunderson

Indeed; it copies them over, but note that this is the Member<>, not the element itself. So we're just copying pointers.

Now, normally, you cannot copy Member<> with memcpy; there needs to be a barrier in case the object is in the middle of a trace from another thread. But constructors are different, since the object cannot be referenced from anywhere (nothing knows its address until the constructor returns). So there it's safe.

Given that this move constructor is called pretty rarely and thus isn't all that performance-sensitive, and mlippautz pointed out that VectorTypeOperations::Move is probably applicable here, so I'll probably switch to that for some less subtlety.

Open in Gerrit

Related details

Attention is currently required from:
  • Joey Arhar
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I9c3221ff200aa7a7c1cb0a78c84785cc2baf07ec
Gerrit-Change-Number: 7486769
Gerrit-PatchSet: 3
Gerrit-Owner: Steinar H Gunderson <se...@chromium.org>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-CC: Xida Chen <xida...@chromium.org>
Gerrit-Attention: Joey Arhar <jar...@chromium.org>
Gerrit-Comment-Date: Fri, 16 Jan 2026 18:00:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Joey Arhar <jar...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Steinar H Gunderson (Gerrit)

unread,
Jan 16, 2026, 1:01:39 PM (24 hours ago) Jan 16
to chrom...@appspot.gserviceaccount.com, Menard, Alexis, chromium...@chromium.org, Xida Chen, apavlo...@chromium.org, blink-re...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org
Attention needed from Joey Arhar

Steinar H Gunderson added 1 comment

Patchset-level comments
Steinar H Gunderson . unresolved

I'm aware that this feels a bit complicated; I'm open to ideas for how to improve the API if you can think of anything. I thought of maybe taking in a ElementRareData*& so that the setters could just update the pointers themselves, but Node stores the member compressed, so then they'd have to take in Member<ElementRareData>& instead and that didn't feel ideal…

Joey Arhar

Not using UNSAFE_BUFFERS would be ideal, but I did enjoy seeing memcpy() for the first time since school :)

I like how UnpackAndRefresh abstracts away a lot of the std::pair ugliness. I wonder if we should also try to further abstract away how some fields have the std::pair listed in the header and some don't - it might make it confusing to add a new field later, but I guess its probably fine as-is.

Steinar H Gunderson

Hm, can you point out some examples of the difference? Generally Ensure\*() needs the pair and Set\*() doesn't, but I could have forgotten something?

Gerrit-Comment-Date: Fri, 16 Jan 2026 18:01:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Joey Arhar <jar...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Joey Arhar (Gerrit)

unread,
Jan 16, 2026, 1:11:18 PM (24 hours ago) Jan 16
to Steinar H Gunderson, chrom...@appspot.gserviceaccount.com, Menard, Alexis, chromium...@chromium.org, Xida Chen, apavlo...@chromium.org, blink-re...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org
Attention needed from Steinar H Gunderson

Joey Arhar added 2 comments

Patchset-level comments
Steinar H Gunderson . unresolved

I'm aware that this feels a bit complicated; I'm open to ideas for how to improve the API if you can think of anything. I thought of maybe taking in a ElementRareData*& so that the setters could just update the pointers themselves, but Node stores the member compressed, so then they'd have to take in Member<ElementRareData>& instead and that didn't feel ideal…

Joey Arhar

Not using UNSAFE_BUFFERS would be ideal, but I did enjoy seeing memcpy() for the first time since school :)

I like how UnpackAndRefresh abstracts away a lot of the std::pair ugliness. I wonder if we should also try to further abstract away how some fields have the std::pair listed in the header and some don't - it might make it confusing to add a new field later, but I guess its probably fine as-is.

Steinar H Gunderson

Hm, can you point out some examples of the difference? Generally Ensure\*() needs the pair and Set\*() doesn't, but I could have forgotten something?

Joey Arhar

Yes Ensure needs the pair, but it now it feels like it has more boilerplate and loses the [[nodiscard]] on the new ElementRareData, right? I guess maybe there isn't really much more boilerplate other than writing out the std::pair type.

I guess its fine though, the "Ensure" pattern is still very useful for a lot of fields.

File third_party/blink/renderer/core/dom/element_rare_data_vector.h
Joey Arhar . resolved

So this copies the memory of the members of the old ElementRareDataVector into the new ElementRareDataVector, right? And we don't need to call constructors or destructors on all those members?

Steinar H Gunderson

Indeed; it copies them over, but note that this is the Member<>, not the element itself. So we're just copying pointers.

Now, normally, you cannot copy Member<> with memcpy; there needs to be a barrier in case the object is in the middle of a trace from another thread. But constructors are different, since the object cannot be referenced from anywhere (nothing knows its address until the constructor returns). So there it's safe.

Given that this move constructor is called pretty rarely and thus isn't all that performance-sensitive, and mlippautz pointed out that VectorTypeOperations::Move is probably applicable here, so I'll probably switch to that for some less subtlety.

Joey Arhar

nice!

Open in Gerrit

Related details

Attention is currently required from:
  • Steinar H Gunderson
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I9c3221ff200aa7a7c1cb0a78c84785cc2baf07ec
Gerrit-Change-Number: 7486769
Gerrit-PatchSet: 3
Gerrit-Owner: Steinar H Gunderson <se...@chromium.org>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-CC: Xida Chen <xida...@chromium.org>
Gerrit-Attention: Steinar H Gunderson <se...@chromium.org>
Gerrit-Comment-Date: Fri, 16 Jan 2026 18:11:07 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Steinar H Gunderson (Gerrit)

unread,
Jan 16, 2026, 5:19:19 PM (19 hours ago) Jan 16
to chrom...@appspot.gserviceaccount.com, Menard, Alexis, chromium...@chromium.org, Xida Chen, apavlo...@chromium.org, blink-re...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org
Attention needed from Joey Arhar

Steinar H Gunderson added 2 comments

Patchset-level comments
Steinar H Gunderson . unresolved

I'm aware that this feels a bit complicated; I'm open to ideas for how to improve the API if you can think of anything. I thought of maybe taking in a ElementRareData*& so that the setters could just update the pointers themselves, but Node stores the member compressed, so then they'd have to take in Member<ElementRareData>& instead and that didn't feel ideal…

Joey Arhar

Not using UNSAFE_BUFFERS would be ideal, but I did enjoy seeing memcpy() for the first time since school :)

I like how UnpackAndRefresh abstracts away a lot of the std::pair ugliness. I wonder if we should also try to further abstract away how some fields have the std::pair listed in the header and some don't - it might make it confusing to add a new field later, but I guess its probably fine as-is.

Steinar H Gunderson

Hm, can you point out some examples of the difference? Generally Ensure\*() needs the pair and Set\*() doesn't, but I could have forgotten something?

Joey Arhar

Yes Ensure needs the pair, but it now it feels like it has more boilerplate and loses the [[nodiscard]] on the new ElementRareData, right? I guess maybe there isn't really much more boilerplate other than writing out the std::pair type.

I guess its fine though, the "Ensure" pattern is still very useful for a lot of fields.

Steinar H Gunderson

You're right, there's a number of Ensure\*() that have missing [[nodiscard]]. OTOH we don't really fear that people are ignoring the result value, we mostly fear that they are ignoring the second half of it (and nodiscard doesn't help us there). Do you have any good suggestions?

And yes, it's really verbose. It's possible that we could wrap it in some kind of struct where the only way to get out the result is to also feed it an ElementRareDataVector\*& to update, but that sounds… weird.

Steinar H Gunderson . resolved

Uploading to rerun tests, I fixed a number of (thankfully local) issues but not sure if I got them all.

Open in Gerrit

Related details

Attention is currently required from:
  • Joey Arhar
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I9c3221ff200aa7a7c1cb0a78c84785cc2baf07ec
Gerrit-Change-Number: 7486769
Gerrit-PatchSet: 3
Gerrit-Owner: Steinar H Gunderson <se...@chromium.org>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-CC: Xida Chen <xida...@chromium.org>
Gerrit-Attention: Joey Arhar <jar...@chromium.org>
Gerrit-Comment-Date: Fri, 16 Jan 2026 22:18:53 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Joey Arhar (Gerrit)

unread,
Jan 16, 2026, 7:43:12 PM (17 hours ago) Jan 16
to Steinar H Gunderson, chrom...@appspot.gserviceaccount.com, Menard, Alexis, chromium...@chromium.org, Xida Chen, apavlo...@chromium.org, blink-re...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org
Attention needed from Steinar H Gunderson

Joey Arhar voted and added 1 comment

Votes added by Joey Arhar

Code-Review+1

1 comment

Patchset-level comments
Steinar H Gunderson . unresolved

I'm aware that this feels a bit complicated; I'm open to ideas for how to improve the API if you can think of anything. I thought of maybe taking in a ElementRareData*& so that the setters could just update the pointers themselves, but Node stores the member compressed, so then they'd have to take in Member<ElementRareData>& instead and that didn't feel ideal…

Joey Arhar

Not using UNSAFE_BUFFERS would be ideal, but I did enjoy seeing memcpy() for the first time since school :)

I like how UnpackAndRefresh abstracts away a lot of the std::pair ugliness. I wonder if we should also try to further abstract away how some fields have the std::pair listed in the header and some don't - it might make it confusing to add a new field later, but I guess its probably fine as-is.

Steinar H Gunderson

Hm, can you point out some examples of the difference? Generally Ensure\*() needs the pair and Set\*() doesn't, but I could have forgotten something?

Joey Arhar

Yes Ensure needs the pair, but it now it feels like it has more boilerplate and loses the [[nodiscard]] on the new ElementRareData, right? I guess maybe there isn't really much more boilerplate other than writing out the std::pair type.

I guess its fine though, the "Ensure" pattern is still very useful for a lot of fields.

Steinar H Gunderson

You're right, there's a number of Ensure\*() that have missing [[nodiscard]]. OTOH we don't really fear that people are ignoring the result value, we mostly fear that they are ignoring the second half of it (and nodiscard doesn't help us there). Do you have any good suggestions?

And yes, it's really verbose. It's possible that we could wrap it in some kind of struct where the only way to get out the result is to also feed it an ElementRareDataVector\*& to update, but that sounds… weird.

Joey Arhar

If there was a way to use templates to minimize the amount of places we are missing [[nodiscard]] and have to write the std::pair that would be cool, but if not thats fine. lgtm as-is

Open in Gerrit

Related details

Attention is currently required from:
  • Steinar H Gunderson
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I9c3221ff200aa7a7c1cb0a78c84785cc2baf07ec
Gerrit-Change-Number: 7486769
Gerrit-PatchSet: 4
Gerrit-Owner: Steinar H Gunderson <se...@chromium.org>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-CC: Xida Chen <xida...@chromium.org>
Gerrit-Attention: Steinar H Gunderson <se...@chromium.org>
Gerrit-Comment-Date: Sat, 17 Jan 2026 00:43:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages