This repository was archived by the owner on Nov 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 191
ResponseCookies.Append()
allocates lots, big lots
#561
Comments
@dougbu Are you able to send a PR to reuse the StringBuilder? |
Sure. I'll do that today. |
Offline discussion w/ @Tratcher: Reusing a |
@dougbu That makes sense. |
dougbu
added a commit
to aspnet/Hosting
that referenced
this issue
Mar 15, 2016
- can now use pooled `StringBuilder`s to address aspnet/HttpAbstractions#561 and similar issues nit: Fix incomplete test noted when adding new one
dougbu
added a commit
that referenced
this issue
Mar 15, 2016
dougbu
added a commit
that referenced
this issue
Mar 17, 2016
…tures` package and namespace - related to #561 - move required interfaces and classes down from `Microsoft.AspNetCore.Http.Abstractions` - move everything in the `Microsoft.AspNetCore.Http.Features` into their own directory nit: remove transient dependencies listed in `Microsoft.AspNetCore.Http.Abstractions`'s `project.json`
dougbu
added a commit
to aspnet/Hosting
that referenced
this issue
Mar 18, 2016
dougbu
added a commit
to aspnet/KestrelHttpServer
that referenced
this issue
Mar 18, 2016
dougbu
added a commit
to aspnet/Security
that referenced
this issue
Mar 18, 2016
This was referenced Mar 18, 2016
Merged
dougbu
added a commit
that referenced
this issue
Mar 18, 2016
…tures` package and namespace - related to #561 - move required interfaces and classes down from `Microsoft.AspNetCore.Http.Abstractions` - move everything in the `Microsoft.AspNetCore.Http.Features` into their own directory nit: remove transient dependencies listed in `Microsoft.AspNetCore.Http.Abstractions`'s `project.json`
dougbu
added a commit
to aspnet/KestrelHttpServer
that referenced
this issue
Mar 19, 2016
dougbu
added a commit
to aspnet/Security
that referenced
this issue
Mar 19, 2016
dougbu
added a commit
that referenced
this issue
Mar 20, 2016
… cookies - #561 - new `SetCookieHeaderValue.AppendToStringBuilder()` method; avoids per-call `StringBuilder` allocation - `ResponseCookies` uses `ObjectPool<StringBuilder>` that `ResponseCookiesFeature` provides - `ResponseCookiesFeature` creates an `ObjectPoolProvider` instance if none in DI - `IResponseCookiesFeature` exposes `int` properties supporting middleware overrides of the pool policy nit: Add some doc comments
dougbu
added a commit
that referenced
this issue
Mar 21, 2016
…tures` package and namespace - #590, also related to #561 - move feature interfaces from `Microsoft.AspNetCore.Http` package - move required classes from `Microsoft.AspNetCore.Http.Abstractions` package - move `ISession` and `WebSocketAcceptContext` to `Microsoft.AspNetCore.Http` namespace (#590) nit: remove transient dependencies listed in `Microsoft.AspNetCore.Http.Abstractions`'s `project.json`
dougbu
added a commit
to aspnet/Hosting
that referenced
this issue
Mar 21, 2016
For exposing the feature interfaces (no longer in |
dougbu
added a commit
that referenced
this issue
Mar 21, 2016
… cookies - #561 - new `SetCookieHeaderValue.AppendToStringBuilder()` method; avoids per-call `StringBuilder` allocation - `ResponseCookies` uses `ObjectPool<StringBuilder>` that `ResponseCookiesFeature` provides - `ResponseCookiesFeature` creates an `ObjectPoolProvider` instance if none in DI - `IResponseCookiesFeature` exposes `int` properties supporting middleware overrides of the pool policy nit: Add some doc comments
dougbu
added a commit
that referenced
this issue
Mar 21, 2016
… cookies - #561 - new `SetCookieHeaderValue.AppendToStringBuilder()` method; avoids per-call `StringBuilder` allocation - `ResponseCookies` uses `ObjectPool<StringBuilder>` that `ResponseCookiesFeature` provides - `ResponseCookiesFeature` creates an `ObjectPoolProvider` instance if none in DI - `IResponseCookiesFeature` exposes `int` properties supporting middleware overrides of the pool policy nit: Add some doc comments
dougbu
added a commit
to aspnet/Session
that referenced
this issue
Mar 23, 2016
- take advantage of aspnet/HttpAbstractions#561 fix
dougbu
added a commit
to aspnet/Security
that referenced
this issue
Mar 23, 2016
- take advantage of aspnet/HttpAbstractions#561 fix
dougbu
added a commit
that referenced
this issue
Mar 23, 2016
… cookies - #561 - new `SetCookieHeaderValue.AppendToStringBuilder()` method; avoids per-call `StringBuilder` allocation - `ResponseCookies` uses `ObjectPool<StringBuilder>` that `ResponseCookiesFeature` provides - `ResponseCookiesFeature` creates an `ObjectPoolProvider` instance if none in DI - `IResponseCookiesFeature` exposes `int` properties supporting middleware overrides of the pool policy nit: Add some doc comments
This was referenced Mar 23, 2016
dougbu
added a commit
to aspnet/Hosting
that referenced
this issue
Mar 23, 2016
- e.g. take advantage of aspnet/HttpAbstractions#561 fix wherever cookies are used
dougbu
added a commit
to aspnet/HttpSysServer
that referenced
this issue
Mar 24, 2016
dougbu
added a commit
that referenced
this issue
Mar 25, 2016
… cookies - #561 - new `SetCookieHeaderValue.AppendToStringBuilder()` method; avoids per-call `StringBuilder` allocation - `ResponseCookies` uses `ObjectPool<StringBuilder>` that `ResponseCookiesFeature` provides - `ResponseCookies` works fine if no `ObjectPoolProvider` is available - `IHttpContextFactory` instance is a singleton instantiated from CI - make `HttpContextFactory` `ObjectPoolProvider` and `ResponseCookiesFeature`-aware - apply same pattern to sample `PooledHttpContextFactory` - pool is not currently configurable; defaults are fine for response cookies - if we need (policy) configuration, would add an `IOptions<HttpContextFactorySettings>` nit: Add some doc comments
dougbu
added a commit
to aspnet/Hosting
that referenced
this issue
Mar 25, 2016
- e.g. take advantage of aspnet/HttpAbstractions#561 fix wherever cookies are used
dougbu
added a commit
to aspnet/HttpSysServer
that referenced
this issue
Mar 25, 2016
- remove unused field - see pull aspnet/HttpAbstractions#594 and issue aspnet/HttpAbstractions#561
Part two for the actual fix:
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Despite using
StringValues
s,ResponseCookies.Append()
is very allocation-heavy. Even just reusing theStringBuilder
created inSetCookieHeaderValue.ToString()
would be a significant improvement.For example, running a scenario that adds an Antiforgery token to every response (~156 characters in the token in this case) allocates almost 1 KB extra per response. That's more than 2% of the allocations in this scenario.
Data for 3000 requests:


The text was updated successfully, but these errors were encountered: