pkgxdev / pkgx

run anything
https://pkgx.sh
Apache License 2.0
8.94k stars 1.36k forks source link

`pkgx` adds 300ms+ to each invocation of a tool #1033

Open alecthomas opened 3 weeks ago

alecthomas commented 3 weeks ago

This doesn't matter much for some tools, but for others that are invoked a lot such as eg. C compilers in a large build, or protoc+plugins with a large number of .proto files, this can really add up.

I'm not sure where this time is spent, perhaps it's Deno bootstrap overhead?

~ $ time go version             
go version go1.23.0 darwin/arm64
go version  0.00s user 0.00s system 74% cpu 0.012 total
~ $ time pkgx go@1.23.0 version
go version go1.23.0 darwin/arm64
pkgx go@1.23.0 version  0.20s user 0.06s system 78% cpu 0.341 total
~ $ time ~/.local/bin/go version
go version go1.23.0 darwin/arm64
~/.local/bin/go version  0.17s user 0.06s system 51% cpu 0.438 total
mxcl commented 3 weeks ago

Should be fixed in the just released v1.2.0. If you get a chance please take a look and let us know. You will need to do a single --sync before the new cache is available.

alecthomas commented 3 weeks ago

Thanks, I gave it a shot but it seems to be roughly the same:

🐚 ~ $ pkgx --version                             
pkgx 1.2.0
🐚 ~ $ pkgx --sync                                

🐚 ~ $ time pkgx go@1.23.0 version                
go version go1.23.0 darwin/arm64
pkgx go@1.23.0 version  0.18s user 0.10s system 75% cpu 0.377 total
🐚 ~ $ time pkgx go@1.23.0 version                
go version go1.23.0 darwin/arm64
pkgx go@1.23.0 version  0.18s user 0.10s system 74% cpu 0.366 total
🐚 ~ $ time pkgx go@1.23.0 version                
go version go1.23.0 darwin/arm64
pkgx go@1.23.0 version  0.18s user 0.10s system 74% cpu 0.372 total
mxcl commented 3 weeks ago

Hmm the cache cannot be working since for me eg:

$ time pkgx go version
go version go1.22.2 darwin/arm64

real    0m0.076s
user    0m0.053s
sys 0m0.018s

$ time ~/.pkgx/go.dev/v\*/bin/go version
go version go1.22.2 darwin/arm64

real    0m0.014s
user    0m0.005s
sys 0m0.007s

So still slower but not nearly as slow as before:

$ time ~/.pkgx/pkgx.sh/v1.1/bin/pkgx go version
go version go1.22.2 darwin/arm64

real    0m0.269s
user    0m0.198s
sys 0m0.042s

Note, I ran all a few times before posting these.

When you do pkgx --sync does it say caching during the output?

alecthomas commented 3 weeks ago

When not pinning the version I get a similar result to you:

🐚 ~ $ time pkgx go version
go version go1.23.0 darwin/arm64
pkgx go version  0.04s user 0.01s system 63% cpu 0.086 total
mxcl commented 3 weeks ago

k can reproduce, this shouldn't be the case I'll figure it out.

alecthomas commented 2 weeks ago

🙏