Skip to content

SystemTools: introduce cache for Getcwd

Tim Blechmann requested to merge timblechmann/kwsys:feature/cache-getcwd into master

getcwd is a rather expensive operation that we're doing rather freqently during CollapseFullPath. however we only really need to do this after changing the working directory, which is done in Chdir. we therefore can cache the value, which is marked as dirty in Chdir.

real-world numbers benchmarks in a rather target-heavy project show quite a speedup

before:

tim@moka-mac:~/build$ time ~/dev/cmk/bin/cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/tim/build

real	0m5.700s
user	0m3.291s
sys	0m2.191s

after:

tim@moka-mac:~/build$ time ~/dev/cmk/bin/cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/tim/build

real	0m4.729s
user	0m3.170s
sys	0m1.372s

the time spent in kernel-space was reduced by roughly 800ms, overall speedup was almost 20%

Merge request reports