-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
perf: Implement streaming XML parsing and improve file upload collision handling #16236
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: master
Are you sure you want to change the base?
Conversation
- Add StreamingReadFolderRemoteOperation for memory-efficient folder reading using SAX parser - Add PropFindSaxHandler for streaming XML parsing of PROPFIND responses - Prevent OutOfMemoryError for folders with thousands of files by avoiding full XML loading - Integrate streaming parser into RefreshFolderOperation with fallback to legacy method - Add batch processing for large folders (500 files per batch) in FileDataStorageManager - Improve logging levels and add thread name tracking for better debugging Signed-off-by: dmiales <[email protected]>
Problem: Users with large photo and video libraries (5000+ files per folder) experience severe performance issues and OutOfMemoryError (OOM) crashes when opening folders. The application receives a massive XML file from the server and attempts to parse it entirely in memory, causing: - Application freezes and lagging (observed on Samsung S23+) - OOM errors during XML parsing - OOM errors in background synchronization processes - Data loss due to crashes during sync operations Solution: Rewrote the parsing block from the old ownCloud approach to a new streaming parser implementation. Additionally implemented batch processing for folders. This eliminates OOM errors and significantly improves performance and stability, even with 20,000+ photos and videos in a single folder. Implementation details: - Add StreamingReadFolderRemoteOperation for memory-efficient folder reading using SAX parser - Add PropFindSaxHandler for streaming XML parsing of PROPFIND responses - Prevent OutOfMemoryError for folders with thousands of files by avoiding full XML loading - Integrate streaming parser into RefreshFolderOperation with fallback to legacy method - Add batch processing for large folders (500 files per batch) in FileDataStorageManager - Improve file upload collision handling in UploadFileOperation - Add content comparison for non-encrypted files when SKIP policy is used - Report SYNC_CONFLICT when file with same name has different content - Preserve old behavior for encrypted files and edge cases - Improve logging levels and add thread name tracking for better debugging Signed-off-by: dmiales <[email protected]>
- Replace inefficient trim().isEmpty() with isBlank() method - Extract string literals to constants (LOG_EQUALS_QUOTE, UNKNOWN_PATH) - Add size limits to StringBuilder to prevent memory leaks - Combine nested if statements for better code style Signed-off-by: dmiales <[email protected]>
- Remove empty debug if blocks - Remove DEBUG_XML constant and related debug logging - Remove all Log_OC.d() debug statements - Remove unused UNKNOWN_PATH constant Signed-off-by: dmiales <[email protected]>
7aaf1ad to
7f073c6
Compare
- Combine nested if statements for better code style - Remove hard size limit on StringBuilder, rely on periodic cleanup - Add comments explaining memory safety of StringBuilder usage - Optimize initial StringBuilder capacity to 512 bytes Signed-off-by: dmiales <[email protected]>
- Add @SuppressWarnings for PMD and SonarQube patterns - Add @SuppressFBWarnings for SpotBugs - Add codacy-disable comments - StringBuilder fields are safe: cleared after each XML element and capacity trimmed periodically Signed-off-by: dmiales <[email protected]>
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
Problem:
Users with large photo and video libraries (5000+ files per folder) experience severe performance issues and OutOfMemoryError (OOM) crashes when opening folders. The application receives a massive XML file from the server and attempts to parse it entirely in memory, causing:
Solution:
Rewrote the parsing block from the old ownCloud approach to a new streaming parser implementation. Additionally implemented batch processing for folders. This eliminates OOM errors and significantly improves performance and stability, even with 20,000+ photos and videos in a single folder.
Implementation details: