I’m working with a Swift package that relies heavily on a library with numerous macros (uses TCA). The package must fully compile before the main app can start building. However, the build timeline shows inefficiencies: 25 of the package’s files are batched and processed on a single core, leaving other cores idle. As shown in the image below, this results in an empty space where only one core is active, sometimes wasting 30 seconds of build time.
To address this, I’m considering splitting the 25 files with macros into smaller ones, such as dividing them into 75 smaller files. My reasoning is that Swift’s compiler batches a fixed number of files for compilation, and by increasing the number of files, the workload can be distributed across more cores, reducing idle time and improving parallelism.
Does this approach sound reasonable for optimizing parallel compilation, or are there alternative strategies to achieve better utilization?