New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpObjectEncoder buffer size estimation #7161

Closed
wants to merge 1 commit into
base: 4.1
from

Conversation

Projects
None yet
2 participants
@Scottmitch
Member

Scottmitch commented Aug 29, 2017

Motivation:
HttpObjectEncoder allocates a new buffer when encoding the initial line and headers, and also allocates a buffer when encoding the trailers. The allocation always uses the default size of 256. This may lead to consistent under allocation and require a few resize/copy operations which can cause GC/memory pressure.

Modifications:

  • Introduce a weighted average which tracks the historical size of encoded data and uses this as an estimate for future buffer allocations

Result:
Better approximation of buffer sizes.

HttpObjectEncoder buffer size estimation
Motivation:
HttpObjectEncoder allocates a new buffer when encoding the initial line and headers, and also allocates a buffer when encoding the trailers. The allocation always uses the default size of 256. This may lead to consistent under allocation and require a few resize/copy operations which can cause GC/memory pressure.

Modifications:
- Introduce a weighted average which tracks the historical size of encoded data and uses this as an estimate for future buffer allocations

Result:
Better approximation of buffer sizes.

@Scottmitch Scottmitch requested a review from normanmaurer Aug 29, 2017

@normanmaurer

This comment has been minimized.

Show comment
Hide comment
@normanmaurer

normanmaurer Aug 29, 2017

Member

@Scottmitch ship it... nice change

Member

normanmaurer commented Aug 29, 2017

@Scottmitch ship it... nice change

@Scottmitch Scottmitch added this to the 4.1.16.Final milestone Aug 31, 2017

@Scottmitch Scottmitch self-assigned this Aug 31, 2017

@Scottmitch

This comment has been minimized.

Show comment
Hide comment
@Scottmitch
Member

Scottmitch commented Aug 31, 2017

4.1 (9bd6d81)

@Scottmitch Scottmitch closed this Aug 31, 2017

@Scottmitch Scottmitch deleted the Scottmitch:http_object_encoder_sizes branch Aug 31, 2017

@normanmaurer

This comment has been minimized.

Show comment
Hide comment
@normanmaurer

normanmaurer Aug 31, 2017

Member

I also cherry-picked into 4.0 (4732fab). Was easy to do and makes maintenance easier.

Member

normanmaurer commented Aug 31, 2017

I also cherry-picked into 4.0 (4732fab). Was easy to do and makes maintenance easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment