-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf functions getEntriesByName and getEntriesByType seem to have unnecessarily bad performance #42004
Comments
I'm wondering why this uses linked lists and not arrays (which are faster in pretty much every way?) |
@benjamingr it's used to prevent allocation and expansion of the array on the entry creation time, at which it is much more performance-sensitive than observing the entries. |
@legendecas but array allocation/size increase is amortized O(1) isn't it? If allocation is a problem we can use a |
From what I understand, expansion of array is not constant time. The content of the array has to be copied to the new larger location. I think FixedQueue could be a good alternative to the linked list. |
You're right - it's not constant. It's amortized constant time which is not quite the same thing - it basically means "acts like O(1) for a large enough N since the expensive operations are split across many invocations" (happy to elaborate with a more formal definition if you prefer). (Anyway a FixedQueue is the best of both worlds since it's also allocation friendly for resets) |
FixedQueue would likely be fine here. |
As a wise Benji once said - I'm taking a stab at this 🗡 |
Also order entries by startTime when calling getEntriesByType. Fix: #42004 Fix: #42024 PR-URL: #42032 Fixes: #42004 Fixes: #42024 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Also order entries by startTime when calling getEntriesByType. Fix: nodejs#42004 Fix: nodejs#42024 PR-URL: nodejs#42032 Fixes: nodejs#42004 Fixes: nodejs#42024 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Also order entries by startTime when calling getEntriesByType. Fix: nodejs#42004 Fix: nodejs#42024 PR-URL: nodejs#42032 Fixes: nodejs#42004 Fixes: nodejs#42024 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Also order entries by startTime when calling getEntriesByType. Fix: #42004 Fix: #42024 PR-URL: #42032 Fixes: #42004 Fixes: #42024 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Also order entries by startTime when calling getEntriesByType. Fix: #42004 Fix: #42024 PR-URL: #42032 Fixes: #42004 Fixes: #42024 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Also order entries by startTime when calling getEntriesByType. Fix: #42004 Fix: #42024 PR-URL: #42032 Fixes: #42004 Fixes: #42024 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Also order entries by startTime when calling getEntriesByType. Fix: #42004 Fix: #42024 PR-URL: #42032 Fixes: #42004 Fixes: #42024 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Also order entries by startTime when calling getEntriesByType. Fix: #42004 Fix: #42024 PR-URL: #42032 Fixes: #42004 Fixes: #42024 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Also order entries by startTime when calling getEntriesByType. Fix: #42004 Fix: #42024 PR-URL: #42032 Fixes: #42004 Fixes: #42024 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Also order entries by startTime when calling getEntriesByType. Fix: #42004 Fix: #42024 PR-URL: #42032 Fixes: #42004 Fixes: #42024 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Version
v16.14.0
Platform
Linux 5.13.0-28-generic #31~20.04.1-Ubuntu SMP Wed Jan 19 14:08:10 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
internal/lib/perf
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Lots of marks or measures must be present to see a noticeable difference in performance. Additionally, the name parameter for the
getEntriesByName
function must be for a entry name that exists in the buffers, as far as I can tell.What is the expected behavior?
No response
What do you see instead?
getEntriesByName
andgetEntriesByType
take significantly longer than a naive entry tracking solution using object key lookups and concatenation.Additional information
kMaxPerformanceEntryBuffers
makes clear that no more than 1000000 entries should be present. Maybe that implies that the performance expectations for these functions should not be high and that users should be expected to regularly clear entries instead.The text was updated successfully, but these errors were encountered: