Skip to content

Backport PostData performance fixes and new features #4314

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

Merged
merged 2 commits into from
Jan 10, 2020

Conversation

Mpdreamz
Copy link
Member

Backport of #4313 and #4313

* Several improvements to PostData

New types

* `ReadOnlyMemory`, only available in `netstandard2.1` allows you to
post `ReadOnlyMemory<byte>`
* `StreamHandler` allows you to inject a stream handler and write to the
request streams the best way you see fit yourself

Performance

* `PostData.String` now reuses bytes
* `PostData.MultiJson(string[]) uses way less allocations

* Move StreamHandler in to its own type.

Expose reusable stream handling on `PostData`

Add tests for new types so that they behave and write as expected

* update post-data docs

* Refactor SerializableData and reuse methods from PostData

(cherry picked from commit af93854)
…rialize. (#4313)

* Several improvements to PostData

New types

* `ReadOnlyMemory`, only available in `netstandard2.1` allows you to
post `ReadOnlyMemory<byte>`
* `StreamHandler` allows you to inject a stream handler and write to the
request streams the best way you see fit yourself

Performance

* `PostData.String` now reuses bytes
* `PostData.MultiJson(string[]) uses way less allocations

* Adds more write overloads to Utf8Json

Either memory stream or to serialize on the writer.

This consolidates and funnels places that need to write
bytes/streams/objects directly

(cherry picked from commit de62914)

* add missing hunk after git add -p session

(cherry picked from commit fc289b1)

* add comment explaining the check for possible fast path in sourceformatter

(cherry picked from commit ffc4e46)

* Move fastpath check into method and use it for Deserialize too

(cherry picked from commit f365b30)

* update formatters to use a better check for fast path

(cherry picked from commit b07e0a8)

* Move StreamHandler in to its own type.

Expose reusable stream handling on `PostData`

Add tests for new types so that they behave and write as expected

* Zap IInternalSerializerWithFormatter

* Make sure WriteRaw for memory streams assumes a memorycopy

* Make sure final newline is written again for bulk requests

* Address PR feedback

* reoorder variable assignments

(cherry picked from commit fadef66)
@Mpdreamz Mpdreamz merged commit 42bac9c into 7.x Jan 10, 2020
@Mpdreamz Mpdreamz deleted the backport/7.x/postdata branch January 10, 2020 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant