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

Unified Diff: base/trace_event/trace_event_memory_overhead.cc

Issue 1249643007: Align base::Pickle allocations to 4k boundaries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@accounting_fix
Patch Set: Nits test Created 5 years, 5 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
« base/bits_unittest.cc ('K') | « base/trace_event/trace_event_argument.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/trace_event_memory_overhead.cc
diff --git a/base/trace_event/trace_event_memory_overhead.cc b/base/trace_event/trace_event_memory_overhead.cc
index 5ece315c00f30485ee0dce9c997b83de6007f3ee..b685d7183f2e4a2411cc212ed3b3987780dee85f 100644
--- a/base/trace_event/trace_event_memory_overhead.cc
+++ b/base/trace_event/trace_event_memory_overhead.cc
@@ -6,18 +6,13 @@
#include <algorithm>
+#include "base/bits.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/memory_allocator_dump.h"
#include "base/trace_event/process_memory_dump.h"
#include "base/values.h"
-namespace {
-size_t RoundUp(size_t size, size_t alignment) {
- return (size + alignment - 1) & ~(alignment - 1);
-}
-} // namespace
-
namespace base {
namespace trace_event {
@@ -61,9 +56,9 @@ void TraceEventMemoryOverhead::AddString(const std::string& str) {
// The number below are empirical and mainly based on profiling of real-world
// std::string implementations:
// - even short string end up malloc()-inc at least 32 bytes.
- // - longer stings seem to malloc() multiples of 16 bytes.
- Add("std::string",
- sizeof(std::string) + std::max<size_t>(RoundUp(str.capacity(), 16), 32u));
+ // - longer strings seem to malloc() multiples of 16 bytes.
+ const size_t capacity = bits::Align(str.capacity(), 16);
+ Add("std::string", sizeof(std::string) + std::max<size_t>(capacity, 32u));
}
void TraceEventMemoryOverhead::AddRefCountedString(
« base/bits_unittest.cc ('K') | « base/trace_event/trace_event_argument.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698