Optimize diff/post performance by caching 'svn info' results
Review Request #7199 — Created April 13, 2015 and submitted
rbt diff and post operations make numerous calls to 'svn info' with
paths to various files. For any given modified file, 'svn info'
is called 4 + N times. This breaks down as:
- 3 calls from convert_to_absolute_paths() with the full filename
to process the new file line, original file line, and Index line - 1 call from find_copyfrom() for the full filename
- N calls from find_copyfrom() for each sub-path component in the
filename
By introducing caching on results from 'svn info' the number of
calls per file can be decreased to 1 + M, where M is always <= N.
For files sharing a common directory hierarchy, M will be equal
to N for the first file processed and 0 for all subsequent files.
Consider a contrived example with two modified files at:
A/B/C/foo.txt
A/B/C/bar.txt
The original code make 14 total calls to 'svn info'. Measuring
timing on a CentOS 7 box with time -p
reveals an average run
time of 0.742s. The updated code makes 5 total calls to
'svn info' and runtime is measured at 0.586s. This is a decrease
in runtime of 21%.
* Performed various 'rbt diff' executions with debug enabled to verify expected decrease in calls to 'svn info'. * Ran unit tests.
- Change Summary:
-
Implement Barret's suggestion to minimize the number of return paths.
- Commit:
-
a3c900ff9faaa3e77f601cb509c3fd03435cd226178ca2073a701f3ec29074613a4153c8f9cfa095
- Diff:
-
Revision 2 (+20 -14)
- Change Summary:
-
Fix PEP8 issue.
- Commit:
-
178ca2073a701f3ec29074613a4153c8f9cfa09539a5461004310f16e13975caf7c5c72f4537dae7
- Diff:
-
Revision 3 (+20 -14)
-
Tool: Pyflakes Processed Files: rbtools/clients/svn.py Tool: PEP8 Style Checker Processed Files: rbtools/clients/svn.py
- Change Summary:
-
Remove blank line.
- Commit:
-
39a5461004310f16e13975caf7c5c72f4537dae72fcdf37b593280689c57b2305215b662bc38dc52
- Diff:
-
Revision 4 (+20 -15)