-
Notifications
You must be signed in to change notification settings - Fork 881
Conversation
ef88c5b
to
71b7af8
Compare
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
71b7af8
to
ef88c5b
Compare
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
ef88c5b
to
897f7ba
Compare
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
6059ee0
to
8170ef1
Compare
d09c1ec
to
721cf3f
Compare
|
||
template <class MutableDerivedVersionHandleType, | ||
class ConfigType, class VersionDType> | ||
MutableDerivedVersionHandleType ReuseOrMakeAndUpdate(const std::string& ref_, |
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 copied over all the ReuseOrMakeAndUpdate* functions from earlier versions, which was the fix to one of the issues. Unfortunately it makes the diff hard to read.
} | ||
else | ||
{ | ||
version.NoLongerNeeded(); |
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.
Removing the NoLongerNeeded calls was a fix to one of the bugs.
@@ -49,210 +55,181 @@ namespace AssetFactory | |||
return nullptr; | |||
} | |||
|
|||
template<class AssetType> |
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.
Most of the changes in this file are to use new template parameters that make the code clearer and make it easier to use the right template parameters. I also deleted a few functions that weren't used.
@@ -27,49 +28,13 @@ | |||
using namespace std; | |||
using namespace AssetFactory; | |||
|
|||
// forward declare classes |
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 essentially rewrote the MockAsset class hierarchy from scratch. I tried to keep parts from the original version but that probably won't show up in the diff. The tests themselves should be more similar, but I did make some changes, including getting rid of duplicate tests and adding new tests to get better coverage.
} | ||
|
||
template<class VersionType> | ||
template<class AssetType> | ||
inline typename AssetType::VersionD FindVersion(const std::string & ref, const AssetDefs::Type & type) { |
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 Find
function is a special case since it can find assets or asset versions, but the new template parameter includes both assets and versions in the same struct. I got around that by creating a FindVersion
function so the regular Find
function can always return an asset. The FindVersion
function is only used below in this file.
@@ -283,6 +275,20 @@ () | |||
|
|||
print $fh <<EOF; | |||
|
|||
// Convenience class that ties together related types |
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 struct puts all the classes that relate to a specific asset type into one place where it's easy to reference several of them at once. It makes the Asset Factory functions much cleaner, but it requires a lot of changes to use it.
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 makes the template parameters a LOT cleaner.
I didn't test, but the code looks good to me. I don't see where the bug was in ReuseOrMakeAndUpdate, either... It looks nearly identical. |
* Move ReuseOrMakeAndUpdate out of the asset factory * Don't remove assets from the cache unnecessarily * Improved error handling in Storage Manager * Simply asset factory templates and remove unused functions * Move ReuseOrMakeAndUpdate back to the asset factory * Clean up unnecessary namespace references * Improve test coverage
This fixes two issues that cause extra versions to be produced unnecessarily during a build. The resulting database is correct, but the size of the database on disk is much larger than necessary.
The actual fixes are fairly small, but I did quite a bit of debugging and refactoring to track down the issue. Instead of throwing away the refactoring I am including it, so the changes are larger than one might expect. I tried to organize the changes into good commits, so it may be easier to review one commit at a time.
Here is a list of the major things I changed. I'll also provide comments on the PR to explain some of the changes.
As a side effect of this fix, builds should be somewhat faster (due to building fewer versions of assets) and memory usage may be much less (due to extra versions of assets not hanging around in memory after they are removed from the cache). I've seen memory usage reductions of as much as 2/3 in system manager.
Fixes #1731