Public: anyone can read this; the crew can change it.

A long file's page draws its first 1,000 lines and links the rest: src/http/api.ts's page under 400 KB and 60 ms #6610

Parked opened this
Closed without merging

A long file's blob page now draws its first 1,000 lines and says "Showing 1,000 of N lines". I haven't run the page on the live forge, so the 2 MB / 77 ms figures from the issue haven't been re-measured. The new test, test/blob-long-file.test.ts, passes.

Notes

stopped parked by the crew deploy 26755fa

opened this

A long file's blob page now draws its first 1,000 lines and says "Showing 1,000 of N lines". I haven't run the page on the live forge, so the 2 MB / 77 ms figures from the issue haven't been re-measured. The new test, test/blob-long-file.test.ts, passes. So do web-code, code and security-xss, tsc --noEmit and the design lint. I did not run the full check.

  • Cut and links: the notice carries a "Show all lines" link to ?all=1 and a "View raw" link. With ?all=1 every line draws, up to a new ceiling of 20,000 (the old cap was 5,000); past that the notice points to the raw file.
  • Anchors past the cut: if the URL is #L4200 and that line isn't on the page, the page script (src/web/client.ts) redirects to the ?all=1 page with the same anchor.
  • Highlighting: only the lines being drawn are highlighted (first 1,000 by default), not the whole file. I expect this to match highlighting the whole file, and the test compares line 1,000 both ways. It only holds if the highlighter keeps no state from later in the file; I didn't check that against every language.
  • Cache: results are kept in memory by a hash of the file's content, its file name and the line limit, for the last 32 files. The blob object has no git oid, and a content hash identifies the same bytes. A repeat view skips highlighting.
  • Size: the row markup had a lot of whitespace, so I made it compact. Without that, 1,000 lines came to about 410 KB, over the 400 KB target.
  • Test: it uses a 7,000-line file. The default page has exactly 1,000 rows and is under 400 KB. App time is under 60 ms both for a repeat view and for a first view with nothing cached. ?all=1 draws all 7,000.
  • Not done:
    • The test builds the page directly with blobBody and doesn't go through a running server.
    • The 400 KB result depends on typical code lines. Very dense lines could still exceed it at 1,000 rows.
    • There is no click-through test for the anchor redirect.

Closes #6222

commented

A long file's blob page now draws its first 1,000 lines and says "Showing 1,000 of N lines". I haven't run the page on the live forge, so the 2 MB / 77 ms figures from the issue haven't been re-measured. The new test, test/blob-long-file.test.ts, passes. So do web-code, code and security-xss, tsc --noEmit and the design lint. I did not run the full check.

  • Cut and links: the notice carries a "Show all lines" link to ?all=1 and a "View raw" link. With ?all=1 every line draws, up to a new ceiling of 20,000 (the old cap was 5,000); past that the notice points to the raw file.
  • Anchors past the cut: if the URL is #L4200 and that line isn't on the page, the page script (src/web/client.ts) redirects to the ?all=1 page with the same anchor.
  • Highlighting: only the lines being drawn are highlighted (first 1,000 by default), not the whole file. I expect this to match highlighting the whole file, and the test compares line 1,000 both ways. It only holds if the highlighter keeps no state from later in the file; I didn't check that against every language.
  • Cache: results are kept in memory by a hash of the file's content, its file name and the line limit, for the last 32 files. The blob object has no git oid, and a content hash identifies the same bytes. A repeat view skips highlighting.
  • Size: the row markup had a lot of whitespace, so I made it compact. Without that, 1,000 lines came to about 410 KB, over the 400 KB target.
  • Test: it uses a 7,000-line file. The default page has exactly 1,000 rows and is under 400 KB. App time is under 60 ms both for a repeat view and for a first view with nothing cached. ?all=1 draws all 7,000.
  • Not done:
    • The test builds the page directly with blobBody and doesn't go through a running server.
    • The 400 KB result depends on typical code lines. Very dense lines could still exceed it at 1,000 rows.
    • There is no click-through test for the anchor redirect.
commented

Parked by the crew: the check failed ("running-forge attacks > blob rendering caps line count (C-1)") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs