[Presubmit Speed] Make pretty-printing histograms faster
What: This CL dramatically speeds up pretty printing of xml files. It speeds up 'git cl format' for CLs with histograms.xml changes from 9 seconds to 3 seconds. This also speeds up other common operations like 'git cl upload'. How: The pretty printer now processes an instance of ElementTree instead of minidom (and will convert minidom to etree if necessary). There is overhead converting minidom to etree but it's still an improvement for those cases where clients only speak minidom. The histograms pretty printer has been rewritten to speak ElementTree. The others (rappor, ukm, actions) still speak minidom and they should be converted in followup CLs but it's less important since their XML files are much smaller. Note: Top-level comments aren't supported by ElementTree, so I've written a SAX parser to copy everything above the first tag in the document and paste it into the result of pretty printing. This is in etree_util.py Otherwise, pretty printing should behave identically. I've improved the testing to catch any mistakes I may have made, but given this involves parsing I wouldn't be surprised if a follow-up CL or two isn't required. Bug: 945354 Change-Id: I28990d245f5d471203f6430e08c8a98e3ba70d03 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1538783 Commit-Queue: Alexei Svitkine <asvitkine@chromium.org> Reviewed-by:Alexei Svitkine <asvitkine@chromium.org> Cr-Commit-Position: refs/heads/master@{#648683}
Showing
This diff is collapsed.
Please register or sign in to comment