| Summary: | Make DeferredWorkTimer::addPendingWork() return a Ticket. | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Mark Lam <mark.lam> | ||||||||
| Component: | JavaScriptCore | Assignee: | Mark Lam <mark.lam> | ||||||||
| Status: | RESOLVED FIXED | ||||||||||
| Severity: | Normal | CC: | ews-watchlist, keith_miller, msaboff, saam, tzagallo, webkit-bug-importer, ysuzuki | ||||||||
| Priority: | P2 | Keywords: | InRadar | ||||||||
| Version: | WebKit Nightly Build | ||||||||||
| Hardware: | Unspecified | ||||||||||
| OS: | Unspecified | ||||||||||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=234855 | ||||||||||
| Attachments: |
|
||||||||||
|
Description
Mark Lam
2021-12-22 20:16:52 PST
Created attachment 447855 [details]
proposed patch.
Comment on attachment 447855 [details] proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=447855&action=review r=me > Source/JavaScriptCore/runtime/DeferredWorkTimer.cpp:142 > + Vector<Ticket, 16> cancelledTickets; > + for (auto& it : m_pendingTickets) { > + if (it.value->isCancelled()) > + cancelledTickets.append(it.key); > + } > + for (auto& ticket : cancelledTickets) > + m_pendingTickets.remove(ticket); You can use `HashMap::removeIf` / `HashSet::removeIf`, which is more efficient. > Source/JavaScriptCore/runtime/DeferredWorkTimer.h:58 > Vector<Strong<JSCell>> dependencies; It is good if we can use FixedVector<Strong<JSCell>> here, which allocates exact size, and it only has one pointer size. > Source/JavaScriptCore/runtime/DeferredWorkTimer.h:92 > + HashMap<Ticket, std::unique_ptr<TicketData>> m_pendingTickets; Why not using `HashSet<std::unique_ptr<TicketData>>`? I think, because of GetPtr abstraction, we can still look up from it via TicketData*, a.k.a. Ticket. And HashSet is 2x more space efficient. > Source/JavaScriptCore/wasm/WasmStreamingCompiler.cpp:210 > + // The pending work TicketData was keeping the promise alive. We need to Remove one space between We and need. Thanks for the review. (In reply to Yusuke Suzuki from comment #2) > You can use `HashMap::removeIf` / `HashSet::removeIf`, which is more > efficient. Fixed. > > Source/JavaScriptCore/runtime/DeferredWorkTimer.h:58 > > Vector<Strong<JSCell>> dependencies; > > It is good if we can use FixedVector<Strong<JSCell>> here, which allocates > exact size, and it only has one pointer size. I can't do this yet. Will need to add 2 APIs: FixedVector::clear() and FixedVector::contains(). It's not difficult to add these, but I'll do that in a separate patch, and make this change after that. > > Source/JavaScriptCore/runtime/DeferredWorkTimer.h:92 > > + HashMap<Ticket, std::unique_ptr<TicketData>> m_pendingTickets; > > Why not using `HashSet<std::unique_ptr<TicketData>>`? I think, because of > GetPtr abstraction, we can still look up from it via TicketData*, a.k.a. > Ticket. > And HashSet is 2x more space efficient. Fixed. > > Source/JavaScriptCore/wasm/WasmStreamingCompiler.cpp:210 > > + // The pending work TicketData was keeping the promise alive. We need to > > Remove one space between We and need. Fixed. Created attachment 447899 [details]
patch for landing.
Created attachment 447905 [details]
[fast-cq] patch for landing.
Comment on attachment 447905 [details]
[fast-cq] patch for landing.
Landing now.
Committed r287421 (245556@main): <https://commits.webkit.org/245556@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 447905 [details]. (In reply to Mark Lam from comment #3) > (In reply to Yusuke Suzuki from comment #2) > > > Source/JavaScriptCore/runtime/DeferredWorkTimer.h:58 > > > Vector<Strong<JSCell>> dependencies; > > > > It is good if we can use FixedVector<Strong<JSCell>> here, which allocates > > exact size, and it only has one pointer size. > > I can't do this yet. Will need to add 2 APIs: FixedVector::clear() and > FixedVector::contains(). It's not difficult to add these, but I'll do that > in a separate patch, and make this change after that. Fixing this in https://bugs.webkit.org/show_bug.cgi?id=234855. |