-
-
Notifications
You must be signed in to change notification settings - Fork 98
Cache the DetectableDB scan results #123
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
base: main
Are you sure you want to change the base?
Conversation
|
Seems like it works with some slight reduction in cpu and memory usage as well. I will update after trying in combination with #92 but it seems good so far. |
|
It appears in combo with 92 the cpu and memory usage goes up but not by much. I do see the memory usage going up at a very slow rate consistently while idling and slightly faster while multiple different processes are running. I have direct contact with chlorobyte if anyone asks how I managed to test the combined pr. |
CanadaHonk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow this is great, thank you! Small request: could you just store detected in the cache instead of { detected }?
This prevents a hypothetical case of rotating lots of processes to bloat the RAM usage
|
Sure, that makes sense. Also implemented some sort of garbage collection to resolve @Dekomoro's concern, in a normal use case you basically never hit this (or maybe you do like once an hour of runtime or something) |
|
When evaluating this change, I was really blown away by the performance improvements. Using the logging in Additionally, running clinic.js BeforeAfterLooking forward to seeing this merged, amazing work. |
|
|
||
|
|
||
| const timestamps = {}, names = {}, pids = {}; | ||
| const timestamps = {}, names = {}, pids = {}, cache = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know most of these already existed before this PR, but using plain objects for this is bad. When you have frequent writes / deletes, Maps perform way better, both in terms of speed and memory usage. Changing all of these to Maps might also make it perform better


Inspired by a performance problem rightfully pointed out in PR #92, I set out to greatly optimize the process scan:
mainmain, simply no GC spikes happened hereThe change works on my end, but is also provably correct (assuming
DetectableDBdoes not change) because:DetectableDB's contents,args, andtoComparetoCompareis derived fromsplitPathsplitPathis derived frompathNotes:
await Native.getProcesses();. Improve linux game detection #92 does add functionality to this call but the performance difference is negligible (16.3ms -> 18.3ms, possibly within margin of error)DetectableDB.Open questions:
DetectableDBentries being detected with one process is intentional, but I cache an array of all detected entries to keep this behavior