news.volyx.in

O(n^2), again, now in Windows Management Instrumentation (randomascii.wordpress.com)

501 points by harikb · 2501 days ago · 224 comments on HN

Article summary

The article discusses a performance issue with Windows Management Instrumentation (WMI) caused by an O(n^2) algorithm. The author discovered the issue after experiencing multi-minute delays on their workstation and used various tools to investigate and prove that the problem was due to a lock being held by WMI. The algorithm's performance degrades significantly as the size of the WMI repository increases. The author reports the issue to Microsoft and works with their IT department to mitigate the problem by stopping a script that was running the problematic command hourly.

Main themes

  • O(n^2) algorithm performance
  • Windows Management Instrumentation
  • Software development methodologies
  • Algorithm optimization
  • Performance debugging

What commenters say

  • The prevalence of O(n^2) algorithms in production code is due to their being fast enough to pass initial testing but slow enough to cause problems at scale.
  • Iterative development methodologies like agile can lead to O(n^2) algorithms being implemented and not optimized until later.
  • Waterfall development methodologies can help identify and optimize critical API calls and algorithms early on.
  • Premature optimization is often discouraged in interviews, but considering performance is essential in real-world software development.
  • Big O notation is not always the best tool for analyzing performance, especially when constant factors are significant.
  • Converting nested loops to non-nested loops can improve performance, but this should be clearly explained rather than relying on notation like O(2n).
  • The size of the input is a crucial factor in determining the significance of constant factors in big O notation.
  • In some cases, it is more important to prioritize code clarity and readability over optimization, but this can depend on the specific use case and requirements.