HDRP build time issues

Greetings everyone, I am facing an issue with my HDRP build. The current build time can take up to 20 hours. I attempted shader stripping as a solution, but unfortunately, it did not yield the desired results in reducing the build time. Could someone assist me in optimizing the build time?
9016492--1243321--upload_2023-5-16_13-35-48.png

There is not a lot of information in your post, is shader variant building actually the majority of your build times or not?
If yes and you don’t have big scenes or otherwise content that could lead to this many variants being built, make sure to not have unnecessary shaders set in your projects to always be built (project settings → graphics → always included shaders).
If this is a professional project, you should get a dedicated build machine with the fastest CPU you can get your hands on and build from CLI, in our case the build times are considerably lower this way.

1 Like

Noteworthy: op say it’s a HDRP build but the progress bar shows “Universal Render Pipeline” (URP).

1 Like

That is the problem. Do you know how to remove URP shader variants from build?

I don’t. I don’t even know if this is expected or not. Check if you have URP in the Package Manager. If so, remove it.

It may also be worth a shot searching for files with “ForwardLit” in the name in the entire project tree (not just assets) in case someone copied URP package contents into another package or the Assets folder.

And then check general Unity project performance considerations. Things like:

  • Project, Temp and build output folders are on (SATA or PCIe) SSDs and ideally on separate drives (and none of them connected via USB, Firewire, etc)

  • if not: Try building to another physical drive or move the project to a faster drive

  • Project root folder is excluded from Antivirus (live/online scan)

  • Debugger is not attached while making a build

  • Machine isn’t running out of resources: ie it isn’t all of the time using 100% of one of: CPU, GPU, RAM, disk space or usage (according to Task Manager)

  • Try making a build on another machine and check if it takes the same time (roughly adjusted to each machine’s specs)

  • Try upgrading (copy of) the project to the latest patch release that you are on (eg 2021.3.10 => 2021.3.latest), or even upgrade to a higher major/minor.

How big is your project anyway? Just the contents of the Assets folder. I would say if it isn’t at least 10+ GB then I would be very suspicious of a 20 hour build time. Either the machine has a problem, or the project itself is bogged with something that slows the build down to a crawl.

2 Likes

thanks for

Thank you for your response. I have found a solution by deleting the URP folders from my project.

Unity caches the compiled shader variants into the Library folder. Your first build will be the slowest with additional builds only needing to compile any new variants.

Worst I saw was around 2.5 hours with a 30 GB project on an AMD Ryzen 3600 w/ 32 GB RAM. After upgrading to a 5950X w/ 64GB RAM the first time build went down to 45 minutes. Subsequent builds were typically 1/5th the time so 30 minutes for the 3600 and around 10 minutes for the 5950X.

1 Like