libera/#commonlisp - IRC Chatlog
Search
17:13:44
francogrex
Hi, I am trying this "optimized" function but it doesn't deliver at fib n > 43, is there a C long long equivalent (not bignum)? (defun fib (n) (declare (optimize (speed 3) (safety 0)) (type fixnum n)) (if (<= n 1) 1 (the fixnum (+ (fib (1- n)) (fib (- n 2))))))
17:15:07
jackdaniel
I think that a part of your problem comes from the fact that you compute same values too many times
17:16:12
jackdaniel
you can have a performant recursive version, but then you need to either memoize results are build from the bottom (not from the top)
17:26:02
jackdaniel
i.e when you want to go from the bottom: http://turtleware.eu/static/paste/0f7ed93a-fib.lisp.txt
17:28:36
jackdaniel
(and for bigger values most of the time will take printing the number, not the actual computaiton)
17:33:11
xach
jackdaniel: not at the moment, but adding new source control systems is generally fairly easy due to the Power of CLOS and a protocol for "upstream source" objects.
17:36:13
francogrex
I guess I was looking at the wring code here; the not optimized: https://github.com/drujensen/fib
17:39:16
francogrex
they should really choose other functions to benchmark than those that can be done with magic tricks like this one
17:40:02
jackdaniel
and the version with labels does not put rec in the tail position, so even when the implementation can support tail call optimization, it won't (because it can't)
17:40:49
francogrex
jackdaniel: I know, both lisp codes in the "optimized" there fail, badly written I guess
17:49:58
jackdaniel
well, almost, it doesn't handle fib(0), but fixing that is an excercise for the reader ,)
17:51:51
jackdaniel
also a memoized version: http://turtleware.eu/static/paste/cf23cbe0-fib.lisp.txt
17:52:14
jackdaniel
ACTION feels like a github copilot (without loundering the foss code bit though)
17:52:39
ck_
future historians will name us as a civilization that values this particular series very highly
22:00:21
pjb
https://quickref.common-lisp.net/lparallel.html#go-to-the-LPARALLEL_2024COGNATE_2236_2236PMAP-function
22:01:30
jmercouris
I’ll have to do some benchmarking to see when it actually makes sense to spawn new threads
22:03:00
jmercouris
Or will it be creating and killing threads every time I do some parallel operation
22:03:15
mfiano
You can use cl-cpus to set the thread pool worker count to the number of logical cores if you wish
22:04:18
mfiano
Well such testing could have wildly different results on different hardware. What you think is better than no parallelism could be worse across hardware / environment line
22:06:17
mfiano
So if this is for code to be consumed by others, I suggest you use use reasoning of how computers work over the numbers you see at one time on one piece of hardware running one OS on one implementation
22:14:05
mfiano
For example, if you were decoding a large image, instead of spawning a worker for each pixel, or for each row...figure how many "bands" you will need to allocate 1 band to each worker in your pool
22:33:17
lotuseater
pjb: this article by Kent Pitman you linked me yesterday was really interesting, thx
22:41:43
lotuseater
I asked DeepL what "lisp machine style rubout handling" would be in German. It says "Lisp-Maschinenstil-Rubbelbearbeitung". :D
23:08:44
lotuseater
eta: why do you mean unlikely? but yes the translation is just funny and not very useful :D
1:17:23
jcowan
"Rubout handling" has to do with unparsing in reverse as you remove characters from the input stream, as older Lisp systems did
4:49:44
asarch
Ok. You get a new job and in the company's server there is no any Lisp (CLisp, SBCL, etc) at all. How would you compile the source code of SBCL in that situation?
4:51:07
asarch
Is there a way to do a cross-compile for the kernel? (Maybe you at your home with your PC...)?
4:53:08
moon-child
beach: cross compiling and installing a binary don't seem mutually exclusive to me. Any binary you install will have been compiled at some point; maybe by a cross compiler, maybe by a native one
4:58:49
moon-child
pjb: sbcl can be bootstrapped; I seem to recall hearing (maybe from beach?) that lispworks and allegro cannot be meaningfully bootstrapped in such a fashion. Which does make it an interesting question (if not a practical one, since lw and acl are not open source)
5:00:07
asarch
I mean, the image not the kernel (From Common Lisp Recipes, 16. Developing and Debugging: The main idea of developing in C OMMON L ISP is that the whole system is one “image” that you continuously modify until it fits your needs.)
5:00:13
moon-child
yeah, from the els paper: 'Rhodes claims that Allegro, Lispworks, [...] are only possible to build using older versions of the same system, and only using image-based techniques'
5:01:28
moon-child
asarch: many lisp compilers have the ability to save the in-memory image to a standalone binary. This is what sb-ext:save-lisp-and-die does in sbcl, for instance