Skip to content

Build: Store multiple Gradle CC entries #4824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

hfhbd
Copy link
Contributor

@hfhbd hfhbd commented May 3, 2025

Subsystem
Build, Gradle

Motivation
Gradle only stores the last CC entry by default. It should store multiple entries to faster switch between tasks, like test and apiDump.

Copy link

coderabbitai bot commented May 3, 2025

Walkthrough

A new configuration property, org.gradle.configuration-cache.entries-per-key=100, has been added to the Gradle properties file. This update supplements existing configuration cache settings and does not modify any logic, error handling, or exported entities in the codebase.

Changes

File(s) Change Summary
gradle.properties Added org.gradle.configuration-cache.entries-per-key=100 property.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
gradle.properties (1)

48-48: Document rationale and trade-offs for 100 entries.

Caching up to 100 entries per key can speed up switching between tasks but may increase disk usage and cleanup overhead. Consider adding an inline comment here or updating the project’s documentation to explain why 100 was chosen and any expected impact.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 185a4a5 and caf810d.

📒 Files selected for processing (1)
  • gradle.properties (1 hunks)
🔇 Additional comments (1)
gradle.properties (1)

48-48:

❌ Incorrect review comment

Ensure compatibility with supported Gradle versions.

The org.gradle.configuration-cache.entries-per-key property was introduced in recent Gradle releases. Please confirm that your Gradle wrapper (gradle/wrapper/gradle-wrapper.properties) points to a version that supports this setting, and bump it if necessary to prevent unknown-property errors or warnings.


🏁 Script executed:

#!/bin/bash
# Extract the Gradle wrapper distribution version
grep '^distributionUrl' gradle/wrapper/gradle-wrapper.properties | sed -E 's|.*/gradle-(.*)-all\.zip|\1|'

Length of output: 186


🌐 Web query:

site:docs.gradle.org "entries-per-key"

💡 Result:

Here are relevant details from the Gradle documentation regarding the "entries-per-key" property:


entries-per-key in Gradle

The phrase "entries-per-key" typically appears in the context of Gradle's Build Cache or Configuration Cache, particularly with the file-system build cache backend.

File System Build Cache Settings

Within the configuration options for the file system build cache, you can find the setting:

entries-per-key

  • Property: entries-per-key
  • Scope: build cache (file system backend)
  • Type: Integer
  • Description:
    Specifies the maximum number of cache entries per cache key that will be stored in the directory. If more entries are created for a key, the oldest entries are deleted. This helps limit the size and disk usage of the local build cache.
  • Default value:
    1 (Only the most recent entry per key is kept)

Example Configuration in settings.gradle:

buildCache {
    local {
        directory = "${rootDir}/.gradle/build-cache"
        removeUnusedEntriesAfterDays = 30
        entriesPerKey = 2 // Keep up to two entries per key
    }
}

Documentation Reference

For more details, see:


In summary:
The entries-per-key property is used to control how many build cache entries are stored per key when using the file system build cache backend in Gradle. It helps manage cache size and ensures old cache data is cleaned up efficiently.


🌐 Web query:

site:docs.gradle.org "org.gradle.configuration-cache.entries-per-key"

💡 Result:

Based on the provided search results from docs.gradle.org, the property org.gradle.configuration-cache.entries-per-key is not mentioned in the available documentation. However, here's a summary of relevant configuration cache settings from the Gradle User Manual:


Configuration Cache Settings

  • org.gradle.configuration-cache:
    Enables/disables the feature entirely (true/false)1.
  • Key Configuration Inputs:
    Build scripts, environment variables, system properties, files read during configuration, and JVM parameters2.
  • Serialization:
    Uses optimized serialization for task graphs and avoids Java serialization for performance2.
  • Parallelization:
    Parallel task execution and cache entry loading (enabled by default from Gradle 8.11)3.

For advanced cache tuning, Gradle's documentation21 does not currently describe a property for limiting cache entries per key. Such a setting might relate to internal implementation details or future updates not covered here. Check the latest Gradle release notes or issue tracker for additions beyond the provided documents.

Citations:


Remove invalid Gradle property

The org.gradle.configuration-cache.entries-per-key setting is not recognized in any current Gradle release (it’s not documented in Gradle’s Configuration Cache or Build Cache guides). It appears to be an invalid property. If your goal is to cap build‐cache entries per key, use the Gradle DSL in settings.gradle:

buildCache {
  local {
    entriesPerKey = 2
    //
  }
}

Please remove or correct this line in gradle.properties:

  • gradle.properties:
    org.gradle.configuration-cache.entries-per-key=100

Likely an incorrect or invalid review comment.

Footnotes

  1. Gradle Build Environment Properties 2

  2. Gradle Configuration Cache Docs 2 3

  3. State of the Configuration Cache (Gradle Blog)

@osipxd osipxd self-assigned this May 4, 2025
Copy link
Member

@osipxd osipxd left a comment

Choose a reason for hiding this comment

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

Thank you for the PR! Nice undocumented option :)
It's the first time I’ve seen this option, so I have some questions.

Could you explain why you chose 100 entries? I haven't found any documentation, but noticed that Gradle itself uses only 2 entries per key. Won't 100 entries per key affect the size of the stored Configuration Cache? Am I understood it correctly that the use-case when this property should help is when we switch from one branch to another?

@hfhbd
Copy link
Contributor Author

hfhbd commented May 5, 2025

@osipxd Good question. It is still undocumented because the impact is not fully tested: gradle/gradle#28022 (comment) (gradle/gradle#31086). I use 100 for middle-size JVM projects, maybe Ktor needs a lower value (because it is a massive MPP project).

@osipxd
Copy link
Member

osipxd commented May 6, 2025

Thank you for the additional context! Let's start with 3 and check how it affects CC hit/miss rate.
Could you also enable org.gradle.configureondemand in this branch? This should make CC entries smaller and more reusable in some cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants