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_diff reads and writes Gitlab::Diff::Rendered::Notebook::DiffCache when 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.prefetch reads the entries of a file collection in one read_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_diff passes interruptible: true to IpynbDiff.diff and computes the lazy text diff inside Gitlab::RenderTimeout, so IpynbDiff::InterruptibleTextDiff kills the diff process at the limit. The disabled branch used Diffy::Diff outside the timeout. The interruptible: option of the ipynbdiff gem stays; this MR does not change the gem.
  • cap_rendered_notebook_size lives 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) and renders the same files as without the cache when every entry misses (spec/lib/gitlab/diff/file_collection/base_spec.rb). They now stub DiffCache#fetch to yield, which renders without the cache, so they still test the same thing.
  • spec/requests/projects/merge_requests/notebook_diff_rendering_spec.rb counts renders and turned the flag off for the whole file. It now uses the same DiffCache#fetch stub, and its with the render cache context (before: when cache_notebook_diffs is enabled) restores the real DiffCache.new.
  • The when the diff file has no repository example under #diff checked that a nil actor still enabled stop_notebook_text_diff_at_timeout. It is removed; the same context in the cache examples still covers rendering without a repository.

References

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

  1. Use a GDK project with the gitlab-test repository. Commit 5d6ed1503801ca9dc28e95eeb85a7cf863527aee changes, adds and deletes a notebook.

  2. In Code > Branches, create nb-base from 9fd7ad70baf0ae69fb1b9ab7b336a1dccb77d23b and nb-change from 5d6ed1503801ca9dc28e95eeb85a7cf863527aee.

  3. Create a merge request from nb-change into nb-base and open its Changes tab. Expect: the notebooks show as rendered diffs, with no feature flag set.

  4. 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 }
  5. In the GDK gitlab directory, run grep 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.

Edited by Eduardo Bonet

Merge request reports

Loading
Loading