HackerNoon
Follow
Optimizing the Ever-Growing Balance in an 11-Year-Old Game
War Robots stores game data, known as balances, for its vast array of content. These balances are divided into meta and core gameplay, with separate sets for default and Skirmish modes. Over eleven years, the game has accumulated a significant amount of content, leading to large balance file sizes. Initially, the meta balance was 9.2 MB and the core balance was 13.1 MB, totaling 44.6 MB for players to download.To address this, the development team analyzed balance file sizes, discovering that strings constituted a substantial portion. They developed tools to identify duplicated strings, which were found to be highly prevalent. The solution involved creating a unique string storage for each balance, replacing direct string instances with indices. This significantly reduced string usage count, improving efficiency.Further optimization involved reworking the data protocol, transitioning from MessagePack with string keys to a binary byte array with numerical keys. Empty collections were also removed, further decreasing data size and processing time. New features were implemented behind toggles, allowing for simultaneous support of old and optimized balance versions. Rigorous testing using reflection ensured that both balance versions produced identical values.These optimizations resulted in substantial file size reductions, with meta balance dropping to 1.28 MB and core balance to 2.22 MB. Deserialization times were also drastically improved, and the memory required on the client side decreased. The team concluded that careful data management and the elimination of redundancy, particularly with strings, are crucial for efficient data transmission and cost savings.