Skip to content

Commit

Permalink
the days of the group executer are numbered
Browse files Browse the repository at this point in the history
  • Loading branch information
paxel committed Sep 25, 2023
1 parent e0fab40 commit 9060f70
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public class Bunny {

Q: Why use this anyway? I can just use a single Threaded Executor in the Bunny.
A: Yes, but if you have 1_000_000 Bunnies, you peak at 1 mio Threads. Good bye.
Q: I can use Virtual Threads now
A: Damn. you're right. This thing is outdated!

Q: Well I could use a limited ExecutorService and limit it to 20.
A: Yes, but then one bunny is hopping concurrently up **and** down. Good bye.
Expand Down Expand Up @@ -280,7 +282,7 @@ scenario.
It must be said, that the ListIterator here is not optimized.
A dedicated FrankenListIterator will improve this value additionally.

## Benchmark results
# Overall Benchmark results
```
Benchmark (entries) Mode Cnt Score Error Units
p.bulkexecutor.JmhActorBasedSumTest.runBatch N/A thrpt 5 2.112 ± 0.023 ops/s
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/paxel/lib/FrankenListTest.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package paxel.lib;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.fail;
import org.junit.Test;
import paxel.lib.FrankenList;

public class FrankenListTest {

Expand Down
33 changes: 18 additions & 15 deletions src/test/java/paxel/lib/JmhFrankenListInsertBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,129 +5,132 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;

import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;

@Warmup(time = 1,iterations = 1,batchSize = 1,timeUnit = TimeUnit.SECONDS)
public class JmhFrankenListInsertBenchmark {

@Benchmark
public void addToFrankenListWith_a_125k_Entries(FrankenDataProvider125k prov, Blackhole bh) {
public void addTo125k_Entries_FrankenList(FrankenDataProvider125k prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToLinkedListWith_a_125k_Entries(LinkedListDataProvider125k prov, Blackhole bh) {
public void addTo125k_Entries_LinkedList(LinkedListDataProvider125k prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToArrayListWith_a_125k_Entries(ArrayListDataProvider125k prov, Blackhole bh) {
public void addTo125k_Entries_ArrayList(ArrayListDataProvider125k prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToFrankenListWith_a_250k_Entries(FrankenDataProvider250k prov, Blackhole bh) {
public void addTo250k_Entries_FrankenList(FrankenDataProvider250k prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToLinkedListWith_a_250k_Entries(LinkedListDataProvider250k prov, Blackhole bh) {
public void addTo250k_Entries_LinkedList(LinkedListDataProvider250k prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToArrayListWith_a_250k_Entries(ArrayListDataProvider250k prov, Blackhole bh) {
public void addTo250k_Entries_ArrayList(ArrayListDataProvider250k prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToFrankenListWith_a_500k_Entries(FrankenDataProvider500k prov, Blackhole bh) {
public void addTo500k_Entries_FrankenList(FrankenDataProvider500k prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToLinkedListWith_a_500k_Entries(LinkedListDataProvider500k prov, Blackhole bh) {
public void addTo500k_Entries_LinkedList(LinkedListDataProvider500k prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToArrayListWith_a_500k_Entries(ArrayListDataProvider500k prov, Blackhole bh) {
public void addTo500k_Entries_ArrayList(ArrayListDataProvider500k prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToFrankenListWith_b_1m_Entries(FrankenDataProvider prov, Blackhole bh) {
public void addTo1000k_Entries_FrankenList(FrankenDataProvider prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToLinkedListWith_b_1m_Entries(LinkedListDataProvider prov, Blackhole bh) {
public void addTo1000k_Entries_LinkedList(LinkedListDataProvider prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToArrayListWith_b_1m_Entries(ArrayListDataProvider prov, Blackhole bh) {
public void addTo1000k_Entries_ArrayList(ArrayListDataProvider prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToFrankenListWith_c_10m_Entries(FrankenDataProvider10m prov, Blackhole bh) {
public void addTo10_000k_Entries_FrankenList(FrankenDataProvider10m prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToLinkedListWith_c_10m_Entries(LinkedListDataProvider10m prov, Blackhole bh) {
public void addTo10_000k_Entries_LinkedList(LinkedListDataProvider10m prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
bh.consume(listUnderTest);
}

@Benchmark
public void addToArrayListWith_c_10m_Entries(ArrayListDataProvider10m prov, Blackhole bh) {
public void addTo10_000k_Entries_ArrayList(ArrayListDataProvider10m prov, Blackhole bh) {
final List<Long> unsortedNewValues = prov.unsortedNewValues;
final List<Long> listUnderTest = prov.sortedList;
addNewValuesToList(unsortedNewValues, listUnderTest);
Expand Down

0 comments on commit 9060f70

Please sign in to comment.