How to Choose the Best Compression Mode for Your Addressable Groups

Jan. 23, 2020
protect

UNITY ADDRESSABLES BENCHMARKING:
What Compression Setting To Use?

[Visit the original post at Unity Addressables Compression Analysis]

Today I'll show you how to select the best Unity Addressable compression method for your asset bundles.

In this post you'll learn:

  • How to reduce your asset bundle sizes

  • How to pay less to your greedy CDN

  • Should you use Uncompressed, LZ4 or LZMA?

So if you want to make the most of Unity addressable assets, you'll find this post useful.

Let's get started

Some time ago, I had the goal to optimize the memory usage of my game.

I had just too much content to fit in RAM.

So the natural way to go was the addressables route.

After putting some great effort into learning the system, I got a rock-solid system up and running. The result was a 50% memory usage reduction. Not bad.

But I was just barely scratching the surface of Addressables. There was so many features I was missing out.

So I went through all Addressable settings I could find.

One instantly caught my attention: the asset bundle compression mode.

Interesting,  this will prove to be useful, I said to myself.

There I clearly saw the opportunities Unity gave me. Unity gave me a powerful tool I could use to work on two crucial variables: storage size and CPU performance.

The three compression modes Unity offers you are: UncompressedLZ4 and LZMA.

I was intrigued. I really wanted to see what difference each mode did in real-life.

However, at the same time, I couldn't stop asking myself... is paying attention to this really worth my time?

Of course, the lack of Addressables documentation from Unity's side was to be expected. Busy developers, busy times. So as it often happens with Addressables, I couldn't count on them.

But in spite of the time investment, here's the deal: I decided I would make the research worth. I decided to make a benchmark to understand the real-world implications of Unity addressables compression modes.

And today I'll share with you the results of my investigation and my thoughts on the subject.

Quick Navigation (redirects to my blog)

Chapter 1: What Are Addressable Groups?

Chapter 2: What Is Addressables Compression?

Chapter 3: Benchmarking Addressables Compression

    Benchmark Setup

    Benchmarking Videos

    Benchmarking Audio

    Benchmarking Textures

    Benchmarking Text

Chapter 4: Conclusion

CHAPTER 1: 
What Is Addressables?

The default way of working with assets in Unity is by using direct references your content. Direct references load all assets automatically for you into memory. This is comfortable, but often leads to an explosion of memory consumption. And that, my friend, we want to fight.

Unity Addressables is the piece of technology game developers urgently needed to use indirect references.

Indirect references let you decide when to load and unload your content into and out of your memory. This gives youan immense control over memory.

icn_bomb_256

When we use Addressables, we aim to optimize memory usage.

But that's not all. Optimizing memory has many secondary benefits such as reduced loading times, less crashes and better user reviews, i.e. more cash to your pocket.

With addressables we organize all our content around asset groups...

And addressable groups are data buckets that contain our assets in a very specific way.

In every supermarket you'll see tons of assets: (warm) soda drinks, bread, juicy fruit, etc... These assets are packaged differently. You don't want to pour some cola into a paper bag you put bread into. Each packaging is well suited for certain types of goods.

Well, Coca-cola, fanta, water, bread, rice are your assets. And the different packaging you put your assets in are your groups. Groups dictate the way you store and deliver your assets, including compression settings (a looser or a tighter cardboard box).

Assigning assets to groups is easy as you can see below.

Assigning Addressable Assets to a Group

Addressables-Course-Groups-Assignation

Assigning Addressable Assets to a Group

To learn more about addressables, check my Addressables Tutorial (Learn the Basics).

CHAPTER 2: 
What Is Addressables Compression?

Your game might have thousands and thousands of assets. And as we saw, different content type require different packaging (groups).

Compression is one of the group parameters that will determine how efficiently Unity stores and loads your assets.

You can choose between the compression modes below:

  • Uncompressed

  • LZ4

  • LZMA

The question is then: how can you make the most of compression in your game?

char7

When you assign assets to a group, you are effectively packing these assets together like in a ZIP file.

And as you might recall with WinZIP and its family, you have several compression settings.

The strongest compression levels tend to save more data, but they also steal more resources to compress and decompress.

Therefore, you and I must always seek to hit the balance between storage space savings and performance cost.

Just like with WinZIP, you have to apply the same principle to Unity addressables compression settings.

So, which compression modes do you have?

  • Uncompressed means: you store the asset data as it is. Theoretically, this requires no further processing and just I/O bandwidth.

  • LZ4 is the second compression mode you have. I'ts an ultra-fast compression algorithm that achieves pretty good ratios for its performance cost. No wonder this is the default setting for new addressable groups.

  • But sometimes we're not happy with our Seat and want a Tesla instead. We're willing to toss a good handful of cash into what seems a more powerful alternative, no matter the cost. Here's where LZMA serves you

LZMA is a (theoretically) more potent Unity addressables compression algorithm. With LZMA we can potientally achieve greater compression ratios by throwing more hardware into the task.

Wondering where to find these compression modes? Have a look below, that's how I usually set my video groups.

JikGuard.com, a high-tech security service provider focusing on game protection and anti-cheat, is committed to helping game companies solve the problem of cheats and hacks, and providing deeply integrated encryption protection solutions for games.

Read More>>