Why is 'locking' more frequently used than 'merging' in game development?



In game development, 'merging,' where multiple people edit the same file and then combine the changes, is not used as much as in general software development. Game developer Alex Krillin explains why game development has its own unique workflow, due to factors such as binary files like images and 3D models, exclusive file locking, and massive data sizes.

Why Game Devs Don't Merge Files | Alex Kurilin

https://www.kuril.in/blog/why-game-devs-dont-merge-files/



In web service development, if person A rewrites button behavior and person B fixes error handling in the same file, Git compares the changed lines and automatically merges both changes if the modifications don't overlap. Even if the changes overlap, developers can manually review the differences and integrate the necessary content. This is possible because much of the program is stored as text, allowing for a mechanical comparison of the differences before and after changes. Similar merging is used in game development for code written in text formats such as C++.

On the other hand, games include character images, music, animations, 3D models, videos, visual effects, and materials. For example, if two people process an image file separately, it is difficult to automatically combine the color correction done by one person with the scratches added by the other, in accordance with the developer's intentions.

Images and audio are not strings that Git can compare line by line, but rather 'binary files' stored as data in a specialized format. Because changes in binary files cannot be compared line by line, if two people edit the same file, one person's changes must be discarded, or one person's changes must be manually reflected in the other's file. With complex materials, this could potentially result in the loss of several days' worth of work.

Unreal Engine's visual scripting feature, 'Blueprint,' suffers from the same problem. Blueprint is a system for assembling game behavior by connecting box-shaped 'nodes' that represent processes with lines. Because it can be used without writing text-based code, game designers and artists can also create processes. A difference display function is available to compare changes, but it is difficult to automatically merge separate changes, and necessary changes must be reflected manually while looking at the differences.

'Exclusive locking' is used to prevent overwriting work. If someone checks out a character's texture for editing, another developer cannot modify the same texture until they have finished their work. This method prevents accidents by prohibiting simultaneous editing altogether, rather than merging multiple people's work later.



Perforce P4, a version control system widely used in medium-to-large-scale game development, uses a central server to manage files and their lock status. When a developer checks out an exclusive file, other members cannot check out the same file until the developer submits their work or reverts changes to unlock it. Krillin explains that Unreal Engine has built-in integration with Perforce P4, making it a familiar system for artists in the game industry.

While exclusive locks can prevent overwriting accidents, they introduce other problems. If a developer locks a main character's file for several days, animators and game designers who need the same file cannot proceed with their work. If the lock is forgotten before leaving work, members working in different time zones may be unable to edit the file.

In game development, to reduce waiting times caused by locking, it's important to design files so that many functions aren't grouped together in one file, but rather divided into smaller files based on their function. For example, if you cram health, inventory, movement, and special abilities into a single character file, changing any of these functions will require locking that same file.

In Unreal Engine, you can use 'Actor Components' to add independent functionality to 'Actors' such as characters, allowing you to separate the handling of health and inventory into different parts. Developers modifying the health system only need to lock the health component, while team members responsible for movement and inventory can continue working in separate files. This not only increases reusability but also reduces waiting times between developers.

Working branches, commonly used in general software development, play a smaller role in game development. Because many binary files are difficult to automatically merge, editing the same material on separate branches doesn't allow for final integration. Often, the entire team works on the main branch, locking only the necessary files.



In game development, the sheer volume of data in the entire project also impacts the development process. A single 4K texture can reach tens of megabytes, and the entire game under development can range from several terabytes to tens of terabytes. Downloading all the data every time you 'build' the game into an executable form is not practical. Therefore, for continuous integration (CI), which incorporates changes and automatically assembles the game, a method is employed that leaves a P4 workspace and synchronizes only the changed data. In the distribution version, the data is converted for the target platform, and adjustments are made to size and format, and unused materials are excluded, so the amount of data that users download is smaller than the entire development data.

Human agreements are essential, such as remembering to unlock files, keeping track of frequently edited files, and assigning specific individuals to handle certain materials. In text-file-centric development, conflicts in work were handled by merge functions like Git, but in game development, these are avoided through file design and team communication.

Krillin states that game development isn't behind general software development; rather, it employs different methods to cope with the constraints of dealing with massive binary files. While automated merging technology may develop further, currently, exclusive locks that prevent multiple people from editing the same binary file simultaneously are a practical solution to protect several days' worth of work.

in Software,   Game, Posted by log1d_ts