[Nix-dev] Re: Performance impact of Nix
Marc Weber
marco-oweber at gmx.de
Thu Jul 30 14:28:20 CEST 2009
Hi Tony,
you're aware that the system caches directory contents?
So if you run the same command a second time everything will be faster?
So what are you measuring exactly ? The time to of man 3 glob ?
marc at nixos: /nix/store ]$ time echo *d5rw61pr6ffl0mnbrfs2*
32d5rw61pr6ffl0mnbrfs2ih5xjk4nls-vim_configurable-7.2
real 0m0.402s
user 0m0.380s
sys 0m0.020s
marc at nixos: /nix/store ]$
marc at nixos: /nix/store ]$ time echo
32d5rw61pr6ffl0mnbrfs2ih5xjk4nls-vim_configurable-7.2/*
32d5rw61pr6ffl0mnbrfs2ih5xjk4nls-vim_configurable-7.2/bin
32d5rw61pr6ffl0mnbrfs2ih5xjk4nls-vim_configurable-7.2/share
real 0m0.000s
user 0m0.000s
sys 0m0.000s
So the command using glob is much slower. So time also measures the
globbing time!
I mean all I saw is:
> real 0m0.065s < first run
> real 0m0.058s < next runs maybe using cached stuff..
> real 0m0.055s
> real 0m0.059s
So I wouldn't conclude that that's the difference unless you retry many
times.
Glob will always read all store paths and test the glob pattern.
If you test for *foo* it doesn't actually matter where this *foo*
appears that much if it's hit only once.. because foo hast to be matched
again and again anyway.
/nix/store/EEEEEEEEEEEEEEEEEEEEEEEEEEEEe-name
foo* ? no
foo*? no
foo*? no
....
Of course this can be optimized but I don't think that this changes glob
time behaviour too much.
I think the more important question is: I accesing
/EEEEEEEEEEEEEEEEEEEE-name
faster than
/nix/store/EEEEEEEEEEEEEEEEEEEEEEEEEE-name
or
/nix/store/a/b/c/d/e/f/EEEEEEEEEEEEEEEEEEEEEEEEEE-name
?
And I don't think you can measure this using one directory access only
using the time command because process scheduling will modify your
results as well then.
Marc Weber
More information about the nix-dev
mailing list