Could Cargo use GPUs to compile large projects more quickly?

This might not be even remotely feasible, but I thought it wouldn’t hurt to bring it up. I had a thought yesterday that it might be possible to speed up compilation times of large projects by utilizing a user’s GPU (if present) to parallelize compilation more so than the user’s CPU would allow.

I don’t really know how compiling works behind the scenes, so this may be an impossible suggestion, but I do often see my computer using all cores to compile everything, and I wouldn’t be surprised if the greater parallelization afforded by a GPU would drastically reduce compilation times in some of the largest projects.

GPUs are faster only for problems that can be expressed as lots of identical, independent, simple computations with almost no conditional code.

Code compilation is almost an exact opposite of that: every line of code is different, influences compilation of other lines of code, and there’s a lot of complex logic behind all of it. Trying to do that on a GPU would be a slow mess.

4 Likes

Some more discussion on this topic on SO.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.