-
Notifications
You must be signed in to change notification settings - Fork 626
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
Fix for reading memory mapped files with DWA compression #1333
Fix for reading memory mapped files with DWA compression #1333
Conversation
Signed-off-by: Darby Johnston <[email protected]>
Signed-off-by: Darby Johnston <[email protected]>
Signed-off-by: Darby Johnston <[email protected]>
@@ -2250,10 +2251,12 @@ DwaCompressor::uncompress ( | |||
// Flip the counters from XDR to NATIVE | |||
// | |||
|
|||
std::array<uint64_t, NUM_SIZES_SINGLE> counterBuf; | |||
memcpy (counterBuf.data (), inPtr, counterBuf.size() * sizeof (uint64_t)); |
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.
I imagine since the data is all going to be touched subsequently, this has no performance implication, and may improve things through cache prewarming?
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.
It's a fairly small buffer, currently NUM_SIZES_SINGLE = 11, so 88 bytes?
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.
This all looks good to me, and having the extra test coverage for memmapped files is great.
Thanks! It looks like the CI is failing from a network timeout:
|
Thanks for the fix, and especially for the tests! Just to confirm, this should be ABI compatible, right? It looks like you've exposed a previously hidden symbol WidenFilename, but that's the only API/ABI change? |
Yes, the only change to the API is exposing the |
It looks like WidenFilename was already duplicated in |
Signed-off-by: Darby Johnston <[email protected]>
Sure thing, I removed the function in |
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.
LGTM, thanks!
…wareFoundation#1333) * Test memory mapping Signed-off-by: Darby Johnston <[email protected]> * Add Windows memory mapping Signed-off-by: Darby Johnston <[email protected]> * Fix for DWAA conpression and memory mapping Signed-off-by: Darby Johnston <[email protected]> * Remove duplicate code Signed-off-by: Darby Johnston <[email protected]> --------- Signed-off-by: Darby Johnston <[email protected]>
* Test memory mapping Signed-off-by: Darby Johnston <[email protected]> * Add Windows memory mapping Signed-off-by: Darby Johnston <[email protected]> * Fix for DWAA conpression and memory mapping Signed-off-by: Darby Johnston <[email protected]> * Remove duplicate code Signed-off-by: Darby Johnston <[email protected]> --------- Signed-off-by: Darby Johnston <[email protected]>
Hi, I mentioned this issue at a TSC meeting a couple of months ago, sorry for the delay in creating a PR.
I use a custom class derived from
Imf::IStream
for reading .exr files that supports memory mapping on Windows and Linux/macOS. I noticed I was getting crashes when reading DWA compressed files, and after looking into it discovered that the DWA code was writing into read only data by casting away theconst
. I guess for regular I/O this didn't cause an issue since it is buffered, but it does cause a crash with memory mapped data. For example in Visual Studio:This PR includes both a fix for the DWA code and adds support for memory mapped I/O to the tests. Specifically:
testExistingStreams
testExistingStreams
to run the tests with all compression typesWidenFilename()
toImfMisc.h/.cpp
for use with Windows filenamesWidenFilename()
to usestd::wstring_convert()
It would also be nice to change
char* IStream::readMemoryMapped()
toconst char* IStream::readMemoryMapped()
since the memory should be read only, or that could be a separate PR.