Skip to content

feat: add CDC lazy chunking and delete delay to Helm chart - #1083

Merged
kalbasit merged 5 commits into
mainfrom
feat-add-cdc-lazy-chunking-and
Mar 13, 2026
Merged

kalbasit merged 5 commits into
mainfrom
feat-add-cdc-lazy-chunking-and

Conversation

@kalbasit

Copy link
Copy Markdown
Owner

Add support for the new CDC lazy chunking configuration options in the
Helm chart and documentation:

  • Add lazyChunkingEnabled, backgroundWorkers, and deleteDelay to
    values.yaml
  • Update configmap template to render the new CDC flags
  • Add tests for the new CDC configuration options
  • Update CDC documentation with lazy chunking section and new parameters

This enables users to configure lazy chunking behavior directly from
their Helm values, including the delay before deleting compressed NAR
files after chunking completes.

@kalbasit

kalbasit commented Mar 13, 2026 •

Copy link
Copy Markdown
Owner Author

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 13, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 Helm chart by integrating support for new CDC lazy chunking configuration options. This allows users to fine-tune the behavior of lazy chunking, including the number of background workers and the delay before deleting compressed NAR files, directly through their Helm values, ultimately improving Time To First Byte (TTFB) by enabling asynchronous chunking.

Highlights

  • Helm Chart Configuration: Added lazyChunkingEnabled, backgroundWorkers, and deleteDelay parameters to values.yaml for CDC lazy chunking.
  • ConfigMap Template Update: Modified the configmap.yaml template to render the newly introduced CDC lazy chunking flags.
  • Testing: Included new tests for the CDC lazy chunking configuration options to ensure correct functionality.
  • Documentation: Updated the CDC documentation with a dedicated section on lazy chunking and details on the new parameters.
Changelog
  • charts/ncps/templates/configmap.yaml
    • Added conditional rendering for lazy-chunking-enabled, background-workers, and delete-delay within the CDC configuration.
  • charts/ncps/tests/configmap_test.yaml
    • Introduced new test cases to verify the correct configuration of CDC lazy chunking when enabled, disabled, nil, and for background workers and delete delay.
  • charts/ncps/values.yaml
    • Added lazyChunkingEnabled, backgroundWorkers, and deleteDelay parameters with descriptions and default values under the config.cdc section.
  • docs/docs/User Guide/Features/CDC.md
    • Expanded the CDC documentation to include a new 'Lazy Chunking' section, detailing its behavior, configuration options, and providing a configuration example.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@dosubot dosubot Bot added documentation Improvements or additions to documentation helm labels Mar 13, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds support for CDC lazy chunking to the Helm chart. The changes to values.yaml and the chart tests are well-implemented. I've provided two suggestions for improvement: one to simplify the Helm template logic in configmap.yaml for better maintainability and adherence to concise boolean expressions, and another to correct the feature description in CDC.md to more accurately reflect its behavior and comply with documentation formatting rules.

Comment thread charts/ncps/templates/configmap.yaml Resolved
Comment thread docs/docs/User Guide/Features/CDC.md Resolved
@kalbasit
kalbasit force-pushed the feat-implement-lazy-cdc-chunking-2 branch from 8cefa7f to 28d9595 Compare March 13, 2026 00:37
@kalbasit
kalbasit force-pushed the feat-add-cdc-lazy-chunking-and branch from 8e48cfb to 3dc4fe3 Compare March 13, 2026 00:38
@kalbasit
kalbasit force-pushed the feat-implement-lazy-cdc-chunking-2 branch from 28d9595 to 91037f0 Compare March 13, 2026 01:00
@kalbasit
kalbasit force-pushed the feat-add-cdc-lazy-chunking-and branch from f6c88ed to e6201e2 Compare March 13, 2026 01:00
Base automatically changed from feat-implement-lazy-cdc-chunking-2 to main March 13, 2026 01:14
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Mar 13, 2026
kalbasit and others added 5 commits March 12, 2026 18:41
Add support for the new CDC lazy chunking configuration options in the
Helm chart and documentation:

- Add lazyChunkingEnabled, backgroundWorkers, and deleteDelay to
  values.yaml
- Update configmap template to render the new CDC flags
- Add tests for the new CDC configuration options
- Update CDC documentation with lazy chunking section and new parameters

This enables users to configure lazy chunking behavior directly from
their Helm values, including the delay before deleting compressed NAR
files after chunking completes.
- Simplify lazy-chunking-enabled rendering in Helm configmap template
- Fix lazy chunking behavior description in CDC documentation

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@kalbasit
kalbasit force-pushed the feat-add-cdc-lazy-chunking-and branch from e6201e2 to b6b4dc8 Compare March 13, 2026 01:42
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Mar 13, 2026
@kalbasit
kalbasit enabled auto-merge (squash) March 13, 2026 01:42
@github-actions

Copy link
Copy Markdown
Contributor

@kalbasit
kalbasit merged commit b304f54 into main Mar 13, 2026
15 checks passed
@kalbasit
kalbasit deleted the feat-add-cdc-lazy-chunking-and branch March 13, 2026 01:55
@codecov

codecov Bot commented Mar 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 5.04%. Comparing base (22e60a8) to head (b6b4dc8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1083   +/-   ##
=====================================
  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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dosubot

dosubot Bot commented Mar 13, 2026

Copy link
Copy Markdown

Documentation Updates

2 document(s) were updated by changes in this PR:

Cache and Storage Configuration Flags
View Changes
@@ -209,10 +209,16 @@
 
 **Behavior:**
 
-When lazy chunking is enabled (the default), NAR files are:
-1. Stored compressed without chunking (with `total_chunks=0` in the database)
-2. Served immediately from storage when requested
-3. Chunked asynchronously in the background by worker processes
+When lazy chunking is enabled (the default), NAR files are stored in their original compressed format first, then chunked in the background. When a new NAR is added to the cache:
+
+1. The NAR is downloaded from upstream and stored in its original compressed form (e.g., xz, zstd) in a temporary location
+2. The associated narinfo is immediately normalized to `compression: none` and stored in the database, signaling that the NAR will eventually be served from chunks
+3. The first client request for the NAR is served by decompressing the temporary file on the fly, ensuring fast Time To First Byte (TTFB)
+4. In the background, the NAR is asynchronously chunked from the temporary file
+5. Once chunking is complete, subsequent requests are served from the newly created chunks
+6. The temporary compressed file is deleted
+
+The `deleteDelay` parameter applies when migrating an existing whole-file NAR to chunks, not to new NARs. It ensures the original whole file remains available for a configured period after migration to allow clients to update their caches.
 
 When lazy chunking is disabled (`--cache-cdc-lazy-chunking-enabled=false`), the original immediate chunking behavior is restored, where NAR files are chunked during the download/storage process.
 
NAR File Download and Streaming
View Changes
@@ -127,7 +127,7 @@
 
 If CDC is not enabled in the database, the command will return an error: "migrate-nar-to-chunks command requires CDC to be enabled in the database; please run 'ncps serve' with CDC enabled first". This ensures that the migration infrastructure is properly configured before attempting to migrate existing NAR files to the chunked storage format.
 
-When lazy chunking is enabled (the default via `--cache-cdc-lazy-chunking-enabled=true`), compressed NAR files are stored without immediate chunking, and background workers automatically perform migration using the same infrastructure as the `migrate-nar-to-chunks` command. The background workers can be configured via `--cache-cdc-background-workers` (defaults to CPU count).
+When lazy chunking is enabled (the default via `--cache-cdc-lazy-chunking-enabled=true`), compressed NAR files are stored without immediate chunking, and background workers automatically perform migration using the same infrastructure as the `migrate-nar-to-chunks` command. The background workers can be configured via `--cache-cdc-background-workers` (default: number of CPUs).
 
 > **⚠️ CDC Configuration Enforcement**
 >
@@ -251,8 +251,10 @@
 
 **Configuration:**
 - `--cache-cdc-lazy-chunking-enabled` (default: `true`): Enable lazy chunking for optimal TTFB
-- `--cache-cdc-background-workers` (default: CPU count): Number of background workers for asynchronous chunking
+- `--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`).
 
 **Serving Logic:**
 
@@ -266,7 +268,7 @@
 
 **Delayed Deletion:**
 
-When lazy chunking is enabled, the system implements delayed deletion of compressed NAR files after chunking completes. Rather than immediately deleting the original compressed NAR when the chunked version becomes available, the system preserves it for a configurable grace period (controlled by `--cache-cdc-delete-delay`, default: 24 hours). This provides:
+When lazy chunking is enabled, the system implements delayed deletion of compressed NAR files after chunking completes. Rather than immediately deleting the original compressed NAR when the chunked version becomes available, the system preserves it for a configurable grace period (controlled by `--cache-cdc-delete-delay`, default: 24 hours). This parameter applies when migrating existing whole-file NARs to chunks, not to new NARs downloaded with lazy chunking enabled. It ensures the original whole file remains available during the migration period to allow clients to update their cached narinfo records. This provides:
 
 - A grace period for clients to update their cached narinfo records
 - Graceful degradation if the chunked version encounters issues

How did I do? Any feedback?  Join Discord

kalbasit added a commit that referenced this pull request Jun 8, 2026
## 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation helm size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant