RESOLVED FIXED 211223
Some HTML element critical paths include AtomString materialization
https://bugs.webkit.org/show_bug.cgi?id=211223
Summary Some HTML element critical paths include AtomString materialization
Yusuke Suzuki
Reported 2020-04-29 22:55:17 PDT
We should use `static NeverDestroyed<AtomString>`.
Attachments
Patch (33.21 KB, patch)
2020-04-30 15:45 PDT, Yusuke Suzuki
no flags
Patch (33.21 KB, patch)
2020-04-30 15:52 PDT, Yusuke Suzuki
saam: review+
Patch (33.96 KB, patch)
2020-04-30 16:30 PDT, Yusuke Suzuki
no flags
Yusuke Suzuki
Comment 1 2020-04-30 15:45:40 PDT
Yusuke Suzuki
Comment 2 2020-04-30 15:52:14 PDT
Saam Barati
Comment 3 2020-04-30 15:58:33 PDT
Comment on attachment 398108 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=398108&action=review > Source/WebCore/ChangeLog:10 > + `static NeverDestroyed<const AtomString> ...("...", AtomString::ConstructFromLiteral)`. Since HTML is in the main thread, we can just use `static NeverDestroyed<>`. can you add asserts everywhere you did this that we're on the main thread?
Saam Barati
Comment 4 2020-04-30 16:10:25 PDT
I spoke to Yusuke and this is done everywhere. My observation is we should have asserts in all those places. But this patch doesn't need to be the thing adding them.
Yusuke Suzuki
Comment 5 2020-04-30 16:17:37 PDT
(In reply to Saam Barati from comment #4) > I spoke to Yusuke and this is done everywhere. > > My observation is we should have asserts in all those places. > > But this patch doesn't need to be the thing adding them. I think we should introduce `MainThreadNeverDestroyed<const AtomString>` and insert `ASSERT(isMainThread());` in get accessor of that class. And replace existing `NeverDestroyed<const AtomString>` with that. But I think this should be done separately given that we already have so many things like that and this patch's goal is not fixing / finding an existing bug with a new abstraction.
Yusuke Suzuki
Comment 6 2020-04-30 16:18:49 PDT
(In reply to Yusuke Suzuki from comment #5) > (In reply to Saam Barati from comment #4) > > I spoke to Yusuke and this is done everywhere. > > > > My observation is we should have asserts in all those places. > > > > But this patch doesn't need to be the thing adding them. > > I think we should introduce `MainThreadNeverDestroyed<const AtomString>` and > insert `ASSERT(isMainThread());` in get accessor of that class. And replace > existing `NeverDestroyed<const AtomString>` with that. But I think this > should be done separately given that we already have so many things like > that and this patch's goal is not fixing / finding an existing bug with a > new abstraction. https://bugs.webkit.org/show_bug.cgi?id=211264
Yusuke Suzuki
Comment 7 2020-04-30 16:26:35 PDT
Inserted `ASSERT(isMainThread())` for newly added NeverDestroyed<>. I postpone `isMainThread()` assertion check in the existing places in https://bugs.webkit.org/show_bug.cgi?id=211264.
Yusuke Suzuki
Comment 8 2020-04-30 16:30:53 PDT
Created attachment 398119 [details] Patch Patch for landing
Yusuke Suzuki
Comment 9 2020-04-30 18:44:48 PDT
Comment on attachment 398119 [details] Patch OK, EWS is green.
EWS
Comment 10 2020-04-30 18:47:52 PDT
Committed r260977: <https://trac.webkit.org/changeset/260977> All reviewed patches have been landed. Closing bug and clearing flags on attachment 398119 [details].
Radar WebKit Bug Importer
Comment 11 2020-04-30 18:48:16 PDT
Darin Adler
Comment 12 2020-05-10 16:15:33 PDT
Comment on attachment 398108 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=398108&action=review >> Source/WebCore/ChangeLog:10 >> + `static NeverDestroyed<const AtomString> ...("...", AtomString::ConstructFromLiteral)`. Since HTML is in the main thread, we can just use `static NeverDestroyed<>`. > > can you add asserts everywhere you did this that we're on the main thread? If so, please don’t write each one out. Make a class that does it! Even one specific to AtomString would be OK with me.
Darin Adler
Comment 13 2020-05-10 16:18:08 PDT
Comment on attachment 398119 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=398119&action=review > Source/WebCore/html/SearchInputType.cpp:70 > + ASSERT(isMainThread()); Adding all these asserts like this doesn’t seem good. Tons of DOM code all assumes it’s on the main thread. Adding these assertions everywhere we use an AtomString like this is inelegant and inconsistent with WebKit coding style. The DOM code could be peppered with ASSERT(isMainThread()); that assertion is true/needed throughout. If we really want these, I suggest we make a class MainThreadAtomStringLiteral: static MainThreadAtomStringLiteral webkitSearchResultsButtonName("-webkit-search-results-button"); The assertions would go in the "get" function as well as the construction code.
Yusuke Suzuki
Comment 14 2020-05-11 03:59:17 PDT
Comment on attachment 398119 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=398119&action=review >> Source/WebCore/html/SearchInputType.cpp:70 >> + ASSERT(isMainThread()); > > Adding all these asserts like this doesn’t seem good. Tons of DOM code all assumes it’s on the main thread. Adding these assertions everywhere we use an AtomString like this is inelegant and inconsistent with WebKit coding style. The DOM code could be peppered with ASSERT(isMainThread()); that assertion is true/needed throughout. > > If we really want these, I suggest we make a class MainThreadAtomStringLiteral: > > static MainThreadAtomStringLiteral webkitSearchResultsButtonName("-webkit-search-results-button"); > > The assertions would go in the "get" function as well as the construction code. I already landed MainThreadNeverDestroyed :) https://trac.webkit.org/changeset/261013/webkit See https://bugs.webkit.org/show_bug.cgi?id=211223#c7 and https://bugs.webkit.org/show_bug.cgi?id=211264
Yusuke Suzuki
Comment 15 2020-05-11 04:05:48 PDT
Comment on attachment 398119 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=398119&action=review >>> Source/WebCore/html/SearchInputType.cpp:70 >>> + ASSERT(isMainThread()); >> >> Adding all these asserts like this doesn’t seem good. Tons of DOM code all assumes it’s on the main thread. Adding these assertions everywhere we use an AtomString like this is inelegant and inconsistent with WebKit coding style. The DOM code could be peppered with ASSERT(isMainThread()); that assertion is true/needed throughout. >> >> If we really want these, I suggest we make a class MainThreadAtomStringLiteral: >> >> static MainThreadAtomStringLiteral webkitSearchResultsButtonName("-webkit-search-results-button"); >> >> The assertions would go in the "get" function as well as the construction code. > > I already landed MainThreadNeverDestroyed :) https://trac.webkit.org/changeset/261013/webkit > > See https://bugs.webkit.org/show_bug.cgi?id=211223#c7 and https://bugs.webkit.org/show_bug.cgi?id=211264 And that patch actually found one tricky usage in GTK/WPE ports https://trac.webkit.org/changeset/261075/webkit
Darin Adler
Comment 16 2020-05-11 09:29:15 PDT
(In reply to Yusuke Suzuki from comment #14) > I already landed MainThreadNeverDestroyed :) > https://trac.webkit.org/changeset/261013/webkit Could you use that here instead of adding all these assertions?
Yusuke Suzuki
Comment 17 2020-05-11 11:23:10 PDT
(In reply to Darin Adler from comment #16) > (In reply to Yusuke Suzuki from comment #14) > > I already landed MainThreadNeverDestroyed :) > > https://trac.webkit.org/changeset/261013/webkit > > Could you use that here instead of adding all these assertions? The patch here is already landed. And https://trac.webkit.org/changeset/261013/webkit is introduced after that, and it replaces inserted `ASSERT(isMainThread())` with `MainThreadNeverDestroyed<>`. So, it is already done :)
Darin Adler
Comment 18 2020-05-11 11:25:54 PDT
(In reply to Yusuke Suzuki from comment #17) > it replaces inserted `ASSERT(isMainThread())` with > `MainThreadNeverDestroyed<>` Great! Sorry I didn’t understand. I still think that one specifically for AtomString would be nice to make the code less wordy.
Note You need to log in before you can comment on or make changes to this bug.