Repository navigation
feat: add --cache-cdc-lazy-cleanup-schedule flag - #1096
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Content-Defined Chunking (CDC) feature by externalizing the previously hardcoded cleanup cron schedule into a configurable option. This provides operators with the flexibility to fine-tune the frequency of NAR file cleanup based on their specific workload requirements, thereby improving operational control and adaptability without requiring application recompilation. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Documentation Updates 2 document(s) were updated by changes in this PR: Cache and Storage Configuration FlagsView Changes@@ -207,7 +207,7 @@
- `--cache-cdc-delete-delay` (duration): Delay before deleting compressed NAR files after chunking completes. Default: `24h`
- Environment variable: `CACHE_CDC_DELETE_DELAY`
- YAML key: `cache.cdc.delete-delay`
- - Purpose: Controls how long to wait before deleting original compressed NAR files after CDC chunking completes. When lazy chunking is enabled, this delay ensures that compressed NAR files remain available during the transition period, allowing graceful fallback while chunks are being generated in the background. A background cleanup job runs hourly to delete compressed files that have been replaced by chunks and exceed this delay.
+ - Purpose: Controls how long to wait before deleting original compressed NAR files after CDC chunking completes. When lazy chunking is enabled, this delay ensures that compressed NAR files remain available during the transition period, allowing graceful fallback while chunks are being generated in the background. A background cleanup job (scheduled via `--cache-cdc-lazy-cleanup-schedule`) deletes compressed files that have been replaced by chunks and exceed this delay.
- `--cache-cdc-lazy-recovery-schedule` (string): Cron schedule for recovering stuck NARs in lazy chunking mode. Default: `@every 5m`
- Environment variable: `CACHE_CDC_LAZY_RECOVERY_SCHEDULE`
@@ -220,6 +220,12 @@
- YAML key: `cache.cdc.lazy-recovery-batch-size`
- Helm value: `config.cdc.lazyRecoveryBatchSize`
- Purpose: Limits the number of stuck NARs that will be recovered in each run to avoid overloading the system. NARs are identified as stuck if they have `total_chunks = 0`, `chunking_started_at = NULL`, and are older than the recovery interval.
+
+- `--cache-cdc-lazy-cleanup-schedule` (string): Cron schedule for the background CDC cleanup job that removes deleted NAR chunks after the `--cache-cdc-delete-delay` period. Default: `@every 1h`
+ - Environment variable: `CACHE_CDC_LAZY_CLEANUP_SCHEDULE`
+ - YAML key: `cache.cdc.lazy-cleanup-schedule`
+ - Helm value: `config.cdc.lazyCleanupSchedule`
+ - Purpose: Controls the schedule for a background cleanup job that deletes compressed NAR files after they have been successfully chunked and the delete delay has expired. Accepts standard cron syntax or special descriptors like `@every 1h`, `@daily`, etc. Allows operators to tune cleanup frequency based on workload.
**Behavior:**
@@ -261,6 +267,13 @@
ncps serve \
--cache-cdc-enabled \
--cache-cdc-delete-delay 48h
+```
+
+**CLI Example (custom cleanup schedule):**
+```bash
+ncps serve \
+ --cache-cdc-enabled \
+ --cache-cdc-lazy-cleanup-schedule "@every 30m"
```
**YAML Example (using defaults):**
@@ -291,6 +304,7 @@
delete-delay: 48h
lazy-recovery-schedule: "@every 10m"
lazy-recovery-batch-size: 50
+ lazy-cleanup-schedule: "@every 30m"
```
**Note:** The existing `migrate-nar-to-chunks` CLI command can still be used for manual chunking of stored NAR files.
@@ -454,6 +468,7 @@
| LRU schedule timezone | `--cache-lru-schedule-timezone` | `cache.lru.schedule.timezone` | N/A | No |
| CDC lazy recovery schedule | `--cache-cdc-lazy-recovery-schedule` | `cache.cdc.lazy-recovery-schedule` | `config.cdc.lazyRecoverySchedule` | No (default: `@every 5m`) |
| CDC lazy recovery batch size | `--cache-cdc-lazy-recovery-batch-size` | `cache.cdc.lazy-recovery-batch-size` | `config.cdc.lazyRecoveryBatchSize` | No (default: `100`) |
+| CDC lazy cleanup schedule | `--cache-cdc-lazy-cleanup-schedule` | `cache.cdc.lazy-cleanup-schedule` | `config.cdc.lazyCleanupSchedule` | No (default: `@every 1h`) |
* Either local or S3 storage must be configured, not both.
** Required for S3 storage.NAR File Download and StreamingView Changes@@ -253,8 +253,9 @@
- `--cache-cdc-lazy-chunking-enabled` (default: `true`): Enable lazy chunking for optimal TTFB
- `--cache-cdc-background-workers` (default: number of CPUs): Number of background workers for asynchronous chunking
- `--cache-cdc-delete-delay` (default: `24h`): Delay before deleting compressed NAR files after chunking completes
-
-These parameters are also configurable via the Helm chart under `config.cdc` in values.yaml (`lazyChunkingEnabled`, `backgroundWorkers`, `deleteDelay`).
+- `--cache-cdc-lazy-cleanup-schedule` (default: `@every 1h`): Cron schedule for running the cleanup job that removes old compressed NAR files
+
+These parameters are also configurable via the Helm chart under `config.cdc` in values.yaml (`lazyChunkingEnabled`, `backgroundWorkers`, `deleteDelay`, `lazyCleanupSchedule`).
**Serving Logic:**
@@ -274,7 +275,7 @@
- Graceful degradation if the chunked version encounters issues
- Reduced risk of cache misses during the transition
-A background cleanup job runs hourly (via `AddCDCDeletedCleanupCronJob`) to identify and delete old compressed NAR files that meet all these criteria:
+A background cleanup job runs on a configurable schedule (via `AddCDCDeletedCleanupCronJob`, default: `@every 1h`) to identify and delete old compressed NAR files that meet all these criteria:
- The compressed NAR has been replaced by a chunked version (`compression != 'none'` and matching hash has `compression = 'none'` with `total_chunks > 0`)
- The deletion delay has passed since the compressed NAR was created |
There was a problem hiding this comment.
Code Review
This pull request introduces a configurable 'lazy cleanup schedule' for Content-Defined Chunking (CDC) by adding a new lazyCleanupSchedule option to the Helm chart, application CLI, and documentation. It also updates development scripts to enable lazy chunking and use more aggressive recovery/deletion schedules, and improves observability by adding an informational log for the recovery cron job setup.
1acc555 to
311efcb
Compare
4ad5f51 to
f1d4953
Compare
147a3bf to
425ca74
Compare
The serve command was checking !cmd.IsSet() for CDC lazy chunking flags and manually setting defaults in code. This moves the defaults directly into the CLI flag definitions using the Value field, making the code cleaner and consistent with standard Go CLI patterns. This also updates the Helm chart to default lazyChunkingEnabled to true instead of null, ensuring the default is explicit in the values.yaml.
Extract the hardcoded '@every 1h' CDC cleanup cron schedule into a configurable flag --cache-cdc-lazy-cleanup-schedule. This allows operators to tune the cleanup frequency based on their workload without rebuilding. The flag is wired through the same sources pattern as other CDC flags (CLI flag, config file key cache.cdc.lazy-cleanup-schedule, and env var CACHE_CDC_LAZY_CLEANUP_SCHEDULE), includes cron validation, and defaults to the previous hardcoded value of '@every 1h'. Also adds the flag to the Helm chart (values.yaml + configmap template) and documents it in the CDC Options table in Reference.md.
425ca74 to
f29b07b
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1096 +/- ##
=====================================
Coverage 5.04% 5.04%
=====================================
Files 6 6
Lines 436 436
=====================================
Hits 22 22
Misses 410 410
Partials 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
## Summary The `[Unreleased]` section was populated in #1309 but skewed toward the recent CDC-drain, in-flight-staging, and Ent-migration work, omitting several user-facing features and fixes that also landed since v0.9.4. This backfills the missing notable changes, each cross-referenced by PR. **Added** - `ncps fsck` command + Helm fsck CronJob (#975, #996, #998, #999, #1000, #1004, #1006, #1176) - Closure pinning HTTP endpoints `POST`/`DELETE /pin/{hash}.narinfo`, `GET /pins` (#1108) - pprof server via `--pprof-addr` (#1063) - CDC lazy chunking as a feature + `--cache-cdc-lazy-cleanup-schedule` + recovery cron (#1082, #1083, #1089, #1096) - Helm: auto `GOMEMLIMIT` (#1061), configurable temp volume / `volumeClaimTemplate` (#1074, #1077), SQLite `Recreate` strategy (#1012) - Startup storage reporting + deprecated-narinfo warning (#959, #961) - `docker-dev` image (#1097) **Fixed** - `store/tmp` no longer wiped on startup (#1313) - `nix-hash` NAR verification (#1101) - Prometheus counters primed at startup (#1337, #1343) - 404 on un-reassemblable chunked NARs (#1319), purged narinfo no longer 500 (#1318), fail-fast tmp validation (#1086) - Further CDC/cache reliability fixes (#1317, #1346, #1341, #1342, #1331, #1347) **Changed** - CDC config now persisted in the DB config table (#971) Dependency bumps, CI/test-only changes, and the internal Ent-conversion PRs are intentionally excluded; the existing Ent-migration entry already covers that work. ## Test plan - [x] `nix fmt` reports no changes (docs-only edit) - [x] CHANGELOG section structure intact (Added/Fixed/Changed/Removed/Migration/CI)
Extract the hardcoded
@every 1hCDC cleanup cron schedule into aconfigurable flag --cache-cdc-lazy-cleanup-schedule. This allows
operators to tune the cleanup frequency based on their workload without
rebuilding.
The flag is wired through the same sources pattern as other CDC flags
(CLI flag, config file key cache.cdc.lazy-cleanup-schedule, and env var
CACHE_CDC_LAZY_CLEANUP_SCHEDULE), includes cron validation, and defaults
to the previous hardcoded value of
@every 1h.Also adds the flag to the Helm chart (values.yaml + configmap template)
and documents it in the CDC Options table in Reference.md.