Hi, I’m trying to use pants for a dummy hello worl...
# development
m
Hi, I’m trying to use pants for a dummy hello world target: BUILD:
Copy code
python_library()

pex_binary(entry_point="main.py", name="bin")
main.py:
Copy code
print("Hello world")
However running it takes ~2 seconds:
Copy code
./pants run bins:bin  0.59s user 0.15s system 37% cpu 1.984 total
Am I doing something wrong or should I expect a big penalty from pex binaries?
h
hm with the user number at 0.59s and system at 0.15s, I'm confused why total is so high at 1.984 2s is probably higher than we'd anticipate, especially for a small repo. Although also a cold run will be slower than a warm run, thanks to caching and the Pants daemon. What's the benchmark for running it a second time?
m
I’m running on macOS:
Copy code
$ time ./pants --version
2.7.0rc0

real	0m0.832s
user	0m0.549s
sys	0m0.125s
Just running
./pants
gets a hit of 600-900ms
👍 1
I’m getting similar numbers on a linux machine
h
Ah yes, indeed. That is being actively worked on with https://github.com/pantsbuild/pants/issues/11831. @enough-analyst-54434 found about ~500ms saved with the proof of concept. That landed in pantsbuld/pants, but isn't yet stable for wider consumption The maintainers are planning this week what our next priorities are (in large part thanks to feedback from the community survey you might have seen!), and I think this will probably come up in prioritizing. Right now, supporting lockfiles (https://github.com/pantsbuild/pants/issues/12314) pushed it back a little. cc @witty-crayon-22786
w
@melodic-thailand-99227: until that is fixed, you can run
pants package
to build the binary, and then run the binary independently
1
PEX has a variety of execution modes, but the
--venv
mode should be ~as fast as a venv.
h
Concretely, set https://www.pantsbuild.org/docs/reference-pex_binary#codeexecution_modecode to either
unzip
or
venv
. As explained there,
venv
will get you the fastest subsequent runs after an initial run