Skip to content

Conversation

bamboo
Copy link
Member

@bamboo bamboo commented Jun 21, 2024

Apply snappy compression to Configuration Cache entries

Compression and encryption are offloaded to a separate thread, utilizing a pool of byte buffers capped at a maximum memory working set of 16MB.

The resulting files are 1/5th of their original size. Storing might be marginally slower in some cases, but loading is as fast or faster in all tested scenarios.

Reviewing cheatsheet

Before merging the PR, comments starting with

  • ❌ ❓must be fixed
  • 🤔 💅 should be fixed
  • 💭 may be fixed
  • 🎉 celebrate happy things

@bamboo bamboo added a:feature A new functionality in:configuration-cache Configuration Caching a:performance-improvement Performance improvement potential labels Jun 21, 2024
@bamboo bamboo added this to the 8.10 RC1 milestone Jun 21, 2024
@bamboo bamboo self-assigned this Jun 21, 2024
@bamboo
Copy link
Member Author

bamboo commented Jun 21, 2024

@bot-gradle test APT

@bot-gradle
Copy link
Collaborator

I've triggered the following builds for you. Click here to see all build failures.

* Determines the maximum memory working set: [bufferCount] * [bufferCapacity].
* The default maximum working set is `32MB`.
*/
val bufferCount = System.getProperty("org.gradle.configuration-cache.internal.buffer-count", null)?.toInt()
Copy link
Member

@abstratt abstratt Jun 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? 1 million buffers that are 32 bit long each? Normally, I'd expect the other way around.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? 1 million buffers that are 32 bit long each? Normally, I'd expect the other way around.

Yes, perhaps the term buffer is not the best choice here. A better analogy might be of a packet (like in UDP). These are used to quickly send the encoded information from the producer to the writer thread for compression >> encryption >> disk IO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abstratt Please take another look, I changed the code to the packet analogy.

Copy link
Member Author

@bamboo bamboo Jun 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32 bit long

bytes

Copy link
Member

@mlopatkin mlopatkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now see that the graph walking in smaller builds is probably stuck on waiting for the writer thread to finish compression. We still may win something back by tweaking compression ratio, but I don't have better ideas.

} finally {
// in case of failure, this releases some memory until the
// producer realizes there was a failure
ready.clear()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 neat!