Skip to content

Add streaming to Blame page full view

Stanislav Lashmanov requested to merge slashmanov/blame-page-streaming into master

What does this MR do and why?

Implements Blame page streaming (#385686 - closed).

Please refer to HTML Streaming (gitlab-org/frontend/rfcs#101) in order to get familiar with the concept of HTML Streaming.

This MR adds streaming support to the Blame page full file view. The feature is enabled via a :blame_page_streaming feature flag.

This MR also changes the styling and layout of the blame file in order to:

  1. Send less bytes (this is really important for huge blame files)
  2. Render faster with less selector overhead

New full blame page rendering algorithm

  1. Render 200 lines initially on the server
  2. When the page starts loading immediately start a request for the next 2000 lines (startup_js block, lines are server rendered by Rails as well)
  3. When the bundle starts fetch the rest of the lines with 2000 lines per page with a maximum of 5 requests at the time
  4. Start rendering the streams (response.body provides ReadableStream of the request)

Screenshots or screen recordings

General preview

Screen_Recording_2023-02-02_at_20.40.49

Slow-motion streaming recording

Screen_Recording_2023-01-26_at_16.37.41

How to set up and validate locally

  1. Run Feature.enable(:blame_page_streaming) in Rails console (gdk rails c)
  2. Open any blame file with more than 2000 lines. (GDK example link, 30KLOC+)
  3. Click 'View entire blame' button at the bottom of the page.

Performance measurements

image

(left is streaming with ?streaming=true, right is full page SSR with ?no_pagination=true)

blame-no-pagination.zip

blame-streaming.zip

Pagination results

image

pagination.zip

Bugs that would be addressed in subsequent MRs

  1. Handle dates with relative time when streaming ... (#391745 - closed)
  2. Use a separate controller action for full blame... (#391841 - closed)
  3. Improve Blame page API response times (#391842 - closed)
Edited by Stanislav Lashmanov

Merge request reports