Summary: | speculative generality in message (de)marshalling increases complexity | ||
---|---|---|---|
Product: | dbus | Reporter: | Simon McVittie <smcv> |
Component: | core | Assignee: | D-Bus Maintainers <dbus> |
Status: | RESOLVED MOVED | QA Contact: | D-Bus Maintainers <dbus> |
Severity: | enhancement | ||
Priority: | low | CC: | bart.cerneels, chengwei.yang.cn, msniko14, smcv |
Version: | 1.5 | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: | work-in-progress patch which adds DBusWriteVector |
Description
Simon McVittie
2011-06-14 03:39:14 UTC
For bonus points, we could consider reading messages via scatter-gather I/O too, which would mean we never needed to copy or realign them: * first read is 16 bytes, for the lengths * subsequent reads are a struct iovec[5] for: * the header * the padding after the header, if any (just to check that it's zeroed) * the body * the padding after the body, if any (just to check that it's zeroed) * the next 16 bytes, if another message is immediately available but we'd need to benchmark that to see if it was actually better in practice. Created attachment 47950 [details] [review] work-in-progress patch which adds DBusWriteVector See dbus-iovec.h in the patch. This probably doesn't compile or work, but could be a useful starting point. (In reply to Simon McVittie from comment #0) > * Write messages into sockets by using scatter-gather I/O, with a struct > iovec[n + 2] pointing to the 16-byte fixed part, the n header fields, > and the body When I mentioned this to Allison she warned me that this is not really how writev/sendmsg is meant to be used, so we might have to back off from actually doing the scatter/gather part. However, it seems entirely plausible to have a data structure something like this pseudocode: char[16] fixed_length_part; DBusString header_field_storage; and do field insertion, replacement and deletion like this: iter = beginning of header_field_storage; while ((iter = next field in header_field_storage) != end) { if (field ID == the one we want to replace or delete) { work out length of this field (it is a struct (yv)) if (it is the last one in the buffer) { truncate immediately after the previous field, deleting padding } else { round up to the next 8-byte unit to count the alignment padding memmove everything after that point downwards to cover it truncate after the segment we moved } } } add 0-7 bytes of new alignment append new ID, type, value of field as a new struct (yv) -- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/dbus/dbus/issues/47. |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.