On Thu, Aug 13, 2026 at 01:40:42AM +0200, Waldek Hebisch wrote:
>
> The above is just a preliminary trial. I am looking at deeper
> change that keeps more things in memory, that hopefully will
> speed up build for any Lisp that we use.
I have now a better patch (attached). Using it with sbcl serial
part of algebra build on my machine takes about 3.2s, the rest
of algebra build is parallel. This is still proof of concept,
tuning may change a bit (in particular this patch compiles files
that we are going to load, so favours sbcl and Clozure CL). There
are two new options to Spad compiler: ')nolispcompile' which
skips compilation of generated Lisp, and ')noopt' which skips
inlining optimizations (needed for bootstrap). Part changing
extention from '.lsp' to '.lisp' is half done, if we want to
do this there is more work. There is some degradation of output,
it seems that is some cases that worked previously inlining
no longer works (that needs to be investigated).
Some extra comments: this patch uses option to compile .spad
files without creating an NRLIB. This is used for domains,
because generated code is (and was) not needed and patched
compiler uses database info in memory instead of loading it
from index .KAF. More precisely, previously after generating
NRLIB Spad compiler erased database info it had about freshly
compiled constructor and load new info from index.KAF. With
the patch info that would be written to index.KAF is used
to update in memory database. In case of categories we
later need executable code and due to the way Spad loading
works we need index.KAF. So patched compiler writes and
compiles Lisp file and writes index.KAF, but update database
in memory. Path also causes compiler to generate database
info for default packages, which allows generation of
database just after 'processGlobals'. Database is generated
using data present in memory. In effect, we avoid reading
data that we have previously written and skip much of
writing activity. Since for compilation we use already
parsed code (needed for previous 'processGlobals' that did
less work) we save parsing algebra files with is about 1
second. There is slightly more compiling going on, but for
sbcl balance is rather positive, that is we save about 5
seconds of CPU time. The second chande is at Makefile
level, since we have database and category NRLIB-s we
can compile category files in normal mode in parallel.
I also changed Makefile to compile inlinable domains in
parallel. The last step affect what is inlinable.
If we compile inlinable domains serially in a single
image, then there inlining between those domains which
probably leads to more inlining possibilities later.
And AFAICS when inlinable domains are compiled serially,
then exactly the same things are inlined as before.
Compiling in parallel seem to need more CPU time, but the
effect is not big and with '-j 20' there is clear gain
in real time. It is not clear how much increase is
real: with hypertreading 2 logical cores running on a
single physical core compete for resources so are slower
than 2 independent core. Also, on sigle threaded work
CPU inreases clock frequency, so one get more cycles in
given time unit. But there are also reasons for real
increase: each compilation process must separately read
its database info instead of reusing already present
info. Similarly each compilation process must load
code that is needs.
Anyway, with that patch as is and using sbcl I can compile
FriCAS on my machine in 45-46 seconds (compared to 61-62
when using current trunk). After changing variables in
Makeifile.in to load Lisp instead of fasl-s, using ECL I get
real 3m13.548s
user 34m28.368s
sys 3m1.747s
where real time is way better than the trunk and slightly
better than the best ECL time that I had previously. CPU
time is larger, so with ECL on machines with lower core
count it may be better to do more work serially.
To put it differenly, building database in memory seem to
be pure win for any Lisp that we use (we basically skip some
work that was done previously). OTOH parallel build
apparently may increase build time, depending on core count
and Lisp that we use.
--
Waldek Hebisch