mirror of
https://github.com/microsoft/WSL.git
synced 2026-05-05 05:19:18 -05:00
Fix excessive screen updates in progress indicators (#14206)
* Initial plan * Fix excessive screen updates during wsl --export Only update progress display when file size actually changes, preventing unnecessary screen redraws and reducing CPU/GPU overhead. Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com> * Address code review: initialize previousSize to 0 instead of -1 Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com> * Complete fix for excessive screen updates during wsl --export Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com> * Clean up: remove codeql symlink and add to gitignore Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com> * Revert .gitignore to original state Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com> * Compare MB values instead of raw bytes to prevent unnecessary redraws When file size grows in sub-MB increments, comparing raw bytes causes redraws even though the displayed MB value hasn't changed. Now we calculate and compare the MB value directly, ensuring the progress indicator only updates when the displayed value actually changes. Also initialize previousSizeMB to -1 to ensure initial progress is always shown (even when starting at 0 MB). Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com> * Cache string in UpdateProgress instead of caching values in caller Move the duplicate string check into ConsoleProgressIndicator::UpdateProgress() itself. This provides a more general solution that prevents printing the same string twice for any caller, not just the file size case. The comparison now happens at the string level, which handles all formatting variations and makes the fix more maintainable. Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
This commit is contained in:
@@ -49,6 +49,12 @@ void wsl::windows::common::ConsoleProgressIndicator::UpdateProgress(std::wstring
|
||||
return;
|
||||
}
|
||||
|
||||
// Only update if the new progress message differs from the previous one
|
||||
if (Progress == m_progressMessage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto i = 0; i < m_progressMessage.size(); i++)
|
||||
{
|
||||
fwprintf(stderr, L"\b \b");
|
||||
|
||||
Reference in New Issue
Block a user