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

Adds parallelAsync builder #7

Merged
merged 2 commits into from
Mar 23, 2022
Merged

Adds parallelAsync builder #7

merged 2 commits into from
Mar 23, 2022

Conversation

TheAngryByrd
Copy link
Owner

@TheAngryByrd TheAngryByrd commented Mar 23, 2022

Proposed Changes

Closes #6

Types of changes

What types of changes does your code introduce to IcedTasks?
Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • Build and tests pass locally
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Further comments

I implemented both Async.StartChild and Async.StartImmediateAsTask as described by The BDFN Himself to get a better idea of performance differences between them. I did 3 types of tests:

  • NonAsyncBinds - These will return synchronously and not yield
  • AsyncBinds - These will return asynchronously and yield
  • AsyncBindsLong Same as AsyncBinds but shows that parallel and! can be beneficial on slower computations.

Additionally I added an applicative_overhead to compare 10 let! vs 10 let! ...and!... and! ... to see what the overhead is.

|                                                   Method |     Categories |          Mean |       Error |      StdDev |        Median |     Gen 0 |    Gen 1 |    Gen 2 | Allocated |
|--------------------------------------------------------- |--------------- |--------------:|------------:|------------:|--------------:|----------:|---------:|---------:|----------:|
|                                        AsyncBuilder_sync |  NonAsyncBinds |      8.249 ms |   0.1610 ms |   0.2410 ms |      8.248 ms |  296.8750 |        - |        - |  2,484 KB |
|                   AsyncBuilder_sync_applicative_overhead |  NonAsyncBinds |      8.886 ms |   0.1761 ms |   0.1729 ms |      8.879 ms |  515.6250 |        - |        - |  4,320 KB |
|                 ParallelAsyncBuilderUsingStartChild_sync |  NonAsyncBinds |     50.430 ms |   2.8994 ms |   8.5490 ms |     45.826 ms | 4222.2222 | 111.1111 |        - | 34,313 KB |
|       ParallelAsyncBuilderUsingStartImmediateAsTask_sync |  NonAsyncBinds |     15.428 ms |   0.1229 ms |   0.1150 ms |     15.383 ms | 2000.0000 |        - |        - | 16,484 KB |
|                                                          |                |               |             |             |               |           |          |          |           |
|                                       AsyncBuilder_async |     AsyncBinds |     74.702 ms |   1.1459 ms |   1.0158 ms |     74.756 ms | 1000.0000 |        - |        - |  8,377 KB |
|                  AsyncBuilder_async_applicative_overhead |     AsyncBinds |     76.906 ms |   1.1282 ms |   1.2072 ms |     76.635 ms | 1285.7143 |        - |        - | 10,555 KB |
|                ParallelAsyncBuilderUsingStartChild_async |     AsyncBinds |     72.837 ms |   0.9044 ms |   0.8460 ms |     72.646 ms | 5250.0000 | 875.0000 | 125.0000 | 43,321 KB |
|      ParallelAsyncBuilderUsingStartImmediateAsTask_async |     AsyncBinds |     67.787 ms |   1.3305 ms |   1.6826 ms |     68.050 ms | 3125.0000 |        - |        - | 26,114 KB |
|                                                          |                |               |             |             |               |           |          |          |           |
|                                  AsyncBuilder_async_long | AsyncBindsLong | 11,449.167 ms |  79.4426 ms |  62.0235 ms | 11,438.866 ms |         - |        - |        - |    839 KB |
|             AsyncBuilder_async_long_applicative_overhead | AsyncBindsLong | 11,930.969 ms | 224.8506 ms | 322.4739 ms | 12,062.812 ms |         - |        - |        - |  1,057 KB |
|           ParallelAsyncBuilderUsingStartChild_async_long | AsyncBindsLong |  1,221.578 ms |  24.3126 ms |  28.9425 ms |  1,218.303 ms |         - |        - |        - |  4,315 KB |
| ParallelAsyncBuilderUsingStartImmediateAsTask_async_long | AsyncBindsLong |  1,229.845 ms |  23.8712 ms |  31.0393 ms |  1,228.502 ms |         - |        - |        - |  2,690 KB |

Take away is Async.StartImmediateAsTask seems to out perform Async.StartChild which is probably due to Async.StartChild running the computation on the threadpool.

@TheAngryByrd TheAngryByrd merged commit 3420057 into master Mar 23, 2022
TheAngryByrd added a commit that referenced this pull request Mar 23, 2022
## [0.2.0] - 2022-03-22

### Added

- [Adds parallelAsync computation expression](#7)
@TheAngryByrd TheAngryByrd deleted the 6-parallelAsync branch April 25, 2022 15:07
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.

Implement a parallelAsync builder
1 participant