Hey, while we are waiting for #616, it would be nice to get accustomed to the code base and contribution policy, send a few patches, and see how it goes in general. Improving performance without significant architectural changes seems to be a nice place to start!
So far, things I've found that can be done relatively easily:
Note: performance numbers are from runs on kotlinx.* libraries in sequential mode (with commented out parallelStream), parallel mode is too noisy for measurements.
Would you be okay if I gradually start sending patches for these and add @AbdullinAM as a co-reviewer?
Hey, while we are waiting for #616, it would be nice to get accustomed to the code base and contribution policy, send a few patches, and see how it goes in general. Improving performance without significant architectural changes seems to be a nice place to start!
So far, things I've found that can be done relatively easily:
Parser.parseresult if code wasn't changed between formatting steps. The duct-taped version of this change yields ~20-25% of raw throughput. Duplicate of Four calls toParser.parsecause performance issues #552Parser.parsevisitsKtFilein search for parsing errors, basically parsing it two times in a row. ~10-15% when commented out (which is not an option for a fix, but an approximation), probably a much less straightforward fix thoughPsiElement.texthere and theregetMultilineTrimmedStringList(because oflines()). Less generally-applicable, helps a lot for large files withtrimIndent/trimMargin(~25% onkftmt, mostly because ofFormatterTest.ktwhich is exactly this pattern)MultilineStringFormatterwhen there are no"""and/ortrimIndent/trimMargin. ~10-15%?Note: performance numbers are from runs on kotlinx.* libraries in sequential mode (with commented out
parallelStream), parallel mode is too noisy for measurements.Would you be okay if I gradually start sending patches for these and add @AbdullinAM as a co-reviewer?