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

System.Memory #94

Merged
merged 22 commits into from
Sep 18, 2018
Merged

System.Memory #94

merged 22 commits into from
Sep 18, 2018

Conversation

adamsitnik
Copy link
Member

@adamsitnik adamsitnik commented Jul 20, 2018

No description provided.

@adamsitnik
Copy link
Member Author

Why is this manually unrolled? Can we use a loop instead?

It's due to the nature of Span - it's stack only, so I can't store it in the field of a class. So I need to create it as part of every benchmark. It's not a problem when it comes to time consuming benchmarks like span.CopyTo or span.Fill but span.Slice is super fast and if I write benchmark like this:

[Benchmark]
public Span<T> Slice() => new Span<T>(_arrayField).Slice(0, 1)

the Span constructor will be a huge part of the benchmark itself (up to 50%)

this is why I called the ctor once and used OperationsPerInvoke to amortize the cost of span creation. (the result is (1x span ctor + 16x slice) / 16) not 1x span ctor + 1x slice

Can we use a loop instead?

No, because the loop would be an overhead for this particular nano-benchmark

@adamsitnik
Copy link
Member Author

result is a local variable and loop independent. Does the loop get optimized?

No, our compiler is not there yet.

@adamsitnik adamsitnik changed the title [WIP] Memory System.Memory Aug 1, 2018
@adamsitnik
Copy link
Member Author

ok, I have covered entire Span, ReadOnlySpan, Memory, ReadOnlyMemory and MemoryMarshaller API with some good benchmarks. I believe the PR is ready for final review

@adamsitnik adamsitnik requested a review from jorive August 29, 2018 08:27
@adamsitnik
Copy link
Member Author

@jorive this is the last one ;D

@jorive
Copy link
Member

jorive commented Sep 18, 2018

        return result;;

nit: ;;


Refers to: src/benchmarks/corefx/System.Collections/Iterate/IterateFor.cs:75 in 68587cd. [](commit_id = 68587cd, deletion_comment = False)

Copy link
Member

@jorive jorive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@adamsitnik adamsitnik merged commit 4b34c30 into dotnet:master Sep 18, 2018
@adamsitnik
Copy link
Member Author

the port is complete now!

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.

2 participants