Open Bug 884978 Opened 11 years ago Updated 2 years ago

improve serialization/deserialization to only check needed buffer space once

Categories

(Core :: DOM: Content Processes, defect, P3)

defect

Tracking

()

People

(Reporter: froydnj, Unassigned)

References

Details

(Whiteboard: [leave open])

+++ This bug was initially created as a clone of Bug #871596 +++ Our IPC code is directly in the critical path, especially on B2G (e.g. time from finger down to the action being reflected on the screen has IPC right in the middle of it). For some unrelated things, I was looking at the serialization/deserialization code. The higher-level code (e.g. structs etc.) calls down to lower level primitives, which eventually get to code in Pickle (e.g. ReadInt32) and friends. This code isn't in a header file, so likely doesn't get inlined, and each one looks something like: bool Pickle::ReadInt32(void** iter, int32_t* result) const { DCHECK(iter); if (!*iter) *iter = const_cast<char*>(payload()); if (!IteratorHasRoomFor(*iter, sizeof(*result))) return false; memcpy(result, *iter, sizeof(*result)); UpdateIter(iter, sizeof(*result)); return true; } IteratorHasRoomFor() does checks on the current iter pointer, the message header, and the remaining size to make sure that we can read sizeof(*result) from it. This all seems like a large amount of overhead to me. There's no reason why we shouldn't be able to generate code to directly [de]serialize all the primitive data types straight in the higher-level generated message/struct code for this, including doing one size check early on, instead of calling multiple layers to eventually get to a ReadInt32 above.
Component: IPC → DOM: Content Processes
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.