Skip to content

buffer: shrink Slice by moving rare state out of line to save memory - #47101

Draft
botengyao wants to merge 1 commit into
envoyproxy:mainfrom
botengyao:buffer-slice-shrink
Draft

buffer: shrink Slice by moving rare state out of line to save memory#47101
botengyao wants to merge 1 commit into
envoyproxy:mainfrom
botengyao:buffer-slice-shrink

Conversation

@botengyao

Copy link
Copy Markdown
Member

drain_trackers_, account_ and releasor_ are unset on almost every slice but account for 72 of Slice's 112 bytes. Holding them in a lazily allocated Extras takes sizeof(Slice) to 48 bytes, shrinking the 8-slice inline ring every OwnedImpl embeds from 896 to 384 bytes and making a slice move a single pointer move. Slices that do carry an account or a fragment releasor pay one extra small allocation, which is minor next to the >=4kb storage allocation an owned slice already makes.

Commit Message:
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

drain_trackers_, account_ and releasor_ are unset on almost every slice
but account for 72 of Slice's 112 bytes. Holding them in a lazily
allocated Extras takes sizeof(Slice) to 48 bytes, shrinking the 8-slice
inline ring every OwnedImpl embeds from 896 to 384 bytes and making a
slice move a single pointer move. Slices that do carry an account or a
fragment releasor pay one extra small allocation, which is minor next to
the >=4kb storage allocation an owned slice already makes.

Signed-off-by: Boteng Yao <botengyao@gmail.com>
@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #47101 was opened by botengyao.

see: more, trace.

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.

1 participant