Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Faster Headers.ClearFast#497

Merged
halter73 merged 1 commit intoaspnet:devfrom
benaadams:headers.clearfast
Dec 16, 2015
Merged

Faster Headers.ClearFast#497
halter73 merged 1 commit intoaspnet:devfrom
benaadams:headers.clearfast

Conversation

@benaadams
Copy link
Contributor

10% improvement in RPS

Issue (2 ClearFast lines)
cpu-trace

Before

Running 30s test @ http://..../plaintext
32 threads and 1024 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 9.46ms 18.88ms 428.30ms 96.09%
Req/Sec 46.14k 9.03k 194.88k 92.81%
44125265 requests in 30.10s, 5.42GB read
Socket errors: connect 35, read 0, write 0, timeout 0
Requests/sec: 1465986.87
Transfer/sec: 184.55MB

After

Running 30s test @ http://.../plaintext
32 threads and 1024 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 9.76ms 20.82ms 366.01ms 95.03%
Req/Sec 52.65k 5.22k 116.78k 90.51%
48788229 requests in 30.10s, 6.00GB read
Socket errors: connect 35, read 0, write 0, timeout 0
Requests/sec: 1620849.91
Transfer/sec: 204.04MB

Resolves #492

Copy link
Member

Choose a reason for hiding this comment

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

The _raw fields are only read by CopyToFast which already has if ({header.TestBit()}), so no other changes needed here.

@halter73 halter73 merged commit 559cd51 into aspnet:dev Dec 16, 2015
@halter73
Copy link
Member

Sweet!

@lodejard
Copy link
Contributor

Hmm... If the headers aren't zeroed out after a request, and the application is responding with computed strings, couldn't this result in more computed string entering the gen1/gen2 heaps?

I mean, yes better for raw RPS, but worse for normal application loads?

@benaadams
Copy link
Contributor Author

result in more computed string entering the gen1/gen2 heaps?

Assuming the setters are clearing the references (either by setting a full StringValue set, or by setting the non-set components to null/empty) then it would only be rarely set headers that would be promoted, as the other ones would be cleared in the next request set - its just avoiding both a double clear (clear+set); and a clear of items that were never set in the first place.

Not sure about the implications pre-encoded change though; haven't looked too closely.

@lodejard
Copy link
Contributor

I'm not so sure that's a rare case - typically browsers will keep a couple connections open at a time, and you requests to arrive in small bursts with longish delays between. If reset doesn't zero the memory then all of the strings from the previous response will still be referenced by the header object during those long delays. So if you have a thousand browsers in the world with your web page open, and the GC kicks off, all of the strings from the most recent response for the thousand connections will move into the next generation.

Pre-encoded and string literals are no problem though - those should be treated like static readonly constants once they are created, and should move into the gen2 heap and stay there forever.

@benaadams
Copy link
Contributor Author

Solution for that might be to pool the header collections between connections so they aren't active in the keep-alive wait state?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants