Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Faster byte[] copy #511

Closed
wants to merge 1 commit into from
Closed

Faster byte[] copy #511

wants to merge 1 commit into from

Conversation

benaadams
Copy link
Contributor

This makes me sad that this is even possible to do (+4% RPS)...

Issue: "Array.Copy & Buffer.BlockCopy x2 to x3 slower < 1kB" https://github.com/dotnet/coreclr/issues/2430

Performance Graph

Until that is fixed, there is this, +4% RPS

Before

Running 30s test @ http://.../plaintext
32 threads and 1024 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 7.31ms 17.04ms 430.36ms 96.48%
Req/Sec 63.61k 11.37k 121.07k 89.55%
60603911 requests in 30.04s, 7.45GB read
Socket errors: connect 35, read 0, write 0, timeout 0
Requests/sec: 2017281.16
Transfer/sec: 253.95MB

Running 30s test @ http://.../plaintext
32 threads and 1024 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 7.86ms 18.76ms 319.53ms 96.10%
Req/Sec 65.93k 7.22k 233.05k 91.79%
61092441 requests in 30.10s, 7.51GB read
Socket errors: connect 35, read 0, write 0, timeout 0
Requests/sec: 2029658.31
Transfer/sec: 255.50MB

Running 30s test @ http://.../plaintext
32 threads and 1024 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 7.76ms 18.81ms 338.18ms 96.30%
Req/Sec 65.90k 6.02k 141.64k 88.76%
61119465 requests in 30.10s, 7.51GB read
Socket errors: connect 35, read 0, write 0, timeout 0
Requests/sec: 2030569.81
Transfer/sec: 255.62MB

After

Running 30s test @ http://.../plaintext
32 threads and 1024 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 6.54ms 16.04ms 421.70ms 97.95%
Req/Sec 66.30k 13.82k 277.14k 91.29%
63126220 requests in 30.10s, 7.76GB read
Socket errors: connect 35, read 0, write 0, timeout 0
Requests/sec: 2097240.79
Transfer/sec: 264.01MB

Running 30s test @ http://.../plaintext
32 threads and 1024 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 6.39ms 15.65ms 315.77ms 98.11%
Req/Sec 68.62k 7.74k 234.24k 87.15%
63593990 requests in 30.10s, 7.82GB read
Socket errors: connect 35, read 0, write 0, timeout 8
Requests/sec: 2112790.91
Transfer/sec: 265.97MB

Running 30s test @ http://.../plaintext
32 threads and 1024 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 6.25ms 15.05ms 332.33ms 98.25%
Req/Sec 66.43k 13.67k 283.71k 92.85%
63515232 requests in 30.10s, 7.81GB read
Socket errors: connect 35, read 0, write 0, timeout 0
Requests/sec: 2110181.96
Transfer/sec: 265.64MB

@@ -5,6 +5,7 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using IllyriadGames.ByteArrayExtensions;
Copy link
Member

Choose a reason for hiding this comment

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

??? 😀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

VectorizedCopy is in a standalone lib as it has a wide applicable use in many different situations; adding a reference seemed easier than including the source here, or Common and trying to workout what do with the file headers (here and in the standalone lib). Happy to take advice 😀

Hopefully the clr will change so it isn't needed; and everything can get the benefit, but equally that might either be a change to memmove in the C Standard Lib; or will be coreclr only for stability, so I'm not holding my breath on timelines 😦

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added reference as specific version number; so the code referenced is under nuget's control not mine 😉

Though would probably be "safer" to use the source; but... dotnet/corefx#3199 (diff) don't know what the situation is.

Copy link
Member

Choose a reason for hiding this comment

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

But you know we're not going to have a dependency on "IllyriadGames.ByteArrayExtensions": "1.0.0-beta-10" in our web server right? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doubt it 😄

What about a source file with a different copyright notice; but using same licence (Apache License, Version 2.0)? Not sure you'd be comfortable with the precedent either... Everyone would want a header! 😝

But only adding the Copyright (c) .NET Foundation. header would mean I'd be in the perverse situation of sub-licensing VectorizedCopy and would need to retain the header if I was to use it under Apache 2.0? (as I understand it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Want to drop net451 and move to only supporting net46? I've just been made aware of Buffer.MemoryCopy which should offer better performance... (Doesn't appear till 4.6 and coreclr)

Could ifdef it I suppose...

Copy link
Contributor

Choose a reason for hiding this comment

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

net46 will likely break Mono. Not necessarily the most recent released version or master, but quite likely the one release that comes most closely to working: 4.0.x.

Copy link
Member

Choose a reason for hiding this comment

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

We're going to be moving to .NET 4.6 for RC2. We'll need to see how much of mono breaks when we do that. Hopefully 4.2.x will have enough 4.6 support to run.

Copy link
Contributor

Choose a reason for hiding this comment

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

(sorry for continuing here)
Switching to .NET 4.6 will break current Mono users. The switch to the .NET 4.6 reference source only happened back in October, so all versions of Mono (including the most recent 4.2 and the mostly-working 4.0) don't have the Array.Empty member. Things will go back the way they were in beta2: aspnet/dnx#1105

Copy link
Member

Choose a reason for hiding this comment

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

Yep, this is known. I'm working with the mono guys to figure out which version of mono will support .NET 4.6 reference assemblies. Hopefully by the time RC2 is ready we'll have a version of mono that supports that.

@benaadams benaadams closed this Dec 21, 2015
@benaadams
Copy link
Contributor Author

Closed as still investigating

@Anderman
Copy link
Contributor

Anderman commented Jan 6, 2016

@benaadams Any updates on this. I think it is still possible to make it faster than Buffer.MemoryCopy. I can make a PR for this but that would be without using IllyriadGames.ByteArrayExtensions (-;

@benaadams
Copy link
Contributor Author

Holding off till post v1.0.0 RTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants