Convert Encoding.Utf8.GetBytes calls to static constants using UTF8 string literals#8487
Conversation
BenchmarksBenchmark execution time: 2026-04-27 09:08:45 Comparing candidate commit f3d2140 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 27 metrics, 0 unstable metrics, 57 known flaky benchmarks, 30 flaky benchmarks without significant changes.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b34d5dc6fb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
eca7df4 to
54730c9
Compare
cd7946c to
6e4930c
Compare
54730c9 to
3f06600
Compare
6e4930c to
5851cc5
Compare
3f06600 to
14245b2
Compare
5851cc5 to
931e25a
Compare
14245b2 to
fa83d95
Compare
931e25a to
c57dd03
Compare
fa83d95 to
787ab49
Compare
c57dd03 to
b895f2b
Compare
787ab49 to
40b0f3c
Compare
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8487) and master. ✅ No regressions detected - check the details below Full Metrics ComparisonFakeDbCommand
HttpMessageHandler
Comparison explanationExecution-time benchmarks measure the whole time it takes to execute a program, and are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are highlighted in **red**. The following thresholds were used for comparing the execution times:
Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard. Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph). Duration chartsFakeDbCommand (.NET Framework 4.8)gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8487) - mean (73ms) : 70, 76
master - mean (75ms) : 71, 79
section Bailout
This PR (8487) - mean (77ms) : 75, 80
master - mean (77ms) : 74, 81
section CallTarget+Inlining+NGEN
This PR (8487) - mean (1,086ms) : 1041, 1131
master - mean (1,087ms) : 1032, 1143
FakeDbCommand (.NET Core 3.1)gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8487) - mean (115ms) : 111, 119
master - mean (116ms) : 110, 121
section Bailout
This PR (8487) - mean (119ms) : 114, 125
master - mean (115ms) : 112, 118
section CallTarget+Inlining+NGEN
This PR (8487) - mean (783ms) : 754, 813
master - mean (780ms) : 748, 813
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8487) - mean (104ms) : 99, 110
master - mean (101ms) : 97, 105
section Bailout
This PR (8487) - mean (105ms) : 99, 111
master - mean (102ms) : 99, 106
section CallTarget+Inlining+NGEN
This PR (8487) - mean (942ms) : 903, 980
master - mean (939ms) : 900, 978
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8487) - mean (100ms) : 98, 103
master - mean (103ms) : 97, 110
section Bailout
This PR (8487) - mean (105ms) : 98, 112
master - mean (102ms) : 99, 104
section CallTarget+Inlining+NGEN
This PR (8487) - mean (825ms) : 778, 873
master - mean (829ms) : 782, 875
HttpMessageHandler (.NET Framework 4.8)gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8487) - mean (201ms) : 195, 208
master - mean (202ms) : 195, 209
section Bailout
This PR (8487) - mean (206ms) : 199, 214
master - mean (208ms) : 198, 218
section CallTarget+Inlining+NGEN
This PR (8487) - mean (1,194ms) : 1137, 1251
master - mean (1,198ms) : 1143, 1254
HttpMessageHandler (.NET Core 3.1)gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8487) - mean (290ms) : 280, 299
master - mean (291ms) : 280, 301
section Bailout
This PR (8487) - mean (290ms) : 279, 301
master - mean (291ms) : 282, 299
section CallTarget+Inlining+NGEN
This PR (8487) - mean (956ms) : 925, 988
master - mean (957ms) : 934, 980
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8487) - mean (286ms) : 272, 300
master - mean (283ms) : 271, 295
section Bailout
This PR (8487) - mean (288ms) : 274, 303
master - mean (284ms) : 274, 294
section CallTarget+Inlining+NGEN
This PR (8487) - mean (1,159ms) : 1118, 1200
master - mean (1,153ms) : 1109, 1197
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8487) - mean (287ms) : 273, 301
master - mean (283ms) : 271, 296
section Bailout
This PR (8487) - mean (289ms) : 271, 307
master - mean (285ms) : 273, 297
section CallTarget+Inlining+NGEN
This PR (8487) - mean (1,052ms) : 1000, 1105
master - mean (1,044ms) : 985, 1104
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
b895f2b to
f3d2140
Compare
Summary of changes
Convert
Encoding.Utf8.GetBytescalls to static constants using UTF8 string literalsReason for change
After moving our vendored
Span<T>implementation into theSystemnamespace, various optimizations open up to us, including using UTF-8 string literals, to encode strings to UTF-8 at compile time instead of at runtime. By combing withstatic ReadOnlySpan<byte>properties, these also become zero allocation, so we get reduced overall memory usage as well as better startup timeImplementation details
Replace the following with utf8 string literals:
StringEncoding.UTF8.GetBytesEncoding.UTF8.GetBytesEncodingHelpers.UTF8NoBom.GetBytesTest coverage
All covered by existing tests
Other details
Depends on a stack updating our vendored system code
ReadOnlySpan<T>,Span<T>et. al. to System namespace #8476Span<T>namespace changes #8477TagListGeneratorto always useReadOnlySpan<byte>properties #8486