Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Jan 27, 2025

Optimize DiffViewProvider Performance for Large Files

This PR optimizes the DiffViewProvider to handle large files much more efficiently by batching operations and removing unnecessary visual updates.

Description

The DiffViewProvider has been optimized for maximum speed when handling large files:

  1. All content changes are batched into a single workspace edit at the end
  2. Visual updates (scrolling, decorations) only happen once at the final step
  3. Smooth scrolling is disabled in favor of instant jumps
  4. Initial setup skips unnecessary visual operations
  5. Intermediate updates are completely skipped

This approach sacrifices the animated streaming effect in favor of near-instant updates, making the diff view feel much more responsive, especially with large files.

Type of change

  • Performance improvement (non-breaking change which enhances performance)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Tested with large files (5000+ lines)
  • Verified instant updates work correctly
  • Confirmed final state matches original implementation
  • Tested both new files and modifications
  • Verified decorations and scroll position are correct at completion

Checklist:

  • [] My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Performance improvements have been verified with large files

Additional context

This change significantly improves the user experience when editing large files by making the diff view feel instant rather than slowly scrolling through changes.

Related Issues

Fixes slow scrolling in diff view with large files

Reviewers

@project-maintainers


Important

Optimize DiffViewProvider for large files by batching operations and minimizing visual updates for improved performance.

  • Performance Optimization:
    • Batch all content changes into a single workspace edit at the end in DiffViewProvider.ts.
    • Skip intermediate updates and apply visual updates (scrolling, decorations) only once at the final step.
    • Disable smooth scrolling in favor of instant jumps using vscode.TextEditorRevealType.Default.
  • Behavior Changes:
    • Initial setup skips unnecessary visual operations.
    • Final state matches original implementation, ensuring consistency.
  • Testing:
    • Verified with large files (5000+ lines) for instant updates and correct final state.

This description was created by Ellipsis for 4d26b24. It will automatically update as commits are pushed.

This DiffViewProvider has been optimized for maximum speed when handling large files:
1. All content changes are batched into a single workspace edit at the end
2. Visual updates (scrolling, decorations) only happen once at the final step
3. Smooth scrolling is disabled in favor of instant jumps
4. Initial setup skips unnecessary visual operations
5. Intermediate updates are completely skipped

This approach sacrifices the animated streaming effect in favor of near-instant updates,
making the diff view feel much more responsive, especially with large files.
@mrubens
Copy link
Collaborator

mrubens commented Jan 28, 2025

Going to close this in favor of #595

@mrubens mrubens closed this Jan 28, 2025
@hannesrudolph hannesrudolph deleted the improve-diff-edit-2 branch January 30, 2025 02:50
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