Skip to content

Conversation

@pcf0
Copy link
Contributor

@pcf0 pcf0 commented Feb 20, 2025

With the last update of SoapCore 1.2.0 some dependencies were added that are not really necessary and were removed in previous versions (e.g. System.Drawing.Common).

  • I have reduced the dependencies to the essentials and updated them.
  • I have also replaced the dependency on Newtonsoft.Json with System.Text.Json.
  • The tests failed for me due to the localization, because the tests are dependent on the text. I have therefore set the CurrentUICulture for the relevant tests.
  • In the readme it was listed that .NET 5.0 to 7.0 is supported, which is currently only the case with netstandard2.1. I have therefore updated this to .NET 8.0.

@akshaybheda
Copy link
Contributor

Did you do a perf check after switching? any benefits there?

@pcf0
Copy link
Contributor Author

pcf0 commented Feb 21, 2025

No, I didn't.
I have now tried running the benchmark before and after, but unfortunately the benchmark only works with my change.
And I also cannot run the obsolete .NET Core 3.1 on my local machine.
I therefore had to upgrade at least BenchmarkDotNet.
But as far as I can see there is no change in performance, you just have fewer (direct and transitive) dependencies.

Before, but with upgraded BenchmarkDotNet:

// * Summary *

BenchmarkDotNet v0.14.0, Windows 10 (10.0.19045.5487/22H2/2022Update)
AMD Ryzen 7 2700X, 1 CPU, 16 logical and 8 physical cores
.NET SDK 9.0.200
  [Host]     : .NET 8.0.13 (8.0.1325.6609), X64 RyuJIT AVX2
  Job-YYRKVG : .NET 8.0.13 (8.0.1325.6609), X64 RyuJIT AVX2

IterationCount=5

| Method    | LoopNum | Mean      | Error     | StdDev    | Gen0      | Gen1     | Allocated |
|---------- |-------- |----------:|----------:|----------:|----------:|---------:|----------:|
| EmptyTask | 100     |  1.742 ms | 0.1749 ms | 0.0454 ms |  263.6719 |        - |   1.05 MB |
| Echo      | 100     | 12.355 ms | 0.7980 ms | 0.2072 ms | 1656.2500 | 125.0000 |   6.65 MB |

After my change:

// * Summary *

BenchmarkDotNet v0.14.0, Windows 10 (10.0.19045.5487/22H2/2022Update)
AMD Ryzen 7 2700X, 1 CPU, 16 logical and 8 physical cores
.NET SDK 9.0.200
  [Host]     : .NET 8.0.13 (8.0.1325.6609), X64 RyuJIT AVX2
  Job-QCSOYQ : .NET 8.0.13 (8.0.1325.6609), X64 RyuJIT AVX2

IterationCount=5

| Method    | LoopNum | Mean      | Error     | StdDev    | Gen0      | Gen1     | Allocated |
|---------- |-------- |----------:|----------:|----------:|----------:|---------:|----------:|
| EmptyTask | 100     |  2.041 ms | 0.4771 ms | 0.1239 ms |  261.7188 |        - |   1.05 MB |
| Echo      | 100     | 12.121 ms | 0.5309 ms | 0.1379 ms | 1656.2500 | 125.0000 |   6.65 MB |

The error before upgrade:

Unhandled exception. System.MissingMethodException: .ctor
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctorWithParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)
   at BenchmarkDotNet.Extensions.ReflectionExtensions.ResolveAttribute[T](MemberInfo memberInfo)
   at BenchmarkDotNet.Running.BenchmarkConverter.<>c.<GetOrderedBenchmarkMethods>b__3_0(MethodInfo method)
   at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.ToArray()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.OrderedEnumerable`1.GetEnumerator()+MoveNext()
   at System.Linq.Enumerable.SelectIPartitionIterator`2.LazyToArray()
   at System.Linq.Enumerable.SelectIPartitionIterator`2.ToArray()
   at BenchmarkDotNet.Running.BenchmarkConverter.GetOrderedBenchmarkMethods(MethodInfo[] methods)
   at BenchmarkDotNet.Running.BenchmarkConverter.TypeToBenchmarks(Type type, IConfig config)
   at BenchmarkDotNet.Running.BenchmarkRunner.RunWithDirtyAssemblyResolveHelper(Type type, IConfig config, String[] args)
   at BenchmarkDotNet.Running.BenchmarkRunner.<>c__DisplayClass0_0`1.<Run>b__0()
   at BenchmarkDotNet.Running.BenchmarkRunner.RunWithExceptionHandling(Func`1 run)
   at BenchmarkDotNet.Running.BenchmarkRunner.Run[T](IConfig config, String[] args)
   at SoapCore.Benchmark.Program.Main() in \SoapCore.Benchmark\Program.cs:line 84

@andersjonsson
Copy link
Collaborator

Thanks!

@andersjonsson andersjonsson merged commit b2b9896 into DigDes:develop Feb 24, 2025
3 checks passed
@pcf0 pcf0 deleted the reduce-dependencies branch February 24, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants