Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Speeding up the Unreal editor by… not using unnecessarily secure hash methods

When optimizing software, it's often beneficial to avoid areas that are already well-optimized and instead target lesser-known or under-profiled sections. This approach proved fruitful when working on the Unreal editor. While profiling, the author found themselves skipping over functions related to "Shader Compilation" or "Shader Source" during profiling sessions.

Shader compilation is known to be a lengthy and intricate process, and they trusted that the experienced team at Epic had already optimized these areas. However, upon closer inspection, they discovered that a SHA1 hash algorithm was being used to hash shader source code during the compilation process. While SHA1 is a cryptographically secure hashing algorithm, it has been shown to be vulnerable and is not the most efficient choice for hashing tasks.

The data being hashed – shader source code including comments and copyright notices – is not sensitive, meaning there is no need to use a cryptographically secure hash. Therefore, switching to a faster hash algorithm, such as xxHash, could potentially yield significant performance improvements. After implementing this change, the author saw a drastic reduction in CPU time spent on hash calculations, with the modified version being eight times faster than the original.

The updated version also had the added benefit of smaller stored hashes (8 bytes instead of 20 bytes). Although the change needed to be adapted in multiple places within the codebase, and a minor compile error was fixed for non-editor builds, the overall effect proved to be a successful optimization. Most notably, the Epic Games team accepted the pull request, integrating the change into their main branch.

Rewritten by urgent.news; may contain errors — check the original.

Source: larstofus.com

Read the original at larstofus.com →

Report a problem with this story

More in Tech

More from Monday 12 October →