clasp-developers / clasp

clasp Common Lisp environment
https://clasp-developers.github.io/
2.56k stars 144 forks source link

Performance - inquiry #1098

Open mdbergmann opened 3 years ago

mdbergmann commented 3 years ago

Hi.

I've recently (last week or so) built clasp on macOS. I've noticed that startup is very slow and general performance even compared to CCL is slow as well.

So I was wondering whether the built I made is a debug version or so. Is there a way to tweak the performance of clasp?

kpoeck commented 3 years ago

See https://github.com/clasp-developers/clasp/wiki/Relative-Compile-Performance-of-clasp

In summary:

mdbergmann commented 3 years ago

OK, thanks. Can you tell what is the expectation, or what is the goal for clasp to reach for compile time and runtime performance? Since Clasp inherits from ECL I'm assuming that runtime performance will be that of ECL, or maybe a bit faster?

kpoeck commented 3 years ago

Code generation is totally different from ECL.

The expectation is that generated code is quicker than ecl. If you look at the table I mentioned in the wiki (clasp is at the right), you see that this sometimes is the case, but in the majority of cases ecl is still quicker.

mdbergmann commented 3 years ago

Thank you for the info.

drmeister commented 3 years ago

mdbergmann - Hi Christian Schafmeister here (lead designer). Clasp is very different from ECL in terms of how it generates code. Clasp uses the llvm C++ API directly and generates LLVM-IR and does just-in-time compilation as well as ahead of time compilation. ECL generate C code that is then compiled by the clang compiler and that uses the same llvm library we do. The goal for clasp is to get the best runtime performance we can - better than ECL and then SBCL. The goal for clasp compile time is to approach ECL. Both ECL and Clasp ultimately run through the llvm library and so it's unlikely that we can do better because llvm will become the bottleneck.

drmeister commented 3 years ago

I also just noticed that kpoeck's compilation timings are not using the parallel compiler. By using the parallel compiler (the default) compilation can be sped up by 1.5 to 3 fold. Comment out USE_COMPILE_FILE_PARALLEL=False

mdbergmann commented 3 years ago

Thank you @drmeister I think the USE_COMPILE_FILE_PARALLEL is already enabled for osx/darwin.

kpoeck commented 3 years ago

I documented it wrong ib the wiki page, is now fixed

mdbergmann commented 3 years ago

FWIW, I had to use this config:

#LLVM_CONFIG_BINARY = '/usr/local/Cellar/llvm/9.0.1/bin/llvm-config'                                                                                                                
PREFIX = '/opt/clasp/'
# set this to false if you have less than 16 GB of RAM                                                                                                                              
USE_PARALLEL_BUILD = True
USE_BUILD_FORK_REDIRECT_OUTPUT = False
#CLASP_BUILD_MODE = 'object'                                                                                                                                                        
USE_COMPILE_FILE_PARALLEL = True
REQUIRE_LIBFFI = True
CPPFLAGS = [ "-Wno-nullability-completeness"]

It seems 'configure' figures out by itself where llvm is. CLASP_BUILD_MODE = 'object' didn't work here on macOS Big Sur.

kpoeck commented 3 years ago

I have not experienced that configure figures out where llvm is, but am glad that it works for you. I don't have bigSur yet, perhaps its different there.

I honestly believe you don't need USE_BUILD_FORK_REDIRECT_OUTPUT = False.

mdbergmann commented 3 years ago

That is possible. I took the the example config from the wiki and adapted until it did build.

kpoeck commented 3 years ago

my own fault :-) I fixed the wiki entry now