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
Scope file handles to BundleResource and BundleResourceStream life-times, resolves #309 #390
base: development
Are you sure you want to change the base?
Scope file handles to BundleResource and BundleResourceStream life-times, resolves #309 #390
Conversation
* Scopes the handle to lifetime of BundleResource and BundleResourceStream Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
* Marked numOpenResources as mutable Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
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.
Tests need to be added to framework\test\gtest\OpenFileHandleTest.cpp
for this new behavior.
* Validates that the file handle count goes up after a resource is acquired and goes back down once all resources from a given bundle are released Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
it out Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
@saschazelzer do you have any flags for this? If not i'm planning on merging this in on Monday. Thanks. |
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 looked over the code one more time and noticed a couple things.
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
* Added back constness for BundleArchive again Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
528ce68
to
d2dc576
Compare
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
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.
The code coverage failure can be solved with a slightly different solution. If the default member initialization of numOpenResources is moved to the constructor and the friend classes are removed, at least locally on my machine, this fixes the code coverage error.
I still don't know why this solves the issue though.
My next step is to isolate the friend class change and see if that causes the same code coverage failure.
adding back the friend class (and not the default member initialization of numOpenResources) does not produce the same gcov file containing ~20 lines containing |
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
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.
performance should be measured within the google benchmark tests to see what the overhead is now that a mutex has been introduced.
I ran the two bundle install benchmarks against development and this branch. Here are the results:
|
I'd like to hold off on merging this for now. This change does regress bundle install performance which I believe is important. |
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
I updated this PR by removing the mutex in BundleArchive and replacing it with a std::atomic implementation. The results in this table were generated by running the benchmark test (in Release mode) with --benchmark_repetitions=256. As you can see, the timings are actually better compared to what they were before this change. Update: I've re-ran the tests and updated the table; the other tests were ran while a few applications were running on my computer. I understand that running these benchmark tests in a non-supercomputer like environment can result in varying results, but these are the results I got. |
Newly ran test (release mode, 512 iterations) comparing the mutex implementation vs. the development branch. |
Signed-off-by: The Mathworks Inc <alchrist@mathworks.com>
Signed-off-by: The MathWorks, Inc. <alchrist@mathworks.com>
Signed-off-by: The MathWorks, Inc. <alchrist@mathworks.com>
This PR introduces changes which resolve issue #309 .
Instead of closing BundleResource file handles at the end of the Bundle life-time, they are now cleaned up if there are no opened resources in a given bundle/bundle container. To achieve this, a reference counting method is used to keep track of how many opened resources there are associated with the given bundle. If this number reaches 0, then the container is closed (thus closing the file handles). If a user requests a resource after the bundle has been closed, it is then reopened and their resource is then served all while keeping track of the reference count.