-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Feature: Improved performance when compressing files #17653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… Chunking + async/await is a reliable pattern for large data processing.
Based on
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the performance and responsiveness of file size calculations in the WPF application by replacing a blocking synchronous approach with an asynchronous batch processing system. The changes address UI freezing issues when processing large directories (50,000+ files).
- Replaced Win32 FindFirstFileEx/FindNextFile API calls with managed Directory.Enumerate methods
- Implemented batched processing with Task.Yield() to maintain UI responsiveness
- Introduced a new ComputeFileSizeBatch method for efficient batch file size computation
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Looking forward to implementing CoPilot Ai's suggestions in the PR. Also looking to improve performance as per @Josh65-2201's suggestion. |
Hi @Josh65-2201, Thanks. |
1) Adaptive chunking → starts at 500, doubles gradually to 5000 for speed on large dirs. 2) Parallel batch processing in ProcessBatchAsync using Parallel.ForEach. 3) _computedFiles check before adding to batch → avoids double-counting. 4) CancellationToken support inside parallel loops. 5) UI responsiveness with await Task.Yield() after each batch.
Report: File Size Calculation Freezing Issue
1. Problem Overview
Our WPF application was becoming unresponsive ("Not Responding" state) when performing file size calculations on large directories.
Closes #14306
2. Investigation
We used Visual Studio Performance Profiler (CPU Usage tool) to understand where the app was spending time.
Findings:
3. Root Cause
4. Solution
We redesigned the FileSizeCalculator to:
FileInfo
for each file.Example snippet (batch logic):
FileSizeCalculator Report.docx
5. Results
6. Key Takeaways