Skip to content
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

Reduce guetzli memory usage by 30% #156

Merged
merged 8 commits into from
Mar 31, 2017
Merged

Reduce guetzli memory usage by 30% #156

merged 8 commits into from
Mar 31, 2017

Conversation

szabadka
Copy link
Contributor

This PR continues to address #11

Peak memory usage of the ~1MP station.png file from the test corpus went from 161 MiB to 110 MiB.

@szabadka szabadka requested a review from robryk March 31, 2017 12:36
Copy link
Contributor

@robryk robryk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you run golden_test.sh?

@@ -31,6 +31,7 @@ ButteraugliComparator::ButteraugliComparator(const int width, const int height,
: width_(width),
height_(height),
target_distance_(target_distance),
rgb_orig_(rgb),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the constructor parameter a const pointer if we now expect it be live as long as this class is live.

@@ -36,6 +36,11 @@ class Comparator {
// baseline image.
virtual void Compare(const OutputImage& img) = 0;

// Must be called before any CompareBlock() calls can be called.
virtual void StartBlockComparisons() = 0;
// No more CompareBlock() calls can be called after this.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: unless you call Start... again.

@@ -719,6 +719,8 @@ void Processor::SelectFrequencyMasking(const JPEGData& jpg, OutputImage* img,
break;
}
}
size_t global_order_size = global_order.size();
global_order.clear();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression that this doesn't actually release the memory.

@@ -709,7 +709,7 @@ void Processor::SelectFrequencyMasking(const JPEGData& jpg, OutputImage* img,
}
}
size_t global_order_size = global_order.size();
global_order.clear();
std::vector<std::pair<int, float>>().swap(global_order);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe merge this with the commit that added the clear?

@szabadka szabadka force-pushed the master branch 2 times, most recently from 9713db1 to f304c49 Compare March 31, 2017 14:13
Instead, compute it and store it only for those blocks that are
being processed in ComputeBlockZeroingOrder().

This saves about 12 bytes / pixel memory usage.
…mory.

This saves about 12 bytes / pixel memory usage.
for block orders into three parts:
  * an std::vector<uint8_t> for coeff indexes within blocks
  * an std::vector<float> for block errors corresponding to above indexes
  * an std::vector<int> for offsets into the above two arrays for each block
Actual memory usage on a 1 MP image was 110 MiB.
@szabadka szabadka merged commit e09417e into google:master Mar 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants