-
Notifications
You must be signed in to change notification settings - Fork 978
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
Conversation
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.
Did you run golden_test.sh?
guetzli/butteraugli_comparator.cc
Outdated
@@ -31,6 +31,7 @@ ButteraugliComparator::ButteraugliComparator(const int width, const int height, | |||
: width_(width), | |||
height_(height), | |||
target_distance_(target_distance), | |||
rgb_orig_(rgb), |
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.
Please make the constructor parameter a const pointer if we now expect it be live as long as this class is live.
guetzli/comparator.h
Outdated
@@ -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. |
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.
Nit: unless you call Start...
again.
guetzli/processor.cc
Outdated
@@ -719,6 +719,8 @@ void Processor::SelectFrequencyMasking(const JPEGData& jpg, OutputImage* img, | |||
break; | |||
} | |||
} | |||
size_t global_order_size = global_order.size(); | |||
global_order.clear(); |
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 was under the impression that this doesn't actually release the memory.
guetzli/processor.cc
Outdated
@@ -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); |
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.
So maybe merge this with the commit that added the clear?
9713db1
to
f304c49
Compare
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.
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.