Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eliminate most CharTable range checks
Motivation ---------- The index into the CharTable is completely safe when indexed via a byte, so we can eliminate it in hot paths safely. Also, we can use RVA statics with ushort on newer versions of C#. Modifications ------------- Use ref and Unsafe.Add to index into the char table in DecompressAllTags, and make CharTable an RVA static. Results ------- BenchmarkDotNet v0.13.10, Windows 11 (10.0.22621.2861/22H2/2022Update/SunValley2) 12th Gen Intel Core i7-1270P, 1 CPU, 16 logical and 12 physical cores .NET SDK 8.0.100 [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2 Job-IVITYO : .NET Framework 4.8.1 (4.8.9181.0), X64 RyuJIT VectorSize=256 Job-SVSNXE : .NET Framework 4.8.1 (4.8.9181.0), X64 RyuJIT VectorSize=256 Job-UZLHWZ : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2 Job-VTIJJN : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2 Job-BDCQZW : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2 Job-WMAPZR : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2 Job-KAZCEW : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2 Job-QKBVXP : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2 | Method | Runtime | BuildConfiguration | PGO | Mean | Error | StdDev | Ratio | Rank | |----------- |------------------- |------------------- |---- |---------:|---------:|---------:|------:|-----:| | Decompress | .NET Framework 4.8 | Previous | N | 14.61 us | 0.104 us | 0.092 us | 1.00 | 1 | | Decompress | .NET Framework 4.8 | Default | N | 14.68 us | 0.099 us | 0.093 us | 1.01 | 1 | | | | | | | | | | | | Decompress | .NET 6.0 | Previous | N | 12.90 us | 0.063 us | 0.049 us | 1.00 | 1 | | Decompress | .NET 6.0 | Default | N | 12.80 us | 0.114 us | 0.106 us | 0.99 | 1 | | | | | | | | | | | | Decompress | .NET 8.0 | Previous | N | 10.41 us | 0.089 us | 0.083 us | 1.00 | 1 | | Decompress | .NET 8.0 | Default | N | 10.29 us | 0.075 us | 0.070 us | 0.99 | 1 | | | | | | | | | | | | Decompress | .NET 8.0 | Previous | Y | 10.50 us | 0.108 us | 0.101 us | 1.00 | 2 | | Decompress | .NET 8.0 | Default | Y | 10.28 us | 0.085 us | 0.075 us | 0.98 | 1 |
- Loading branch information