Skip to content

Conversation

@MaxFangX
Copy link
Contributor

@MaxFangX MaxFangX commented Dec 3, 2025

Builds on top of #425; if you rebase merge #425 there will be no conflicts for rebase merging this one.

Description

After staging/unstaging a hunk, DiffScreen calls Model:fetch() to refresh the view. This runs several git commands that are unnecessary when we know the file state hasn't fundamentally changed:

  • git rev-parse --show-toplevel (GitFile creation)
  • git status (conflict check)
  • git status (file status)

Add Model:refresh_hunks() which skips these redundant checks and only fetches what's needed: current lines and updated hunks. This reduces git commands from ~4-6 to ~1-2 per staging operation (60-75% or roughly 3-4x improvement)

@MaxFangX MaxFangX changed the title perf(DiffScreen): Reduce git commands during hunk staging perf(DiffScreen): Reduce git commands during hunk staging, 60-75% performance improvement Dec 3, 2025
@MaxFangX MaxFangX force-pushed the 2025-12-03-better-hunk-stage-latency branch from 41e404f to 5c3ba16 Compare December 3, 2025 21:08
After staging/unstaging a hunk, DiffScreen calls Model:fetch() to refresh the
view. This runs several git commands that are unnecessary when we know the file
state hasn't fundamentally changed:

- git rev-parse --show-toplevel (GitFile creation)
- git status (conflict check)
- git status (file status)

Add Model:refresh_hunks() which skips these redundant checks and only fetches
what's needed: current lines and updated hunks. This reduces git commands from
~4-6 to ~1-2 per staging operation.
@MaxFangX MaxFangX force-pushed the 2025-12-03-better-hunk-stage-latency branch from 5c3ba16 to 62d8c83 Compare December 5, 2025 01:08
@MaxFangX
Copy link
Contributor Author

MaxFangX commented Dec 5, 2025

Rebased.

@tanvirtin tanvirtin merged commit 4168602 into tanvirtin:main Dec 5, 2025
1 of 2 checks passed
@MaxFangX MaxFangX deleted the 2025-12-03-better-hunk-stage-latency branch December 5, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants