Skip to content

Fix the file view asking git again for a file it already shows - #601

Merged
hannesa2 merged 1 commit into
gitx:masterfrom
goneng:fix-repeated-file-view-reads
Sep 13, 2026
Merged

hannesa2 merged 1 commit into
gitx:masterfrom
goneng:fix-repeated-file-view-reads

Conversation

@goneng

@goneng goneng commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

Selecting a commit hands the file browser a freshly built tree every time, so
any index refresh, and every switch between the history and the commit view,
re-ran check-attr, cat-file -s and show/blame/log
for a blob that cannot have changed.
The view now remembers which file, in which tab, and against which HEAD it last rendered, and
skips a render that would repeat all three.

Impact of the change

External git commands the tree view runs:

action before after
4 switches between the history and the commit view 12 0
4 clicks between the Source, Blame and History tabs 8 8
external commit while the History tab is open 3 3

(traced from a running GitX with one file selected)

Only repeated renders of the same file go away.
A tab click loads that tab's page, which arrives empty and has to be filled in, and
an external commit still refreshes the file's history, the one tab read from HEAD
rather than from the selected commit.

Test plan

  • New GLFileViewContentCacheTests: 5 tests, of which
    testTheSameFileIsReadOnlyOnce fails on master and passes here, while
    the other four guard against over-caching (another file, another tab, a
    reloaded page, a moved HEAD)
  • make unit-test: 60 tests, 0 failures
  • Traced every external git command of a running GitX to produce the
    table above

@goneng goneng changed the title Fix the file view asking git again for a file it already shows Fix the file view asking git again for a file it already shows (performance improvement) Sep 11, 2026
@goneng
goneng marked this pull request as ready for review September 11, 2026 22:06
@goneng
goneng marked this pull request as draft September 11, 2026 22:07
@goneng
goneng force-pushed the fix-repeated-file-view-reads branch 3 times, most recently from abf751c to b124140 Compare September 12, 2026 15:29
@goneng
goneng marked this pull request as ready for review September 12, 2026 15:32
@goneng
goneng requested a review from hannesa2 September 12, 2026 18:34
@hannesa2

Copy link
Copy Markdown
Contributor

unfortunately, there is a conflict

The tree the file browser reads from is rebuilt on every repository
update, so rendering it again asked git for a blob that cannot have
changed.

* Remember which file, in which tab, and against which HEAD the view
  last rendered, and skip a render that would repeat all three
* Clear that memory when a tab's page reloads, since the new page
  arrives empty and has to be filled in again
* Keep HEAD in the comparison so a new commit still refreshes the
  file's history, the one tab that is read from HEAD rather than from
  the selected commit

Measured with one file selected: four switches between the history and
the commit view ran twelve external git commands before and none after.
@goneng
goneng force-pushed the fix-repeated-file-view-reads branch from b124140 to 8509903 Compare September 13, 2026 04:25
@hannesa2 hannesa2 added the performance performance improvement label Sep 13, 2026
@hannesa2 hannesa2 changed the title Fix the file view asking git again for a file it already shows (performance improvement) Fix the file view asking git again for a file it already shows Sep 13, 2026
@hannesa2

Copy link
Copy Markdown
Contributor

I changed the titel and added an own label and section in changelog
#617

@hannesa2
hannesa2 merged commit a1fbed3 into gitx:master Sep 13, 2026
4 of 6 checks passed
@hannesa2

Copy link
Copy Markdown
Contributor

@hannesa2

Copy link
Copy Markdown
Contributor

Here I've to restart the unit tests again https://github.com/gitx/gitx/actions/runs/34739834791?pr=617 , then it was working. Looks like being a flaky test

@goneng
goneng deleted the fix-repeated-file-view-reads branch September 13, 2026 05:44
@goneng

goneng commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

Hmm, the merge to master fails here https://github.com/gitx/gitx/actions/runs/34739962102/job/103677888388 with the unit tests

This looks like a real bug in the tests - preparing a fix via PR #620

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants