Description
spago build
takes surprisingly long to read it's configuration files.
When using my somewhat older laptop i noticed, that an invocation of spago build
on my smallish AdventOfCode project took 3.5 seconds, even though everything had already been compiled.
I tried investigating what took so long by inserting logDebug
and using the --verbose
flag.
I noticed that running purs
isn't actually the single most expensive step (took 800ms), instead globbing the workspace for every spago.yaml
and parsing spago.lock
takes quite long.
I usually expect a package manager to finish very quickly when there is no actual work to be done, even on slightly older hardware.
The old spago just takes 1.5s on the same project and device, so is this just the cost of writing spago in a language that compiles to javascript, or can we reduce this startup time? Or perhaps some of these steps can be skipped in certain cases?
How I measured:
time node ~/clones/spago/bin/bundle.js build --verbose
shows:
[ 25ms] CWD: /home/jasper/projects/pure-advent
[ 50ms] Global cache: "/home/jasper/.cache/spago-nodejs"
[ 52ms] Local cache: "/home/jasper/projects/pure-advent/.spago"
[ 112ms] DB: Connecting to database at /home/jasper/.cache/spago-nodejs/spago.v1.sqlite
[ 122ms] Reading Spago workspace configuration...
[ 122ms] Reading config from spago.yaml
[ 164ms] Before Glob.match **/spago.yaml I Added this logDebug
[ 698ms] After Glob.match **/spago.yaml Took about 550ms
[ 701ms] Selecting package aoc from ./
[ 702ms] Before FS.readYamlFile I Added this logDebug
[ 1540ms] After FS.readYamlFile Took about 800ms
[ 1541ms] Lockfile is up to date, using it
[ 1542ms] Found lockfile, using the package set from there
[ 1548ms]
✅ Selecting package to build: aoc
[ 1549ms] Package path: ./
[ 1550ms] Requested to install these packages: []
[ 1556ms] Downloading dependencies...
[ 1619ms] Building...
[ 1655ms] Running command:
purs compile --codegen corefn,docs,js,sourcemaps --json-errors .spago/p/aff-promise/3aa74e68e . . . . . . . . .
Src Lib All
Warnings 0 0 0
Errors 0 0 0
[ 2464ms]
✅ Build succeeded.
[ 2464ms] Looking for unused and undeclared transitive dependencies...
[ 2465ms] Running command:
purs graph .spago/p/aff-promise/3aa74e68e3e4c3e . . . . . . . . . . .
[ 2659ms] Called `purs graph`, decoding..
real 0m3,561s
user 0m7,615s
sys 0m1,242s