Rewrite MATLAB functions with matlab.io.xml.dom.*#351
Open
Jerry1144 wants to merge 1 commit into
Open
Conversation
Circumvent Java heap size problems with recent MATLAB dealing with large XML. MATLAB's `io.xml.xpath.*` appears to execute eagerly and over-consumes memory Walking the dom tree ourselves is slower than native `readtable()` when every sub-node are consolidated into one big table, but the latter cannot easily handle "one edge table per track" which is required by trackmateEdges.m Also replaced every `str2double` with `double(string())` per recommendation.
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
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.
Rewrite with matlab.io.xml.dom.* facilities, avoiding Java heap size problems. Available since R2021a. One path to #343. Force-push of #346
A detour from #345 -
trackmateEdgesrequires one table per track node, but it isn't possible to express a parent node's attribute in XPath 1.0, and callingreadtable()once per track is slow (50+h from my 16k track file).Then, to keep the total memory use in check, all function in the series must adhere to a single path. Apparently memory reuse does not happen across
readstruct,readtable, andmatlab.io.xml.*, and GC only occurs during inactivity. Thus the total rewrite.Finally, I eliminated all calls to
str2double(one function call for each attribute for each node!), replacing them with the weird-lookingdouble(string())per Mathworks recommendation. Speed up is very significant. I also changed text preallocation tostrings, with no noticeable impact.PS: Text comparison still uses
strcmp, which is faster than string's==.PPS: Why text preallocation using
stringsnot brings improvements, is beyond me. I changed that only for aesthetic reasons.