Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regressions in System.Numerics.Tests.Perf_BigInteger #60293

Closed
Tracked by #47244
performanceautofiler bot opened this issue Oct 12, 2021 · 9 comments
Closed
Tracked by #47244

Regressions in System.Numerics.Tests.Perf_BigInteger #60293

performanceautofiler bot opened this issue Oct 12, 2021 · 9 comments

Comments

@performanceautofiler
Copy link

Run Information

Architecture x64
OS Windows 10.0.19042
Baseline 6c09f34947026ed988fd3013fdaa624a5fab0f26
Compare 9dcde5f8a182a9202a50afa92fec463f6654ecd9
Diff Diff

Regressions in System.Numerics.Tests.Perf_BigInteger

Benchmark Baseline Test Test/Base Test Quality Edge Detector Baseline IR Compare IR IR Ratio Baseline ETL Compare ETL
Subtract - Duration of single invocation 49.13 ns 72.31 ns 1.47 0.07 True

graph
Test Report

Repro

git clone https://github.com/dotnet/performance.git
py .\performance\scripts\benchmarks_ci.py -f net6.0 --filter 'System.Numerics.Tests.Perf_BigInteger*'

Payloads

Baseline
Compare

Histogram

System.Numerics.Tests.Perf_BigInteger.Subtract(arguments: 1024,1024 bits)


Docs

Profiling workflow for dotnet/runtime repository
Benchmarking workflow for dotnet/runtime repository

@EgorBo EgorBo changed the title [Perf] Changes at 10/11/2021 9:01:10 AM Regressions in System.Numerics.Tests.Perf_BigInteger Oct 12, 2021
@EgorBo EgorBo transferred this issue from dotnet/perf-autofiling-issues Oct 12, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Numerics untriaged New issue has not been triaged by the area owner labels Oct 12, 2021
@ghost
Copy link

ghost commented Oct 12, 2021

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

Issue Details

Run Information

Architecture x64
OS Windows 10.0.19042
Baseline 6c09f34947026ed988fd3013fdaa624a5fab0f26
Compare 9dcde5f8a182a9202a50afa92fec463f6654ecd9
Diff Diff

Regressions in System.Numerics.Tests.Perf_BigInteger

Benchmark Baseline Test Test/Base Test Quality Edge Detector Baseline IR Compare IR IR Ratio Baseline ETL Compare ETL
Subtract - Duration of single invocation 49.13 ns 72.31 ns 1.47 0.07 True

graph
Test Report

Repro

git clone https://github.com/dotnet/performance.git
py .\performance\scripts\benchmarks_ci.py -f net6.0 --filter 'System.Numerics.Tests.Perf_BigInteger*'

Payloads

Baseline
Compare

Histogram

System.Numerics.Tests.Perf_BigInteger.Subtract(arguments: 1024,1024 bits)


Docs

Profiling workflow for dotnet/runtime repository
Benchmarking workflow for dotnet/runtime repository

Author: performanceautofiler[bot]
Assignees: -
Labels:

area-System.Numerics, untriaged

Milestone: -

@EgorBo
Copy link
Member

EgorBo commented Oct 12, 2021

Likely regressed by #35565 (cc @sakno)

@sakno
Copy link
Contributor

sakno commented Oct 12, 2021

Correct, the regression caused by PR. Situation was previously highlighted/predicted during the discussion with reviewers. Probably, the root cause is a ArrayPool<T>.Rent behavior which is slower than array allocation using new operator.

/cc @GrabYourPitchforks

@jeffhandley jeffhandley added this to the 7.0.0 milestone Oct 12, 2021
@jeffhandley jeffhandley removed the untriaged New issue has not been triaged by the area owner label Oct 12, 2021
@jeffhandley
Copy link
Member

We might end up deciding that this is an acceptable trade-off from the changes made, as several other scenarios were improved in exchange. We'll leave the issue open for the time-being though and if time-permits, we'll consider an investigation into the ArrayPool<T>.Rent cost incurred.

@kunalspathak
Copy link
Member

arm64 regression: dotnet/perf-autofiling-issues#1816

@adamsitnik
Copy link
Member

The benchmark has regressed also for other arguments:

image

@jeffhandley
Copy link
Member

@sakno and @kunalspathak -- do we need to investigate this any further, or are we OK closing this as expected?

@sakno
Copy link
Contributor

sakno commented Mar 30, 2022

@jeffhandley , regression is expected for all operands which are greater than 512 bits (64 bytes) in size. The current stackalloc threshold is 64 bytes. Large operands require memory pooling using ArrayPool<byte>.Shared. Note that any changes in TlsOverPerCoreLockedStacksArrayPool class have impact on BigInteger performance. Currently, TlsOverPerCoreLockedStacksArrayPool.Rent + Span<byte>.Clear are slower than new byte[size].

As for me, this is acceptable. However, we can consider NativeMemory.Alloc method (which is equivalent to malloc in C) as alternative. Anyway, we have strong control over buffer lifetime inside of BigInteger methods. But this suggestion requires confirmation and discussion.

@jeffhandley
Copy link
Member

Thanks, @sakno. Closing as expected/accepted.

@ghost ghost locked as resolved and limited conversation to collaborators May 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants