perf(utils): improve the performance of scoring and reporting#212
perf(utils): improve the performance of scoring and reporting#212MishaSeredenkoPushBased merged 10 commits intomainfrom
Conversation
|
Could you add the new logic the the benchmark tests please. |
|
@BioPhoton @matejchalk well, it looks like the changes don't affect the performance in a positive way - I added the updated functions to the benchmark, file |
|
could we get the traces for that? |
matejchalk
left a comment
There was a problem hiding this comment.
A have a question about the benchmarks. What numbers of audits and groups are you using?
The fact that imperative code is faster the declarative is not surprising (that's always the case in benchmarks which use extreme values), but the trick is figuring out if it's relevant to us or not.
If the performance optimizations are not noticeable for realistic amounts of data, then optimizing for code maintenance is still the way to go. E.g. if it doesn't make a difference until we reach thousands of groups, then it's not relevant to us, because that's not a realistic scenario and we would do better to prioritize our ability to understand and maintain the code and prevent bugs (side-effects like mutations are an anthesis to this). There's a famous quote that "premature optimization is the root of all evil", after all.
I would estimate that 100s and in extreme cases 1000s of audits are realistic (e.g. for the CLI, our very strict ESLint gives us 347 audits). So if the performance optimization has an impact at this level, then it's worth it, but if we don't see the performance benefits until we reach a million audits for example, then it isn't.
For groups, the number is much lower. I can't imagine we'd have over a 100 even.




Improved the performance of scoring and reporting.
Removed nested loops where possible, added dictionaries to go constant time O(1) instead of linear O(n).
Made minor refactoring, added some checks.
@BioPhoton As task owner, let me know if I understood the task correctly and implemented everything properly. Also, maybe you could propose additional changes for further performance improvements.
Closes #132