Skip to content

Commit 429a82a

Browse files
committed
Removed inlining attribute due to huge performance hit
1 parent 294c434 commit 429a82a

File tree

4 files changed

+6
-21
lines changed

4 files changed

+6
-21
lines changed

BrotliSharpLib/BrotliSharpLib.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
<NoWarn>1570;1701</NoWarn>
77
</PropertyGroup>
88
<PropertyGroup>
9-
<Version>0.1.1</Version>
10-
<FileVersion>0.1.1</FileVersion>
9+
<Version>0.2</Version>
10+
<FileVersion>0.2.0</FileVersion>
1111
<Authors>master131</Authors>
1212
<Description>Full C# port of Brotli compression library.</Description>
1313
<Copyright>Copyright (c) 2017 master131</Copyright>
1414
<RepositoryUrl>https://github.com/master131/BrotliSharpLib</RepositoryUrl>
1515
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
1616
<RepositoryType>git</RepositoryType>
1717
<PackageTags>brotli;csharp;net</PackageTags>
18-
<AssemblyVersion>0.1.1.0</AssemblyVersion>
18+
<AssemblyVersion>0.2.0.0</AssemblyVersion>
1919
<PackageLicenseUrl>https://github.com/master131/BrotliSharpLib/blob/master/LICENSE</PackageLicenseUrl>
2020
<PackageProjectUrl>https://github.com/master131/BrotliSharpLib</PackageProjectUrl>
2121
</PropertyGroup>

BrotliSharpLib/Encode/BackwardReferencesHQ.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ private static unsafe float ZopfliCostModelGetDistanceCost(
171171
return self->cost_dist_[distcode];
172172
}
173173

174-
#if AGGRESSIVE_INLINING
175-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
176-
#endif
177174
private static unsafe float ZopfliCostModelGetLiteralCosts(
178175
ZopfliCostModel* self, size_t from, size_t to) {
179176
return self->literal_costs_[to] - self->literal_costs_[from];

BrotliSharpLib/Encode/Command.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ internal struct Command {
3737
public ushort dist_prefix_;
3838
}
3939

40-
#if AGGRESSIVE_INLINING
41-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
42-
#endif
4340
private static ushort GetInsertLengthCode(size_t insertlen)
4441
{
4542
if (insertlen < 6)
@@ -69,9 +66,6 @@ private static ushort GetInsertLengthCode(size_t insertlen)
6966
}
7067
}
7168

72-
#if AGGRESSIVE_INLINING
73-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
74-
#endif
7569
private static unsafe ushort GetCopyLengthCode(size_t copylen)
7670
{
7771
if (copylen < 10)
@@ -93,9 +87,6 @@ private static unsafe ushort GetCopyLengthCode(size_t copylen)
9387
}
9488
}
9589

96-
#if AGGRESSIVE_INLINING
97-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
98-
#endif
9990
private static ushort CombineLengthCodes(
10091
ushort inscode, ushort copycode, bool use_last_distance)
10192
{
@@ -168,9 +159,6 @@ increase by BROTLI_NUM_DISTANCE_SHORT_CODES - 1 */
168159
}
169160
}
170161

171-
#if AGGRESSIVE_INLINING
172-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
173-
#endif
174162
private static unsafe uint CommandCopyLenCode(Command* self)
175163
{
176164
return (self->copy_len_ & 0xFFFFFF) ^ (self->copy_len_ >> 24);

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Performance can also be further improved by building BrotliSharpLib using .NET F
9696

9797
### Benchmark
9898

99-
The following are benchmark results using [DotNetBenchmark](https://github.com/dotnet/BenchmarkDotNet) with BrotliSharpLib (v0.1.1) and [Google's C# implementation](https://github.com/google/brotli/tree/master/csharp/org/brotli/dec) built against .NET Framework 4.6.1. The original C version was compiled in Release mode using Visual Studio 2017 (v141) as a 64-bit Windows executable.
99+
The following are benchmark results using [DotNetBenchmark](https://github.com/dotnet/BenchmarkDotNet) with BrotliSharpLib (v0.2) and [Google's C# implementation](https://github.com/google/brotli/tree/master/csharp/org/brotli/dec) built against .NET Framework 4.6.1. The original C version was compiled in Release mode using Visual Studio 2017 (v141) as a 64-bit Windows executable.
100100

101101
``` ini
102102
BenchmarkDotNet=v0.10.6, OS=Windows 10 Redstone 2 (10.0.15063)
@@ -128,7 +128,7 @@ File: UPX v3.91 (Windows Executable)
128128
| Original C | 6 | 36.540 ms |
129129
| BrotliSharpLib | 9 | 116.318 ms |
130130
| Original C | 9 | 73.080 ms |
131-
| BrotliSharpLib | 11 | 4,476.191 ms |
131+
| BrotliSharpLib | 11 | 2201.000 ms |
132132
| Original C | 11 | 877.58 ms |
133133

134-
While BrotliSharpLib performs comparatively at lower quality levels, it performs up to five times worse at level 11. Future versions of the port will hopefully bring this down.
134+
While BrotliSharpLib performs comparatively at lower quality levels, it performs up to three times worse at level 11. Future versions of the port will hopefully bring this down.

0 commit comments

Comments
 (0)