Bug 1814310 Comment 1 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

[Here](https://share.firefox.dev/44qEHMw) is a profile running the test 10 times with higher sampling. Three methods seem relevant: `FindAncestorForm`, `GetAttr` and `GetFormInternal`.

`FindAncestorForm` has a high self time and I don't think there is much to be done, as we have to walk the tree to find possible forms. I can't figure out why `NodeInfo::Equals` shows up in the call tree.

`GetAttr` has some overhead, as we call `GetAttr(..., nsAString)` which calls `GetAttr(..., DOMString)`, which again retrieves the value from a `nsAttrValue` object. So there is an intermediate `DOMString` object that we could eliminate by duplicating code between `GetAttr(..., nsAString)` and `GetAttr(..., DOMString)`. Truncating an empty `nsAString` also shows up, maybe that can be optimized? Using `nsString` instead of `nsAutoString` did not change that.

I'm unsure why `GetFormInternal` shows up, maybe because of virtual overhead or `HTMLElement`s implementation [here](https://searchfox.org/mozilla-central/source/dom/html/HTMLElement.cpp#357). We can eliminate some calls to it by updating a local variable whenever `ClearForm` or `SetFormInternal` is called, though one might fail to update the variable correctly in the future causing bugs. Given this reduced the number of samples by 4 of 93 total, this might not be worth it.

[Here](https://share.firefox.dev/3POKlEt) is a profile with `GetAttr` directly using `nsAttrValue` and `GetFormInternal` being called only once.
[Here](https://share.firefox.dev/44qEHMw) is a profile running the test 10 times with higher sampling. Three methods seem relevant: `FindAncestorForm`, `GetAttr` and `GetFormInternal`.

`FindAncestorForm` has a high self time and I don't think there is much to be done, as we have to walk the tree to find possible forms. I can't figure out why `NodeInfo::Equals` shows up in the call tree, maybe it's just called often?

`GetAttr` has some overhead, as we call `GetAttr(..., nsAString)` which calls `GetAttr(..., DOMString)`, which again retrieves the value from a `nsAttrValue` object. So there is an intermediate `DOMString` object that we could eliminate by duplicating code between `GetAttr(..., nsAString)` and `GetAttr(..., DOMString)`. Truncating an empty `nsAString` also shows up, maybe that can be optimized? Using `nsString` instead of `nsAutoString` did not change that.

I'm unsure why `GetFormInternal` shows up, maybe because of virtual overhead or `HTMLElement`s implementation [here](https://searchfox.org/mozilla-central/source/dom/html/HTMLElement.cpp#357). We can eliminate some calls to it by updating a local variable whenever `ClearForm` or `SetFormInternal` is called, though one might fail to update the variable correctly in the future causing bugs. Given this reduced the number of samples by 4 of 93 total, this might not be worth it.

[Here](https://share.firefox.dev/3POKlEt) is a profile with `GetAttr` directly using `nsAttrValue` and `GetFormInternal` being called only once.
[Here](https://share.firefox.dev/44qEHMw) is a profile running the test 10 times with higher sampling. Three methods seem relevant: `FindAncestorForm`, `GetAttr` and `GetFormInternal`.

`FindAncestorForm` has a high self time and I don't think there is much to be done, as we have to walk the tree to find possible forms. I guess `NodeInfo::Equals` shows up in the call tree as it's called often?

`GetAttr` has some overhead, as we call `GetAttr(..., nsAString)` which calls `GetAttr(..., DOMString)`, which again retrieves the value from a `nsAttrValue` object. So there is an intermediate `DOMString` object that we could eliminate by duplicating code between `GetAttr(..., nsAString)` and `GetAttr(..., DOMString)`. Truncating an empty `nsAString` also shows up, maybe that can be optimized? Using `nsString` instead of `nsAutoString` did not change that.

I'm unsure why `GetFormInternal` shows up, maybe because of virtual overhead or `HTMLElement`s implementation [here](https://searchfox.org/mozilla-central/source/dom/html/HTMLElement.cpp#357). We can eliminate some calls to it by updating a local variable whenever `ClearForm` or `SetFormInternal` is called, though one might fail to update the variable correctly in the future causing bugs. Given this reduced the number of samples by 4 of 93 total, this might not be worth it.

[Here](https://share.firefox.dev/3POKlEt) is a profile with `GetAttr` directly using `nsAttrValue` and `GetFormInternal` being called only once.

Back to Bug 1814310 Comment 1