Skip to content

Commit 424b927

Browse files
authored
Update README.md
1 parent 19ea653 commit 424b927

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Parallel coroutine operations on Kotlin collections
2-
Provides parallelized map, ~~reduce~~, ~~etc.~~ operations using coroutines in Kotlin.
2+
Provides parallelized map, reduce, etc. operations using coroutines in Kotlin.
33

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

22+
## Chunked operations
23+
Chunked operations improve performance since they split the collection into just a couple of segments,
24+
which are processed each by a single thread. That benefits from data locality and lesser thread management.
25+
It is particularly useful (pretty much needed for operations like sum) in the reduce operation when using multithreading,
26+
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.
27+
28+
## Benchmarks
29+
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).
30+
31+
Example benchmarks will be included here soon.
32+
2233
## Gradle
2334
To include this in you gradle project add the following to you root build.gradle file.
2435
```gradle
@@ -37,7 +48,4 @@ dependencies {
3748
```
3849

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

0 commit comments

Comments
 (0)