Skip to content

Commit

Permalink
Removed inlining attribute due to huge performance hit
Browse files Browse the repository at this point in the history
  • Loading branch information
master131 committed Jun 28, 2017
1 parent 294c434 commit 429a82a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 21 deletions.
6 changes: 3 additions & 3 deletions BrotliSharpLib/BrotliSharpLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<NoWarn>1570;1701</NoWarn>
</PropertyGroup>
<PropertyGroup>
<Version>0.1.1</Version>
<FileVersion>0.1.1</FileVersion>
<Version>0.2</Version>
<FileVersion>0.2.0</FileVersion>
<Authors>master131</Authors>
<Description>Full C# port of Brotli compression library.</Description>
<Copyright>Copyright (c) 2017 master131</Copyright>
<RepositoryUrl>https://github.com/master131/BrotliSharpLib</RepositoryUrl>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<RepositoryType>git</RepositoryType>
<PackageTags>brotli;csharp;net</PackageTags>
<AssemblyVersion>0.1.1.0</AssemblyVersion>
<AssemblyVersion>0.2.0.0</AssemblyVersion>
<PackageLicenseUrl>https://github.com/master131/BrotliSharpLib/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/master131/BrotliSharpLib</PackageProjectUrl>
</PropertyGroup>
Expand Down
3 changes: 0 additions & 3 deletions BrotliSharpLib/Encode/BackwardReferencesHQ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ private static unsafe float ZopfliCostModelGetDistanceCost(
return self->cost_dist_[distcode];
}

#if AGGRESSIVE_INLINING
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
private static unsafe float ZopfliCostModelGetLiteralCosts(
ZopfliCostModel* self, size_t from, size_t to) {
return self->literal_costs_[to] - self->literal_costs_[from];
Expand Down
12 changes: 0 additions & 12 deletions BrotliSharpLib/Encode/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ internal struct Command {
public ushort dist_prefix_;
}

#if AGGRESSIVE_INLINING
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
private static ushort GetInsertLengthCode(size_t insertlen)
{
if (insertlen < 6)
Expand Down Expand Up @@ -69,9 +66,6 @@ private static ushort GetInsertLengthCode(size_t insertlen)
}
}

#if AGGRESSIVE_INLINING
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
private static unsafe ushort GetCopyLengthCode(size_t copylen)
{
if (copylen < 10)
Expand All @@ -93,9 +87,6 @@ private static unsafe ushort GetCopyLengthCode(size_t copylen)
}
}

#if AGGRESSIVE_INLINING
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
private static ushort CombineLengthCodes(
ushort inscode, ushort copycode, bool use_last_distance)
{
Expand Down Expand Up @@ -168,9 +159,6 @@ increase by BROTLI_NUM_DISTANCE_SHORT_CODES - 1 */
}
}

#if AGGRESSIVE_INLINING
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
private static unsafe uint CommandCopyLenCode(Command* self)
{
return (self->copy_len_ & 0xFFFFFF) ^ (self->copy_len_ >> 24);
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Performance can also be further improved by building BrotliSharpLib using .NET F

### Benchmark

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.
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.

``` ini
BenchmarkDotNet=v0.10.6, OS=Windows 10 Redstone 2 (10.0.15063)
Expand Down Expand Up @@ -128,7 +128,7 @@ File: UPX v3.91 (Windows Executable)
| Original C | 6 | 36.540 ms |
| BrotliSharpLib | 9 | 116.318 ms |
| Original C | 9 | 73.080 ms |
| BrotliSharpLib | 11 | 4,476.191 ms |
| BrotliSharpLib | 11 | 2201.000 ms |
| Original C | 11 | 877.58 ms |

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.
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 comments on commit 429a82a

Please sign in to comment.