Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
cvb941 authored Apr 27, 2019
1 parent 19ea653 commit 424b927
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Parallel coroutine operations on Kotlin collections
Provides parallelized map, ~~reduce~~, ~~etc.~~ operations using coroutines in Kotlin.
Provides parallelized map, reduce, etc. operations using coroutines in Kotlin.

At this point, there is only a parallel map implementation called .mapParallel(). It is implemented like this.
```kotlin
Expand All @@ -19,6 +19,17 @@ fun showCase() {
```
If you want to achieve multithreading, make sure to run the coroutine with the Default dispatcher.

## Chunked operations
Chunked operations improve performance since they split the collection into just a couple of segments,
which are processed each by a single thread. That benefits from data locality and lesser thread management.
It is particularly useful (pretty much needed for operations like sum) in the reduce operation when using multithreading,
since each thread takes one chunk that it reduces on its own. After all threads finish, their results are then reduced again to the final result.

## Benchmarks
This source includes some benchmarks in the test source folder using [JUnitBenchmarks](http://labs.carrotsearch.com/junit-benchmarks-tutorial.html). Performance of the methods (chunked vs. not chunked and Dispatcher.Default vs Dispatcher.Main) depends on the type of the transformation operation (whether it's blocking for a long time, suspending or really quick).

Example benchmarks will be included here soon.

## Gradle
To include this in you gradle project add the following to you root build.gradle file.
```gradle
Expand All @@ -37,7 +48,4 @@ dependencies {
```

## Future
In the future, I would like parallel reduce and other transformation functions to be implemented,
as well as chunked variations of the map and future operations.
Chunked operations could potentially improve performance since they would split the collection into just a couple of segments,
which would be processed each by a single thread. That could benefit from data locality and lesser thread management.
In the future, I would like other transformation functions to be implemented.

0 comments on commit 424b927

Please sign in to comment.