Repository navigation
Write measurement data to temporary files - #15
Open
josephburkhart wants to merge 15 commits into
Open
josephburkhart wants to merge 15 commits into
josephburkhart wants to merge 15 commits into
Conversation
…tring buffers around
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.
Description
This PR resolves memory issues caused when measuring fields with high position and orientation resolution by streaming measurement data to files on disk, rather than keeping it all in memory.
Currently,
util.simulation.measure()streams data as comma-separated strings into aStringIOobject, and then passes that object back up toSystem.measure()to be processed further. This causes problems when the number of measured positions and orientations is quite large, eventually resulting in out-of-memory issues.This PR resolves that problem by using
StringIOonly as a buffer, and periodically dumping that buffer into a temporary file,<destination>/measure_part<i>.csv, where<destination>is the parent folder of the requested output file and<i>is the process number.Note the following changes:
util.simulation.measure()no longer returns anything, it just writesmeasure_part<i>.csvto disk.System.measure()merges the part files and cleans their headers, somerge_tables()andclean_header()have been removed fromutil/data.py. This merging and cleaning is now memory-friendly, meaning that the part files are never loaded fully into memory. If support is added for new table file formats in the future, this functionality may be moved back intoutil/data.py.System.measure()now checks if files can be read/written/removed from the destination, and it raises an error if they cannot.System.measure()to return a field instance or not. If this were not the case, the whole table file would be loaded into memory and that could cause the same out-of-memory issue. In the future, functionality may be added to allow users to do aggregation over orientations on the file on disk.The new approach is covered by new and existing tests in
test/test_measure.py.The "breaking changes" listed above only impact functions in the
utilmodule, so this PR is not itself considered a breaking change.Motivation and Context
Users often want to measure fields with high resolution on HPC resources. They should not need to request additional compute nodes just to increase the amount of available memory. Additionally, users should be able to measure high resolution fields on their local computers without worrying about running out of memory.
Types of Changes
1The change breaks (or has the potential to break) existing functionality.
Checklist: