docs: update README usage section with serialize sample and blittable structs - #89
docs: update README usage section with serialize sample and blittable structs#89google-labs-jules[bot] wants to merge 4 commits into
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
| Blittable structs provide significant benefits: | ||
| - **No Offset Table**: Serialized directly as raw memory payloads without field offset overhead. | ||
| - **Instant Materialization**: Convert a View directly back to the original struct using the `.Materialize()` extension method. | ||
| - **Maximum Performance**: Fast direct memory copy operations with zero deserialization overhead. |
There was a problem hiding this comment.
| - **Maximum Performance**: Fast direct memory copy operations with zero deserialization overhead. | |
| - **Maximum Performance**: Fast direct memory copy operations with zero serialization/deserialization overhead. |
There was a problem hiding this comment.
Applied suggestion to emphasize zero serialization/deserialization overhead.
|
|
||
| Blittable structs provide significant benefits: | ||
| - **No Offset Table**: Serialized directly as raw memory payloads without field offset overhead. | ||
| - **Instant Materialization**: Convert a View directly back to the original struct using the `.Materialize()` extension method. |
There was a problem hiding this comment.
| - **Instant Materialization**: Convert a View directly back to the original struct using the `.Materialize()` extension method. |
There was a problem hiding this comment.
Applied suggestion to remove redundant materialization bullet point.
|
|
||
| // Serializing a blittable struct (exact fixed byte size available via RequiredByteLength) | ||
| var transform = new Transform { PositionX = 1.0f, PositionY = 2.0f, PositionZ = 3.0f }; | ||
| var buffer = new byte[TransformView.RequiredByteLength]; |
There was a problem hiding this comment.
| var buffer = new byte[TransformView.RequiredByteLength]; | |
| var buffer = new byte[TransformView.RequiredByteLength]; // 12 bytes |
There was a problem hiding this comment.
Applied suggestion to add '// 12 bytes' comment to byte array allocation.
|
|
||
| // Serializing data into a buffer using generated 'Serialize' extension method. | ||
| var packet = new Packet { Id = 1, Name = "John", Values = new[] { 10, 20 } }; | ||
| var buffer = new byte[256]; |
There was a problem hiding this comment.
| var buffer = new byte[256]; | |
| Span<byte> buffer = stackalloc byte[256]; |
There was a problem hiding this comment.
Applied suggestion to use stackalloc byte buffer for serialization.
| Structs marked with both `[ZeroSerializer]` and `[StructLayout(LayoutKind.Sequential, Pack = 1)]` are recognized as blittable structs. | ||
|
|
||
| Blittable structs provide significant benefits: | ||
| - **No Offset Table**: Serialized directly as raw memory payloads without field offset overhead. |
There was a problem hiding this comment.
| - **No Offset Table**: Serialized directly as raw memory payloads without field offset overhead. | |
| - **No Offset Table**: Serialized directly as raw memory payloads without field offset table. |
There was a problem hiding this comment.
Applied suggestion to update wording to 'field offset table'.
|
|
||
| Blittable structs provide significant benefits: | ||
| - **No Offset Table**: Serialized directly as raw memory payloads without field offset overhead. | ||
| - **Maximum Performance**: Fast direct memory copy operations with zero serialization/deserialization overhead. |
There was a problem hiding this comment.
| - **Maximum Performance**: Fast direct memory copy operations with zero serialization/deserialization overhead. | |
| - **Maximum Performance**: Fast direct memory copy operations with zero overhead. |
There was a problem hiding this comment.
Applied suggestion to simplify maximum performance description.
| @@ -58,6 +63,35 @@ ReadOnlyMemory<byte> retainedData = packetView; | |||
| ``` | |||
There was a problem hiding this comment.
Removed implicit conversion section as suggested.
| int writtenBytes = packet.Serialize(buffer); | ||
| ``` | ||
|
|
||
| View construction does not read every property. Values are decoded directly from the original memory only on access. |
There was a problem hiding this comment.
| View construction does not read every property. Values are decoded directly from the original memory only on access. | |
| > [!TIP] | |
| > View construction does not read every property. Values are decoded directly from the original memory only on access. |
There was a problem hiding this comment.
Formatted view construction note as a GitHub [!TIP] callout.
Added serialize code sample to the existing code block in the Usage section of README.md and introduced a dedicated 'Blittable Structs' subsection outlining their benefits and usage.
PR created automatically by Jules for task 17471951661693468938 started by @sator-imaging