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

Go full Async #1

Merged
merged 3 commits into from
Apr 16, 2018
Merged

Go full Async #1

merged 3 commits into from
Apr 16, 2018

Conversation

benaadams
Copy link
Contributor

@benaadams benaadams commented Apr 15, 2018

Is currently blocking in some of the paths; making it fully async gives no significant drop off and the FileStream can then also be async.

AsyncFileWriterTester>dotnet run -c Release
100,000 bounded capacity.
Total Time: 1.9647976 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:02.3469906
------------------------

10,000 bounded capacity.
Total Time: 1.7327357 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:01.8846596
------------------------

1,000 bounded capacity.
Total Time: 1.7522801 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:02.2072572
------------------------

100 bounded capacity.
Total Time: 1.7023758 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:01.9285510
------------------------

Press ENTER to continue.

@benaadams
Copy link
Contributor Author

And on Core 2.1 preview

AsyncFileWriterTester>dotnet run -c Release
100,000 bounded capacity.
Total Time: 1.8987974 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:01.7353395
------------------------

10,000 bounded capacity.
Total Time: 1.6465742 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:01.4772885
------------------------

1,000 bounded capacity.
Total Time: 1.6717849 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:01.6662691
------------------------

100 bounded capacity.
Total Time: 1.7220855 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:01.8154073
------------------------

Press ENTER to continue.

@electricessence
Copy link
Owner

electricessence commented Apr 15, 2018

https://www.reddit.com/r/dotnet/comments/8c4ova/ado_async_all_the_way_down_the_tubes/dxf80rw/?st=jg1dbwdr&sh=75405bf7

I'm reviewing the code now. Thanks for your submission.
Be sure to look at the test file to see that 1,000,000 rows have been written.

@benaadams
Copy link
Contributor Author

I can rebase? There should hopefully be no slow down from the full async in this PR?

@benaadams
Copy link
Contributor Author

Rebasing has hit the performance; looking it it

@benaadams
Copy link
Contributor Author

There's something definitely wrong with FileStream in async mode...

Anyway, current - everything async other than FileStream

AsyncFileWriterTester>dotnet run -c Release
100,000 bounded capacity.
Total Time: 2.3680831 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:02.6254878
------------------------

10,000 bounded capacity.
Total Time: 2.0399536 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:02.3390593
------------------------

1,000 bounded capacity.
Total Time: 2.1499109 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:02.3699012
------------------------

100 bounded capacity.
Total Time: 2.0656293 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:03.0224013
------------------------

Press ENTER to continue.

Switch FileStream to async

AsyncFileWriterTester>dotnet run -c Release
100,000 bounded capacity.
Total Time: 4.1238278 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:14.3291113
------------------------

10,000 bounded capacity.
Total Time: 4.370184 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:19.3693952
------------------------

1,000 bounded capacity.
Total Time: 4.1362524 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:19.0104628
------------------------

100 bounded capacity.
Total Time: 4.2608508 seconds
Total Bytes: 115,888,890
Total Wait Time: 00:00:20.4615956
------------------------

Press ENTER to continue.

@benaadams
Copy link
Contributor Author

@electricessence
Copy link
Owner

Let's do some more investigation first. @benaadams your async tests aren't exactly at parity with the synchronous ones.

@electricessence
Copy link
Owner

There's a stack overflow I've seen before about FileStream async. I'd search for that. There may not be anything wrong.

@electricessence electricessence merged commit 1e28a1c into electricessence:master Apr 16, 2018
@electricessence
Copy link
Owner

After my refactor, here's the results I'm getting.
I strongly suggest trying to reimplement your ParallelAsync tests in AsyncTester.cs.

Synchronous tests have to remain as a benchmark.

TESTS WITH PARTIAL BLOCKING:

Synchronized file stream benchmark.
Total Time: 2.5686957 seconds
Total Bytes: 115,888,890
Aggregate Waiting: 00:00:08.0020843
------------------------

100,000 bounded capacity.
Total Time: 1.8137859 seconds
Total Bytes: 115,888,890
Aggregate Waiting: 00:00:03.1323739
------------------------

10,000 bounded capacity.
Total Time: 1.7435298 seconds
Total Bytes: 115,888,890
Aggregate Waiting: 00:00:02.6384457
------------------------

1,000 bounded capacity.
Total Time: 2.4563794 seconds
Total Bytes: 115,888,890
Aggregate Waiting: 00:00:08.4284548
------------------------

100 bounded capacity.
Total Time: 38.1694338 seconds
Total Bytes: 115,888,890
Aggregate Waiting: 00:38:06.0996803
------------------------


FULLY ASYNCHRONOUS:

100,000 bounded capacity.
Total Time: 8.3645859 seconds
Total Bytes: 115,888,890
Aggregate Waiting: 00:16:05.7421462
------------------------

10,000 bounded capacity.
Total Time: 19.7808654 seconds
Total Bytes: 115,888,890
Aggregate Waiting: 00:58:04.0314021
------------------------

1,000 bounded capacity.
Total Time: 29.7159541 seconds
Total Bytes: 115,888,890
Aggregate Waiting: 02:21:54.4839711
------------------------

100 bounded capacity.
Total Time: 121.6788821 seconds
Total Bytes: 115,888,890
Aggregate Waiting: 14:09:48.1087417
------------------------

@electricessence
Copy link
Owner

electricessence commented Apr 16, 2018

https://github.com/electricessence/AsyncFileWriter/blob/master/AsyncFileWriterTester/AsyncTester.cs#L61
I added an assertion to ensure the file bytes match. If you don't see a significant slow down in time using 100 bounded capacity, your test is probably not actually finishing.

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