wide-midnight-78598
06/14/2024, 8:48 PMfastapi
numpy
pandas
pydantic
scipy
uvicorn
I'm writing a sanity test to be able to script a few performance scenarios while building pexes/dockerfiles/etcbroad-processor-92400
06/14/2024, 9:01 PMwide-midnight-78598
06/14/2024, 9:15 PM# Meaningless comment that I'll use to test re-builds
import os
import fastapi
import numpy
import pandas
import pydantic
import scipy
import uvicorn
MY_ID = "sj"
MY_ENV_ID = os.getenv("PERFANITY_ID", "env")
class Foo(pydantic.BaseModel):
id: str
app = fastapi.FastAPI()
@app.get("/")
async def root():
foo = Foo(id=MY_ID)
bar = Foo(id=MY_ENV_ID)
return {"message": f"Hello {foo} and {bar}"}
def square(x: int) -> int:
return x**2
a = numpy.mean([1,2,3])
b = pandas.DataFrame()
c = scipy.integrate.quad(square, 0, 4)
if __name__ == "__main__":
uvicorn.run(app)nutritious-hair-72580
06/15/2024, 3:35 AMcareful-address-89803
06/15/2024, 3:44 AMazure-cli pulls in a full gig of stuff with ~150 packageswide-midnight-78598
06/15/2024, 4:15 AMwide-midnight-78598
06/15/2024, 4:19 AMfor layout in loose packed zipapp; do
for execution_mode in venv zipapp; do
echo " Packaging pex with execution_mode=$execution_mode and layout=$layout"
time pants package simple:bin@execution_mode=$execution_mode,layout=$layout
echo " Running tests with zero changes"
time pants test simple:
echo " Re-packaging with zero changes"
time pants package simple:bin@execution_mode=$execution_mode,layout=$layout
echo " Re-running tests with zero changes"
time pants test simple:
echo " Re-packaging with a comment change"
sed -i '' "1s|.*|# CACHE_BUSTING=$RANDOM|" ./simple/main.py
time pants package simple:bin@execution_mode=$execution_mode,layout=$layout
echo " Re-running tests with zero changes"
time pants test simple:
done
donebroad-processor-92400
06/15/2024, 4:21 AM--no-pre-install-wheels pex option too (I think there pants fields to pass through arbitrary args), although this’ll be affected by the pex cache. For truly fresh-cache tests, I find setting the local store/named cache global options to temporary dirs to be the most reliable way.wide-midnight-78598
06/15/2024, 4:26 AMwide-midnight-78598
06/15/2024, 3:04 PMstep clean noop incremental
goal package run test package run test package run test
simple:bin@execution_mode=venv,layout=loose 4.02 11.29 1.11 1.00 3.63 0.09 4.10 11.03 1.11
simple:bin@execution_mode=venv,layout=packed 1.23 3.02 0.09 0.09 1.08 0.25 1.17 1.71 1.10
simple:bin@execution_mode=venv,layout=zipapp 6.38 0.94 0.08 0.08 0.89 0.08 6.40 1.51 1.08
simple:bin@execution_mode=zipapp,layout=loose 4.23 9.02 0.09 0.96 8.93 0.09 4.19 9.45 1.04
simple:bin@execution_mode=zipapp,layout=packed 1.15 1.36 0.08 0.08 1.20 0.09 1.15 1.26 1.08
simple:bin@execution_mode=zipapp,layout=zipapp 6.35 1.30 0.08 0.08 1.38 0.16 6.43 1.30 1.06wide-midnight-78598
06/15/2024, 5:26 PMloose packaging when copying into Docker 🤦♂️
Though, it looks like it's not even using my pre-built - so, who knows - I probably blundered the cache somewhere
step clean noop incremental
goal package run test package run test package run test
simple:img_execution_mode_venv_layout_loose 6.25 354.93 0.18 5.87 355.49 0.20 5.74 357.60 0.19
simple:img_execution_mode_venv_layout_packed 4.45 14.58 0.18 3.91 15.06 0.19 3.52 14.66 0.42
simple:img_execution_mode_venv_layout_zipapp 4.32 15.52 0.19 3.67 15.62 0.21 3.82 14.83 0.18
simple:img_execution_mode_zipapp_layout_loose 6.15 360.92 0.21 6.01 357.35 0.18 5.79 358.86 0.20
simple:img_execution_mode_zipapp_layout_packed 4.46 14.63 0.21 3.88 14.88 0.22 4.22 15.67 0.24
simple:img_execution_mode_zipapp_layout_zipapp 4.13 15.83 0.35 3.59 14.95 0.29 3.51 15.39 0.21broad-processor-92400
06/17/2024, 11:17 AMwide-midnight-78598
06/17/2024, 12:22 PMcurved-manchester-66006
06/17/2024, 2:41 PMNote to self: Don't use loose packaging when copying into Dockerhttps://github.com/pantsbuild/pants/issues/20822
wide-midnight-78598
06/17/2024, 5:11 PMwide-midnight-78598
06/17/2024, 5:12 PM