Crystal language introduces Execution Contexts, a new multithreading model replacing the legacy 'preview MT' scheduler. Three context types are provided: Concurrent (fibers run concurrently on one thread), Parallel (fibers scale across CPU cores with work stealing), and Isolated (a single fiber owns a dedicated thread). The default context starts concurrent on one thread to avoid breaking existing apps, but can be resized for parallelism. Key breaking changes include fibers being able to switch threads in parallel contexts, schedulers moving threads on blocking syscalls like getaddrinfo, and removal of the spawn(same_thread: true) argument. The new scheduler is faster than all legacy schedulers and auto-scales to CPU cores roughly every 100ms. Legacy preview_mt and without_mt flags remain temporarily supported but are discouraged.

8m read timeFrom crystal-lang.org
Post cover image
Table of contents
The default execution contextWhat do execution contexts provide?Can execution contexts communicate?How are execution contexts different from the ‘preview MT’ model?What changes?Breaking changesNotes
476 Impressions