I noticed that when I try to build a project, only one core is being used in my laptop. I’m using zig version 0.14.0-dev.2851+b074fb7dd and just tried building zls master branch and I got this CPU usage during the build:
To be clear the Zig compiler pipeline is multithreaded in various ways. For example:
All of the AstGen phase of the pipeline is fully dispatched per-file.
All the C objects that need to be compiled happen on the thread pool.
Any libc artifacts are created by a worker from the thread pool.
Some backends have been refactored to support “separate codegen thread” which means semantic analysis and codegen happen simultaneously.
Any build.zig steps that can be run simultaneously will be.
However there is a bottleneck in semantic analysis of the compiler. Only one thread at a time can work on semantic analysis, across all of the Zig code in a given compilation. One goal for the future will be to introduce parallelism into this component as well.