Skip to content

feat: use new cache policies - #8725

Merged
jedevc merged 3 commits into
dagger:mainfrom
jedevc:new-cache-policies
Oct 28, 2024
Merged

jedevc merged 3 commits into
dagger:mainfrom
jedevc:new-cache-policies

Conversation

@jedevc

@jedevc jedevc commented Oct 17, 2024 •

Copy link
Copy Markdown
Contributor

Fixes #7711.

This PR updates buildkit to use the new complex GC policies introduced in moby/buildkit#5079 moby/buildkit#5359, which allows us to set a more complex default policy that works out-of-the-box in more scenarios.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sipsma I've updated these tests to also include examples of the new policies - but would appreciate a close look at these to make sure they're doing what I think they're doing.

@jedevc
jedevc force-pushed the new-cache-policies branch 2 times, most recently from d5dbfc1 to 3793a02 Compare October 18, 2024 13:44
Comment thread engine/server/gc.go
Comment on lines +198 to +199
const (
diskSpaceReservePercentage int64 = 10
diskSpaceReserveBytes int64 = 10 * 1e9 // 10GB
diskSpaceFreePercentage int64 = 20
diskSpaceMaxPercentage int64 = 80
diskSpaceMaxBytes int64 = 200 * 1e9 // 200GB
)

@jedevc jedevc Oct 18, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The old policy is very simple - use 75% of the disk.

The new policy is more complex:

  • Always allow use of 10% or 10GB (whichever is smaller, to handle disks that are very small, like docker-desktop's defaults) - dagger's cache will never be forced to reduce below this amount
  • Never consume more than 80% or 200GB (whichever is smaller again) - dagger's cache will also be gc-ed at this amount
  • Try and keep 20% of the disk free at any point - but never below the reserved storage of 10%/10GB.

I think this makes sense?

  • It does mean than on a huge disk, like a 1TB one, we won't use more than 200GB of storage - I think that's the right call for a local dev experience?
  • Maybe it would make more sense to avoid the 200GB cap, to get CI to use more of the disk? But this would result in a worse local dev experience - I don't want dagger to consume 100s of GBs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah it's a tough call and there's no way to get a default ideal for everyone; we need to lean on making it easy to configure and doc'd how to do so.

  • Not needed here but the ability to change these values at runtime via dagger core engine ... would help a lot and might not be a monumental effort

The 200GB max is the only part I have some concerns with because

  1. it's a breaking change for users running dagger on infra for their CI that has large disks
  2. It seems kind of arbitrary that we're willing to use 80% of the space for small disks but not large disks. I totally understand the thought process that lead to this, but when I think about it more I can't really articulate why 80% is okay on smaller disks but not larger ones.
    • I.e. you said I don't want dagger to consume 100s of GBs, but to me that would imply you just want a custom configuration with a lower percentage, or a custom configuration with an absolute number set to what you want.

So IMO it would be okay to leave that 200GB out from the defaults and just leave the default as 80%, with the max absolute size being left as configurable still of course. However, I'm not strongly opinionated here, not a blocker for me as long as we try to proactively communicate the possibly breaking change for users that might be impacted.

@jedevc jedevc Oct 28, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, makes sense - I've reverted the default to 75% usage, without the cap - if we do modify that, we can do it separately.

I'm working on a new config file mechanism as well, which should give us more ownership over our config, and will help us more easily configure the defaults (so we don't have to keep pointing to the buildkit docs).

Comment thread go.mod Resolved
@jedevc
jedevc force-pushed the new-cache-policies branch from 3793a02 to 085fdf1 Compare October 18, 2024 13:50
@jedevc jedevc added needs/changelog Pull requests that require a changelog entry needs/docs Pull requests that require a docs change labels Oct 18, 2024
@jedevc
jedevc force-pushed the new-cache-policies branch 8 times, most recently from f97b972 to 5094676 Compare October 25, 2024 13:26
@jedevc
jedevc force-pushed the new-cache-policies branch from d46bc29 to 3e77b63 Compare October 25, 2024 14:46
@jedevc
jedevc marked this pull request as ready for review October 25, 2024 14:46
@jedevc
jedevc requested review from a team as code owners October 25, 2024 14:46
@jedevc
jedevc requested a review from sipsma October 25, 2024 14:46
@jedevc jedevc added this to the v0.13.7 milestone Oct 25, 2024

@sipsma sipsma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, no blockers but left one comment with thoughts about the defaults

Comment thread engine/server/gc.go
Comment on lines +198 to +199
const (
diskSpaceReservePercentage int64 = 10
diskSpaceReserveBytes int64 = 10 * 1e9 // 10GB
diskSpaceFreePercentage int64 = 20
diskSpaceMaxPercentage int64 = 80
diskSpaceMaxBytes int64 = 200 * 1e9 // 200GB
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah it's a tough call and there's no way to get a default ideal for everyone; we need to lean on making it easy to configure and doc'd how to do so.

  • Not needed here but the ability to change these values at runtime via dagger core engine ... would help a lot and might not be a monumental effort

The 200GB max is the only part I have some concerns with because

  1. it's a breaking change for users running dagger on infra for their CI that has large disks
  2. It seems kind of arbitrary that we're willing to use 80% of the space for small disks but not large disks. I totally understand the thought process that lead to this, but when I think about it more I can't really articulate why 80% is okay on smaller disks but not larger ones.
    • I.e. you said I don't want dagger to consume 100s of GBs, but to me that would imply you just want a custom configuration with a lower percentage, or a custom configuration with an absolute number set to what you want.

So IMO it would be okay to leave that 200GB out from the defaults and just leave the default as 80%, with the max absolute size being left as configurable still of course. However, I'm not strongly opinionated here, not a blocker for me as long as we try to proactively communicate the possibly breaking change for users that might be impacted.

Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
@jedevc
jedevc force-pushed the new-cache-policies branch from 3e77b63 to c064b73 Compare October 28, 2024 11:20
@jedevc
jedevc merged commit 9c27cdb into dagger:main Oct 28, 2024
@jedevc
jedevc deleted the new-cache-policies branch October 28, 2024 11:49
@jedevc jedevc mentioned this pull request Oct 28, 2024
10 tasks done
@jedevc jedevc mentioned this pull request Jul 29, 2025
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs/changelog Pull requests that require a changelog entry needs/docs Pull requests that require a docs change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dagger cache can fill the disk in some situations

2 participants