Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Unified Diff: courgette/memory_allocator.h

Issue 565753002: Make Courgette as much as 5x faster. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/memory_allocator.h
diff --git a/courgette/memory_allocator.h b/courgette/memory_allocator.h
index 5386dad0d7d9ead4b26bd66d083eefb9f2ceb0d1..ada7f40b8438b42c14d4de0c952d552f727677d9 100644
--- a/courgette/memory_allocator.h
+++ b/courgette/memory_allocator.h
@@ -333,6 +333,12 @@ class NoThrowBuffer {
if (size < kStartSize)
size = kStartSize;
+ // Use a size 1% higher than requested. In practice, this makes Courgette as
+ // much as 5x faster on typical Chrome update payloads as a lot of future
+ // reserve() calls will become no-ops instead of costly resizes that copy
+ // all the data. Note that doing this here instead of outside the function
+ // is more efficient, since it's after the no-op early return checks above.
+ size *= 1.01;
gab 2014/09/12 04:12:19 This will have no impact on reserves below 100, sh
gab 2014/09/12 04:16:06 Oops s/multiple of 2/power of 2/ of course.
T* new_buffer = alloc_.allocate(size);
if (!new_buffer) {
clear();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698