-
-
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
Open
dmiales
wants to merge
6
commits into
nextcloud:master
Choose a base branch
from
dmiales:feature/additional-improvements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,087
−66
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: