Remove the notebook diff cache and timeout feature flags
What does this MR do and why?
Removes two gitlab_com_derisk feature flags and keeps their enabled code: cache_notebook_diffs caches the rendered diff of a Jupyter notebook for each pair of blobs, and stop_notebook_text_diff_at_timeout kills the notebook text diff process at the render timeout. Both are at 100% on GitLab.com (stop_notebook_text_diff_at_timeout since 2026-10-28, cache_notebook_diffs since 2026-11-04), so self-managed instances get both behaviors with this MR. Rollback is a revert of this MR.
Self-managed users see one new behavior: when a notebook takes more than 1.5 seconds to render, every viewer of that diff sees the raw diff for 10 minutes, and when a render is too large, every viewer sees the raw diff for 1 hour.
With this MR, self-managed instances use their Redis cache for rendered notebook diffs. The #g_durability consult about the Redis cache load, listed in the rollout issue, found no concerns.
Merge this MR with or after !269563 (merged), the reduce_notebook_diff_rendering removal. The rollout issue made that flag a precondition for the cache, because without it the metadata and stats endpoints read every notebook from the cache.
What each flag controlled and what the specs now test
cache_notebook_diffs(introduced in !263925 (merged)):Gitlab::Diff::Rendered::Notebook::DiffFile#notebook_diffreads and writesGitlab::Diff::Rendered::Notebook::DiffCachewhen the repository has a project. A render that is too large or times out caches a marker, and the diff shows the raw file until the marker expires.DiffCache.prefetchreads the entries of a file collection in oneread_multi. The cache was off in the disabled branch; the no-project path still renders without the cache.stop_notebook_text_diff_at_timeout(introduced in !263933 (merged)):DiffFile#render_notebook_diffpassesinterruptible: truetoIpynbDiff.diffand computes the lazy text diff insideGitlab::RenderTimeout, soIpynbDiff::InterruptibleTextDiffkills thediffprocess at the limit. The disabled branch usedDiffy::Diffoutside the timeout. Theinterruptible:option of theipynbdiffgem stays; this MR does not change the gem.cap_rendered_notebook_sizelives in the same method and stays.
Spec changes:
- The
stub_feature_flags(...: false)contexts are gone. The enabled-path examples stay. - Two examples compared cached output with output rendered with the flag off:
returns the same output as without the cache(spec/lib/gitlab/diff/rendered/notebook/diff_file_spec.rb) andrenders the same files as without the cache when every entry misses(spec/lib/gitlab/diff/file_collection/base_spec.rb). They now stubDiffCache#fetchto yield, which renders without the cache, so they still test the same thing. spec/requests/projects/merge_requests/notebook_diff_rendering_spec.rbcounts renders and turned the flag off for the whole file. It now uses the sameDiffCache#fetchstub, and itswith the render cachecontext (before:when cache_notebook_diffs is enabled) restores the realDiffCache.new.- The
when the diff file has no repositoryexample under#diffchecked that anilactor still enabledstop_notebook_text_diff_at_timeout. It is removed; the same context in the cache examples still covers rendering without a repository.
References
- Rollout issue: Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/635151
- Original MRs: !263925 (merged), !263933 (merged)
- Sibling MR: !269563 (merged), the
reduce_notebook_diff_renderingflag removal. It also editsspec/lib/gitlab/diff/file_collection/base_spec.rbandspec/requests/projects/merge_requests/notebook_diff_rendering_spec.rb, so the MR that merges second needs a rebase.
Commits and changelog
One commit per flag. The first commit carries one Changelog: performance entry for both behaviors, because the squash keeps only the first commit message.
Screenshots or screen recordings
No UI change.
How to set up and validate locally
-
Use a GDK project with the
gitlab-testrepository. Commit5d6ed1503801ca9dc28e95eeb85a7cf863527aeechanges, adds and deletes a notebook. -
In Code > Branches, create
nb-basefrom9fd7ad70baf0ae69fb1b9ab7b336a1dccb77d23bandnb-changefrom5d6ed1503801ca9dc28e95eeb85a7cf863527aee. -
Create a merge request from
nb-changeintonb-baseand open its Changes tab. Expect: the notebooks show as rendered diffs, with no feature flag set. -
In
gdk rails console, render the changed notebook twice:project = Project.find_by_full_path('<group>/<project>') commit = project.commit('5d6ed1503801ca9dc28e95eeb85a7cf863527aee') render = -> { Gitlab::Diff::Rendered::Notebook::DiffFile.new(Gitlab::Diff::File.new(commit.raw_diffs.first, diff_refs: commit.diff_refs, repository: project.repository)).diff.present? } 2.times { render.call } -
In the GDK
gitlabdirectory, rungrep IPYNB_DIFF_CACHE_HIT log/application_json.log | tail -1. Expect: an entry from the second render.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.