From 508b3a70ed4516b4b2008db3da864178a7222768 Mon Sep 17 00:00:00 2001 From: Hellblazer Date: Sun, 7 Apr 2024 08:20:03 -0700 Subject: [PATCH] optimize gather, parallelism --- .github/workflows/maven.yml | 2 +- .../com/salesforce/apollo/choam/CHOAM.java | 11 ++++---- .../salesforce/apollo/choam/ViewAssembly.java | 2 +- fireflies/pom.xml | 13 --------- sql-state/pom.xml | 8 ++++++ .../apollo/state/AbstractLifecycleTest.java | 28 +++++++++---------- 6 files changed, 29 insertions(+), 35 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4eb1c5e57..14386c18f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -16,4 +16,4 @@ jobs: cache: 'maven' github-token: ${{ secrets.GITHUB_TOKEN }} - name: Build with Maven - run: ./mvnw -T 0.5C -batch-mode clean install -Ppre --file pom.xml -Dforks=2 + run: ./mvnw -T 0.5C -batch-mode clean install -Ppre --file pom.xml -Dforks=4 diff --git a/choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java b/choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java index f8385d32d..181795e57 100644 --- a/choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java +++ b/choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java @@ -98,13 +98,14 @@ public CHOAM(Parameters params) { nextView(); var bContext = new DelegatedContext<>(params.context()); + var adapter = new MessageAdapter(any -> true, (Function) this::signatureHash, + (Function>) any -> Collections.emptyList(), + (m, any) -> any, + (Function) AgedMessageOrBuilder::getContent); + combine = new ReliableBroadcaster(bContext, params.member(), params.combine(), params.communications(), params.metrics() == null ? null : params.metrics().getCombineMetrics(), - new MessageAdapter(any -> true, - (Function) any -> signatureHash(any), - (Function>) any -> Collections.emptyList(), - (m, any) -> any, - (Function) am -> am.getContent())); + adapter); linear = Executors.newSingleThreadExecutor( Thread.ofVirtual().name("Linear " + params.member().getId()).factory()); combine.registerHandler((ctx, messages) -> { diff --git a/choam/src/main/java/com/salesforce/apollo/choam/ViewAssembly.java b/choam/src/main/java/com/salesforce/apollo/choam/ViewAssembly.java index a923a3cf7..909d1ad6a 100644 --- a/choam/src/main/java/com/salesforce/apollo/choam/ViewAssembly.java +++ b/choam/src/main/java/com/salesforce/apollo/choam/ViewAssembly.java @@ -162,7 +162,6 @@ private boolean consider(Optional futureSailor, Terminal term, Membe params().member().getId()); return !gathered(); } - polled.add(vm); join(member, true); return !gathered(); } @@ -243,6 +242,7 @@ private void join(ViewMember vm, boolean direct) { validations.forEach(this::validate); } } + polled.add(mid); var reass = builder.build(); if (reass.isInitialized()) { publisher.accept(reass); diff --git a/fireflies/pom.xml b/fireflies/pom.xml index b435d3e14..702113c39 100644 --- a/fireflies/pom.xml +++ b/fireflies/pom.xml @@ -46,17 +46,4 @@ test - - - - - org.apache.maven.plugins - maven-surefire-plugin - - 1 - true - - - - diff --git a/sql-state/pom.xml b/sql-state/pom.xml index 1e73a795c..890ebc727 100644 --- a/sql-state/pom.xml +++ b/sql-state/pom.xml @@ -84,6 +84,14 @@ org.codehaus.mojo build-helper-maven-plugin + + org.apache.maven.plugins + maven-surefire-plugin + + 1 + false + + diff --git a/sql-state/src/test/java/com/salesforce/apollo/state/AbstractLifecycleTest.java b/sql-state/src/test/java/com/salesforce/apollo/state/AbstractLifecycleTest.java index e9474fc8d..dded314b5 100644 --- a/sql-state/src/test/java/com/salesforce/apollo/state/AbstractLifecycleTest.java +++ b/sql-state/src/test/java/com/salesforce/apollo/state/AbstractLifecycleTest.java @@ -55,12 +55,11 @@ * @author hal.hildebrand */ abstract public class AbstractLifecycleTest { - protected static final int CARDINALITY = 5; - protected static final Random entropy = new Random(); - private static final List GENESIS_DATA; - - private static final Digest GENESIS_VIEW_ID = DigestAlgorithm.DEFAULT.digest( + protected static final int CARDINALITY = 5; + private static final Digest GENESIS_VIEW_ID = DigestAlgorithm.DEFAULT.digest( "Give me food or give me slack or kill me".getBytes()); + protected final AtomicReference checkpointHeight = new AtomicReference<>(); + protected final Map updaters = new HashMap<>(); // static { // ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Session.class)).setLevel(Level.TRACE); // ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(CHOAM.class)).setLevel(Level.TRACE); @@ -71,16 +70,9 @@ abstract public class AbstractLifecycleTest { // ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Fsm.class)).setLevel(Level.TRACE); // ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(TxDataSource.class)).setLevel(Level.TRACE); // } - - static { - var txns = MigrationTest.initializeBookSchema(); - txns.add(initialInsert()); - GENESIS_DATA = CHOAM.toGenesisData(txns); - } - - protected final AtomicReference checkpointHeight = new AtomicReference<>(); - protected final Map updaters = new HashMap<>(); + private final List GENESIS_DATA; private final Map parameters = new HashMap<>(); + protected SecureRandom entropy; protected CountDownLatch checkpointOccurred; protected Map choams; protected List members; @@ -92,6 +84,12 @@ abstract public class AbstractLifecycleTest { private File checkpointDirBase; private List transactioneers; + { + var txns = MigrationTest.initializeBookSchema(); + txns.add(initialInsert()); + GENESIS_DATA = CHOAM.toGenesisData(txns); + } + public AbstractLifecycleTest() { super(); } @@ -132,7 +130,7 @@ public void before() throws Exception { baseDir = new File(System.getProperty("user.dir"), "target/cluster-" + Entropy.nextBitsStreamLong()); Utils.clean(baseDir); baseDir.mkdirs(); - var entropy = SecureRandom.getInstance("SHA1PRNG"); + entropy = SecureRandom.getInstance("SHA1PRNG"); entropy.setSeed(new byte[] { 6, 6, 6, disc() }); context = new DynamicContextImpl<>(DigestAlgorithm.DEFAULT.getOrigin(), CARDINALITY, 0.2, 3); toleranceLevel = context.toleranceLevel();