Commit 79813025 authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Mojo: Reduce default message allocation size

4 kB is a bit large. Microbenchmarks don't indicate a performance
hit when lowering this, and they may even improve on lower-end
devices.

This decreases the default size to 128 bytes. We can monitor perf
dashboards for the effect.

Also fixes a bug in test code which assumed an allocation wouldn't
resize a message, since that actually happens now.

Bug: None
Change-Id: Ibc7d17fe6f7cc98db7b290862cd4aea0f9be4fe0
Reviewed-on: https://chromium-review.googlesource.com/992553Reviewed-by: default avatarJay Civelli <jcivelli@chromium.org>
Commit-Queue: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548079}
parent 8c7af6e2
...@@ -33,7 +33,7 @@ namespace { ...@@ -33,7 +33,7 @@ namespace {
// The minimum amount of memory to allocate for a new serialized message buffer. // The minimum amount of memory to allocate for a new serialized message buffer.
// This should be sufficiently large such that most seiralized messages do not // This should be sufficiently large such that most seiralized messages do not
// incur any reallocations as they're expanded to full size. // incur any reallocations as they're expanded to full size.
const uint32_t kMinimumPayloadBufferSize = 4096; const uint32_t kMinimumPayloadBufferSize = 128;
// Indicates whether handle serialization failure should be emulated in testing. // Indicates whether handle serialization failure should be emulated in testing.
bool g_always_fail_handle_serialization = false; bool g_always_fail_handle_serialization = false;
......
...@@ -82,7 +82,8 @@ U SerializeAndDeserialize(T input) { ...@@ -82,7 +82,8 @@ U SerializeAndDeserialize(T input) {
void* subsequent_area = message.payload_buffer()->AllocateAndGet(32); void* subsequent_area = message.payload_buffer()->AllocateAndGet(32);
memset(subsequent_area, 0xAA, 32); memset(subsequent_area, 0xAA, 32);
OutputDataType output_data = reinterpret_cast<OutputDataType>(data); OutputDataType output_data =
reinterpret_cast<OutputDataType>(message.mutable_payload());
U output; U output;
mojo::internal::Deserialize<OutputMojomType>(output_data, &output, &context); mojo::internal::Deserialize<OutputMojomType>(output_data, &output, &context);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment