[Nix-dev] Re: Performance impact of Nix

Tony White tonywhite100 at googlemail.com
Thu Jul 30 12:53:20 CEST 2009


2009/7/30 Ludovic Courtès <ludo at gnu.org>:
> Hi,
>
> Tony White <tonywhite100 at googlemail.com>
> writes:
>
>> I think that if the package name came before the hash in the folder
>> name for each package in the nix store, we would experience faster
>> search results.
>
> I don't think so, precisely because cryptographic hashes are designed to
> "spread" well over their output domain.
>
> In my crowded Nix store, a prefix of 3 or 4 characters is enough to
> discriminate a specific directory.
>
> Thanks,
> Ludo'.
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at cs.uu.nl
> https://mail.cs.uu.nl/mailman/listinfo/nix-dev
>

Hi,
Hmm, you're right! :

# Enter the nix store and create two fake test directories
cd /nix/store
sudo mkdir 2g3g2zcndglrjshszzhkk50km8fhkmzj-test-1
sudo mkdir test-2-2g3g2zcndglrjshszzhkk50km8fhkmzj
# Benchmark the search time
cd $HOME
# Test 1 (The hash comes before the package name)
time find /nix/store/*test-1*

Result :

/nix/store/2g3g2zcndglrjshszzhkk50km8fhkmzj-test-1

real    0m0.065s
user    0m0.053s
sys     0m0.004s

# Test 2 (The hash comes after the package name)
time find /nix/store/*test-2*

Result :

/nix/store/test-2-2g3g2zcndglrjshszzhkk50km8fhkmzj

real    0m0.058s
user    0m0.048s
sys     0m0.003s

# Remove the fake directories in from the nix store
sudo rmdir /nix/store/2g3g2zcndglrjshszzhkk50km8fhkmzj-test-1
sudo rmdir /nix/store/test-2-2g3g2zcndglrjshszzhkk50km8fhkmzj

But that test was unfair because the store would never contain the
same hash twice (I think.)

So differences in the hash (Four characters) And the name :

cd /nix/store
sudo mkdir 2g3g2zcnjglrjslszzhkf50ym8fhkmzj-test-1
sudo mkdir test-2-2g3k2zsndglreshszzrkk50km8fhkmzj

time find /nix/store/*test-1*

Result :

/nix/store/2g3g2zcnjglrjslszzhkf50ym8fhkmzj-test-1

real    0m0.055s
user    0m0.046s
sys     0m0.004s


time find /nix/store/*test-2*

Result :

/nix/store/test-2-2g3k2zsndglreshszzrkk50km8fhkmzj

real    0m0.059s
user    0m0.047s
sys     0m0.005s


sudo rmdir 2g3g2zcnjglrjslszzhkf50ym8fhkmzj-test-1
sudo rmdir test-2-2g3k2zsndglreshszzrkk50km8fhkmzj

So the way it works is currently the fastest. So my thinking was wrong.
I wonder if it's the same result with symlinks?
Maybe the time test could be used to measure if the nix store in
/store instead of /nix/store is any faster?

Thanks,
Tony



More information about the nix-dev mailing list