Cache os calls to make xenv faster
When building the LHCb project, there are many repeated calls to os.listdir
for the same directory.
With a simple caching of the calls, I am able to save 275user + 350system.
This is on a 4 core openstack VM.
Here are the timings of two builds with a hot ccache before and after the proposed change
1291.85user 773.61system 18:12.69elapsed 189%CPU (0avgtext+0avgdata 3290288maxresident)k
72941752inputs+5380936outputs (151956major+27552186minor)pagefaults 0swaps
1026.60user 424.04system 9:44.70elapsed 248%CPU (0avgtext+0avgdata 3290452maxresident)k
72332696inputs+5381144outputs (151712major+27911347minor)pagefaults 0swaps