Skip to content

mgmt-gateway: Update to new MGS serialization of large messages#733

Merged
jgallagher merged 2 commits into
masterfrom
mgmt-gateway-better-serialization
Aug 29, 2022
Merged

mgmt-gateway: Update to new MGS serialization of large messages#733
jgallagher merged 2 commits into
masterfrom
mgmt-gateway-better-serialization

Conversation

@jgallagher

Copy link
Copy Markdown
Contributor

Update payloads and serial console packets are now serialized as raw
data after a hubpack-encoded message, instead of the data being
embedded as part of the hubpack message. Formerly we were required to
allocate several moderately-sized arrays on the stack and copy data
unnecessarily; now the raw data is borrowed from the receive buffer we
pass to net, which requires no extra copies or stack allocation of
large arrays.

This is the hubris half of oxidecomputer/omicron#1645, which did the MGS side of this work.

We get significant improvements in flash and stack, and a modest improvement in ram (although it doesn't look like it at first glance). Before this PR:

# xtask sizes
PROGRAM        REGION  USED   SIZE   LIMIT
mgmt_gateway   flash   26764  32768  32768
               ram     6444   8192   8192

# stackmargin after performing an update, before resetting
ID TASK                STACKBASE  STACKSIZE   MAXDEPTH     MARGIN
11 mgmt_gateway       0x20004000       4096       3416        680

After this PR:

# xtask sizes
PROGRAM        REGION  USED   SIZE   LIMIT
mgmt_gateway   flash   19220  32768  32768
               ram     7456   8192   8192
               
# stackmargin after performing an update, before resetting
ID TASK                STACKBASE  STACKSIZE   MAXDEPTH     MARGIN
11 mgmt_gateway       0x20004000       1536       1048        488

Our absolute ram usage goes up by about 1k, but our buffers are significantly larger: we can now receive ~1k update chunks (previously 512 bytes), and we can send and receive ~1k serial console packets (previously 128 bytes). Handwaving a bit, I think we have about 1.8k more buffer space for only 1k more ram usage.

@jgallagher jgallagher requested a review from mkeeter August 25, 2022 20:43
Comment thread app/gimletlet/app.toml Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Comment thread task/mgmt-gateway/src/main.rs Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of destructuring in function arguments, but that's just, like, my opinion, man.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, me neither. IIRC this is a relic of trying to get cargo fmt to do something reasonable with a long line before I introduced the SerializedMessageBuf typedef; it was doing something heinous like

buffers: &'static mut [ArrayVec<[u8; SOME_LONG_CONSTANT]>;
                       2],

With the typedef I don't think that's a concern any more, so I'll switch this back.

@jgallagher jgallagher force-pushed the mgmt-gateway-better-serialization branch from f4102ce to 7f4fe83 Compare August 29, 2022 16:22
Update payloads and serial console packets are now serialized as raw
data _after_ a hubpack-encoded message, instead of the data being
embedded as part of the hubpack message. Formerly we were required to
allocate several moderately-sized arrays on the stack and copy data
unnecessarily; now the raw data is borrowed from the receive buffer we
pass to `net`, which requires no extra copies or stack allocation of
large arrays.
@jgallagher jgallagher force-pushed the mgmt-gateway-better-serialization branch from 7f4fe83 to 5f441ea Compare August 29, 2022 17:17
@jgallagher jgallagher enabled auto-merge (squash) August 29, 2022 17:17
@jgallagher jgallagher merged commit c68e347 into master Aug 29, 2022
@jgallagher jgallagher deleted the mgmt-gateway-better-serialization branch August 29, 2022 17:38
FawazTirmizi pushed a commit to rivosinc/hubris that referenced this pull request Oct 3, 2022
…ecomputer#733)

Update payloads and serial console packets are now serialized as raw
data _after_ a hubpack-encoded message, instead of the data being
embedded as part of the hubpack message. Formerly we were required to
allocate several moderately-sized arrays on the stack and copy data
unnecessarily; now the raw data is borrowed from the receive buffer we
pass to `net`, which requires no extra copies or stack allocation of
large arrays.
FawazTirmizi pushed a commit to rivosinc/hubris that referenced this pull request Oct 3, 2022
…ecomputer#733)

Update payloads and serial console packets are now serialized as raw
data _after_ a hubpack-encoded message, instead of the data being
embedded as part of the hubpack message. Formerly we were required to
allocate several moderately-sized arrays on the stack and copy data
unnecessarily; now the raw data is borrowed from the receive buffer we
pass to `net`, which requires no extra copies or stack allocation of
large arrays.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants