r/Common_Lisp

why do my threads suck?

I have written a program to draw the buddhabrot ..

I was here the other day asking about how to increase heap size and was offered a lot of help so thanks for that ..

I have run my single threaded program and gotten good results on a small number of pixels and sample points ..

I rewrote the program to use sb-threads .. only due to Google making it extremely difficult to find information that I can use ..

example using do loops to start threads because I don't really understand the loop procedure .. and using named functions instead of anonymous ones ..

I got the run around .. bt or lparallel .. I went with sb-threads because I at least understand the concept .. I don't know how to write a procedure for lparallel

so I finally have a multi threaded program that uses 16 threads on my 5950 x 16 core processor ..

I'm running it now and it's using 59% of one core and 40 something percent of another ..

the question is .. how do I ensure I am using the processor to the best extent?

what are potential pitfalls I could have fallen into with my code?

thanks for reading appreciated ..

amateur al.

reddit.com
u/madmuppet006 — 9 days ago

What are rank-0 arrays used for?

I recently learned one can do:

What is this type of construct used forCL-USER> (make-array '() :initial-contents '(0 1 2))

#0A(0 1 2)
CL-USER> (aref *)
(0 1 2)
CL-USER> (array-rank **)
0 (0 bits, #x0, #o0, #b0)
CL-USER> (array-dimensions ***  )
NIL

What is this type of array used for?

reddit.com
u/mirkov19 — 10 days ago

Common Lisp universal time has just crossed 4,000,000,000!

Happy 4G seconds! (2026-10-03 07:06:40 UTC) Here’s to the next billion seconds of Common Lisp!

reddit.com
u/g000001 — 12 days ago
▲ 32 r/Common_Lisp+1 crossposts

UPDATE 2: CL-OBJC is reborn!

Back in March 2023 I posted an update on reviving cl-objc, the CFFI-based Common Lisp ⇄ Objective-C bridge originally written by Geoff Cant and Luigi Panzeri. At that point I had Hello World and Converter running, and I was stuck waiting on CFFI. Here's where it is now.

Repo: https://github.com/theangelperalta/cl-objc

Examples

All five examples run on Apple Silicon (arm64). There are no nib files or Objective-C sources; every app is written in Lisp.

  • Hello World: an NSWindow with buttons wired to Lisp callbacks
  • Converter: the classic Cocoa currency-converter tutorial
  • Circle View: a custom NSView subclass that draws text along a circle, with mouse interaction and animation (ported from an old Apple SDK sample)
  • Video Player (new): an AVPlayerView streaming HLS, plus a KVO observer class defined in Lisp. make builds it into a standalone executable.
  • Todo (new): an NSTableView whose data source and delegate are Lisp classes. On macOS 26 the list scrolls under floating Liquid Glass controls (NSGlassEffectView); older versions get a translucent material instead.

https://preview.redd.it/ffb5lv3yjysh1.png?width=960&format=png&auto=webp&s=27fb94abc0109850ddcb87377946e7c0afcf093f

What changed under the hood

  • arm64 struct-by-value: you can pass and return structs by value, and the dispatch was rewritten for the arm64 ABI. x86-64 support has been dropped.
  • Lazy CLOS bindings: import-framework now loads only the static bindings. CLOS classes and generic functions get generated on demand (ensure-clos-bindings), and they're cached and regenerated when their inputs change. This makes startup much faster than scanning the whole runtime.
  • ObjC exceptions: with-objc-exception-handling turns NSException's into Lisp conditions, so they no longer crash the image.
  • with-autorelease-pool: macro
  • Many fixes around BOOL marshaling, automatic Lisp-string → NSString conversion in untyped calls, with-super, and method-cache collisions
  • The test suite moved from FiveAM to Rove.

The CFFI situation

define-objc-method methods that take a struct by value (for example drawRect: with a CGRect) need CFFI callbacks that accept structs by value. Released CFFI still doesn't support that. My PR is still open: https://github.com/cffi/cffi/pull/351 (open since December 2022). I decided to use Qlot to pin a patched version CFFI, to get this out in the world in the meantime.

For now, the repo includes a qlfile that pins my fork, so setup is:

    qlot install
    sbcl --dynamic-space-size 4096 --load .qlot/setup.lisp

Obviously this isn't ideal, if anyone here can review the CFFI PR or help get it merged, that's the biggest thing blocking cl-objc from loading with stock Quicklisp.

What's next

  • Getting struct-by-value callbacks into upstream CFFI
  • Fewer dependencies on CFFI internals
  • More examples and docs
  • Real applications (LEM frontend, LLM harness, Graphing tools, etc.)

Feedback, issues and PRs are welcome, especially from anyone who has tried building Cocoa apps from Lisp before.

A.I. Disclaimer

A.I. was used for some of the recent work, but the original CFFI patch was worked by hand. That being said, goal here is to unlock the potential of Lisp development for native macOS development again (I realize there are paid alternatives).

reddit.com
u/acort3255 — 13 days ago

increase heap size sbcl

I am trying to draw a large buddhabrot for my daughter's birthday ..

I can draw a small one but when I increase the pixel count I get heap exhausted (no more space for allocation)

992739328 bytes available 2485248016 requested

I am using emacs slime and sbcl 2.30 on a Debian box with 128gb of ram ..

I have tried using (setq slime-lisp-implementations '((sbcl ( "sbcl" "dynamic-heap-size" "4096")))) and other numbers in there and still get the same error

I have tried setting the dynamic heap size in the console but I find it's a nightmare and doesn't work

how can I permanently increase the heap size for sbcl?

thanks

al

reddit.com
u/madmuppet006 — 13 days ago