Commit da234b9
authored
Improve performance of output cache (dotnet#48328)
* optimize Output Cache; no API changes yet - all internal:
- unify OutputCacheEntry and FormatterEntry
- leased buffers for headers, tags, etc (dispose on way out)
- use ReadOnlySequence<byte> instead of List<byte[]> with recyclable segments
- avoid copying the payload data once fectched
- serialization tweak: use common headers (not yet listed)
finish porting tests; all good
migrate writes to IBufferWriter<byte>, using recyclable array buffer writer (similar to MemoryStream, but: faster)
use pooled buffers when buffering output-cache payloads RROSS should be able to recycle buffers as needed
implement header name/value lookup buffer
add bench project
note memory overhead in bench
full bench suite
add benchmark result
- don't store tags in the cache payload
- don't store segment details in the cache payload
whitespace
include test that uses body-writer rather than stream
tidy up benchmarks
remove pipe impl; we don't need it (proven in bench)
add a few more known headers; don't store request-id
don't write empty segments
fix buffer cleanup paths
revert changes to shared SegmentWriteStream
update numbers
use fixed size stackalloc
Update src/Middleware/OutputCaching/src/OutputCacheEntryFormatter.cs
Co-authored-by: Günther Foidl <gue@korporal.at>
- remove global SkipLocalsInit
- add accessibility on all new members
- in length checks, use - over + to avoid overflow
nits
relocate perf to microbenchmarks
use standard project structure for micro-benchmarks
use "actual" instead of "bytes" to avoid a "pop"/"ld" in the "release" case
avoid a memcopy by writing directly to the buffer bytes (and increasing DRY)
Update src/Middleware/OutputCaching/src/OutputCacheEntry.cs
Co-authored-by: Brennan <brecon@microsoft.com>
Update src/Middleware/OutputCaching/test/OutputCacheEntryFormatterTests.cs
Co-authored-by: Brennan <brecon@microsoft.com>
fix PR nits from dotnet#48450
fix sln (dead project)
Update src/Middleware/OutputCaching/src/OutputCacheEntry.cs
Co-authored-by: Brennan <brecon@microsoft.com>
DRY nit
moar nits
use leased buffer for tags when calling SetAsync
Update src/Middleware/OutputCaching/src/OutputCacheEntryFormatter.cs
Co-authored-by: Brennan <brecon@microsoft.com>
use [LoggerMessage] for logging
merge submodule delete
bump
optimize Output Cache; no API changes yet - all internal:
- unify OutputCacheEntry and FormatterEntry
- leased buffers for headers, tags, etc (dispose on way out)
- use ReadOnlySequence<byte> instead of List<byte[]> with recyclable segments
- avoid copying the payload data once fectched
- serialization tweak: use common headers (not yet listed)
sln fix
dammit
* use `_field` naming in `FormatterBinaryReader.cs`
* move log methods to dedicated file
* simplify cached response cleanup
* add comment re buffer size1 parent c6cc85c commit da234b9
29 files changed
Lines changed: 1997 additions & 480 deletions
File tree
- src
- Caching/StackExchangeRedis/src
- Middleware/OutputCaching
- perf/Microbenchmarks
- src
- Serialization
- Streams
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1772 | 1772 | | |
1773 | 1773 | | |
1774 | 1774 | | |
| 1775 | + | |
| 1776 | + | |
1775 | 1777 | | |
1776 | 1778 | | |
1777 | 1779 | | |
| |||
10645 | 10647 | | |
10646 | 10648 | | |
10647 | 10649 | | |
| 10650 | + | |
| 10651 | + | |
| 10652 | + | |
| 10653 | + | |
| 10654 | + | |
| 10655 | + | |
| 10656 | + | |
| 10657 | + | |
| 10658 | + | |
| 10659 | + | |
| 10660 | + | |
| 10661 | + | |
| 10662 | + | |
| 10663 | + | |
| 10664 | + | |
| 10665 | + | |
10648 | 10666 | | |
10649 | 10667 | | |
10650 | 10668 | | |
| |||
11520 | 11538 | | |
11521 | 11539 | | |
11522 | 11540 | | |
| 11541 | + | |
11523 | 11542 | | |
11524 | 11543 | | |
11525 | 11544 | | |
| |||
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| 29 | + | |
26 | 30 | | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
30 | | - | |
31 | 35 | | |
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments