| Summary: | Small optimizations to TinyLRUCache | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Chris Dumez <cdumez> | ||||||
| Component: | Web Template Framework | Assignee: | Chris Dumez <cdumez> | ||||||
| Status: | RESOLVED FIXED | ||||||||
| Severity: | Normal | CC: | benjamin, cmarcelo, darin, ews-watchlist, ggaren, sam, webkit-bug-importer, ysuzuki | ||||||
| Priority: | P2 | Keywords: | InRadar | ||||||
| Version: | WebKit Nightly Build | ||||||||
| Hardware: | Unspecified | ||||||||
| OS: | Unspecified | ||||||||
| Attachments: |
|
||||||||
|
Description
Chris Dumez
2022-02-23 15:25:47 PST
Created attachment 453035 [details]
Patch
Comment on attachment 453035 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=453035&action=review > Source/WTF/ChangeLog:14 > + - Use Vector::uncheckedAppend() instead of Vector::append() to bypass capacity > + checks given that the vector has an inline capacity that is the size of the > + cache (vector capacity never grows or shrinks). Maybe we should us FixedVector instead? > Source/WTF/wtf/TinyLRUCache.h:56 > + Entry entry = WTFMove(m_cache[index]); I’d use auto here. Comment on attachment 453035 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=453035&action=review >> Source/WTF/ChangeLog:14 >> + cache (vector capacity never grows or shrinks). > > Maybe we should us FixedVector instead? I am not super familiar with FixedVector but doesn't it have a fixed size? Here the vector size is dynamic but the vector *capacity* is static. I guess we could use a vector of fixed size (FixedVector) but then we'd need to fill the vector with "empty" values, distinguishable from actually cache values? >> Source/WTF/wtf/TinyLRUCache.h:56 >> + Entry entry = WTFMove(m_cache[index]); > > I’d use auto here. OK. Created attachment 453062 [details]
Patch
Committed r290415 (247723@main): <https://commits.webkit.org/247723@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 453062 [details]. (In reply to Chris Dumez from comment #3) > Comment on attachment 453035 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=453035&action=review > > >> Source/WTF/ChangeLog:14 > >> + cache (vector capacity never grows or shrinks). > > > > Maybe we should us FixedVector instead? > > I am not super familiar with FixedVector but doesn't it have a fixed size? > Here the vector size is dynamic but the vector *capacity* is static. > I guess we could use a vector of fixed size (FixedVector) but then we'd need > to fill the vector with "empty" values, distinguishable from actually cache > values? > > >> Source/WTF/wtf/TinyLRUCache.h:56 > >> + Entry entry = WTFMove(m_cache[index]); > > > > I’d use auto here. > > OK. Given the name (Tiny...) I think we can probably just a fixed size array for this. Im don't think we ever use this for something with more than 32 elements and we know the max capacity at compile time. std::array or whatever would be fine. Just a bother to have to implement your own size(), remove(), and append() functions. Maybe not worth the bother? |