libera/#commonlisp - IRC Chatlog
Search
10:38:19
phantomics
What's the difference under the hood between doing C-c C-k to compile a file and doing C-x C-e on an expression in Emacs with Slime? When doing the former, the compiler will print all the available style warnings. When doing the latter, it will print much less, usually only the serious warnings.
10:39:13
phantomics
I also find that C-x C-e is much faster to compile in certain cases than C-c C-k, even if I'm comparing compiling a file with just the one expression in it to doing a C-x C-e on that expression
10:41:01
_death
C-x C-e simple sends the string representation of the form to swank, which reads and evaluates it
10:41:55
phoe
but I think the difference is that C-c C-c creates a new file under the hood, copypastes the single form into it, compile-and-loads it, C-c C-k does that with the whole file, and C-x C-e, what _death said
10:43:43
_death
I tend to use C-M-x, which is like C-x C-e but has a special case for defvar.. I almost never use C-c C-k, and sometimes use C-c C-l which just loads the file
10:45:45
phantomics
Any idea why there would be a massive difference in the time taken to compile via sending a string to swank with C-x C-e and doing C-c C-c? A difference of 19 sec vs. 3 sec
10:48:44
phantomics
Although when I've made changes to stuff in the material to be compiled, I've never not had those changes manifest when doing C-x C-e
10:51:05
phantomics
So interprets rather than compiling? I'm wondering doing a full compilation compiles many dependencies of the compiled code, thus the long time taken
10:51:53
lisp123
usually there are phantomics: fasl files already created I thought, so the dependencies shouldn't recompile?
10:52:38
splittist
Any suggestions for interesting codebases using postmodern I could read to learn from?
10:53:01
_death
phantomics: you can profile compilation the same way you profile ordinary code (say with sb-sprof)
10:53:40
splittist
phantomics: the sbcl manual has a chapter on it: http://www.sbcl.org/manual/index.html#Profiling
11:06:04
phantomics
Thanks _death and splittist, when I do (sb-sprof:with-profiling (:loop nil :show-progress t :max-samples 100 :report :flat) ...) it returns no samples and prints the message "No sampling progress; run too short, sampling frequency too low, inappropriate set of sampled threads, or possibly a profiler bug." This is even when the actual elapsed time is around 19sec
11:07:13
phantomics
Maybe because the code generated by the compilation includes an (eval ...) form?
11:10:30
phantomics
It contains (april-load (with (:space numeric-lib-space)) (asdf:system-relative-pathname :april-lib.dfns.numeric "numeric.apl"))
11:11:32
_death
it should contain the code to compile the form that takes time to compile... like a call to compile-file or compile
11:19:22
phantomics
Interestingly, the actual April compilation, as much as I can measure, is relatively fast even after deleting the relevant .fasl file. Compiling that numeric.apl file without running the compiled code takes only 606 cycles according to (time), there must be something wrong with that but the time I perceive is still under a second
11:20:34
phantomics
When I just return the compiled code, no (eval) happens either, so I don't know why it measures so little activity, I know compiling all that APL code takes more than 606 cycles
11:42:30
phantomics
max-samples of 100000 still returns 0 samples, whether I just compile or compile and load
11:44:31
phantomics
Even up to 10 mil samples returns nothing, it doesn't take that long to compile, I perceive a time of about 19s to compile and load it but it's not reflected, really strange
11:47:05
phantomics
When I (time) the compilation, it was just taking 606 cycles, measured time was flat 0 of course
11:47:42
_death
well, difficult to know the issue without more context.. like the full with-profiling form.. also note that the default sampling mode is :cpu .. maybe try with :time if you have some sleeps or weird I/O
11:48:11
phoe
phantomics: does the issue still happen in the terminal, to rule out any emacs/slime/sly interaction?
11:48:27
phantomics
I tried timing compilation and loading, and despite my perceived several seconds it tells me 144,628 cycles elapsed and 0 seconds
11:56:16
phantomics
Using :mode :time helped, though it's still weird. It returned just 33 samples with several seconds of time I perceived
11:57:46
phantomics
And 84% of the time was spent in "foreign function syscall", there's also some threading stuff in there so I think what's measured is from lparallel
11:59:19
phantomics
That's the ticket, when I measure (macroexpand `(april-load ...)) with the compile-only option, I get 0.316 seconds of real time, 1,190,337,574 processor cycles. That's more like it
12:01:19
phantomics
But it's still weird... when I do sb-sprof:with-profiling of the macroexpansion, it's very fast, even if I'm doing compile and run
12:02:38
phantomics
The macroexpansion takes 0.6 sec, and the compiler outputs some useful info, but when I compile and run without macroexpanding, the profiler returns nothing and I perceive ~19sec
12:09:50
phantomics
Lots of time spent in gethash, puthash, sb-c::walk... sounds like that's what I need to look at
12:30:08
jcowan
minion: memo to lisp123: when C-M-x is asked to evaluate a defvar, it overrides the normal behavior of ignoring any changes to it, and treats it like defparameter or setf.
15:56:33
dorem
hi ! is there some way to load a system with ASDF without compiling, only evaluating the expressions? I mean if one is using a CL implementation with an interpreter ?
15:57:55
beach
Even a system with no compiler must supply a COMPILE-FILE function. What it does is then not compile to native code, of course.
15:58:49
beach
Also, what implementation are you using? Some implementations don't even have an interpreter.
16:01:11
beach
I know ECL has a bytecode interpreter, but I don't know whether it has a direct interpreter. Maybe jackdaniel can help us.
16:01:14
Bike
you're probably better off reading the manual for that. ECL's manual has a whole section on the interpreter.
16:01:45
Bike
unless ecl has some kind of usable interface for inspecting interpreted code, i don't think interpreting code is going to tell you much about how the interpreter works
16:02:04
dorem
Bike: ok, I'm doing that but is possible to configure ASDF to do that in general, in case I want to the same for other implementations with an interpreter?
16:03:26
jackdaniel
but mind, that the code compiled to the bytecode is still compiled (i.e not interpreted); bytecodes compiler performs a so-called "minimal compilation"
16:03:28
Bike
asdf is flexible enough that you can probably get it to use LOAD instead of COMPILE-FILE, but i don't know if there's any way to do that built in
16:03:48
Bike
if i really wanted to look at interpreted functions i'd probably eschew looking at whole systems anyway, and just eval or load smaller things myself
16:03:51
jackdaniel
if you want to enforce using bytecodes compiler, then do (ext:install-bytecodes-compiler)
16:04:39
beach
ASDF would have to use some implementation-specific functionality to make sure the code is not compiled, because there is no standard functionality to control that.
16:04:55
jackdaniel
and if you are interested in the implementation of both the compiler and the interpreter of bytecodes, check out files src/c/compiler.d and src/d/interpreter.d
16:05:09
Bike
ah, here is where it is mentioned in the asdf manual https://asdf.common-lisp.dev/asdf.html#How-do-I-mark-a-source-file-to-be-loaded-only-and-not-compiled_003f
16:06:05
beach
dorem: You could also ask here for general principles of interpretation vs compilation.
16:06:28
jackdaniel
I think that they want to see how ecl's bytecodes interpeter works, that's why they have confused interpretation and compilation (it is just a guess though)
16:08:01
beach
As far as I know, ASDF then just uses LOAD on the source, but that can still result in compilation.
16:08:10
dorem
thanks a lot Bike, jackdaniel, beach! I think that link is what I was looking for, let's see how much interpreted code can create for my projects ;)
16:08:57
beach
Speaking of which, does the standard require minimal compilation even for interpreted code?
16:10:23
jackdaniel
http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_i.htm#interpreted_implementation
16:11:17
Bike
requiring minimal compilation would pretty much rule out using a conventional interpreter, which seems like the kind of restriction the standard usually avoids