Skip to content

Commit

Permalink
restore build parallelism. cleanup. do not restore on genii
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Apr 7, 2024
1 parent 825af9f commit a7ed6e4
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
cache: 'maven'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build with Maven
run: ./mvnw -batch-mode clean install -Ppre --file pom.xml
run: ./mvnw -T 0.5C -batch-mode clean install -Ppre --file pom.xml -Dforks=2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
**/dependency-reduced-pom.xml
pom.xml.bak
/ff.log
chkpoint.txt

## Intellij stuff
.idea
Expand Down
13 changes: 0 additions & 13 deletions choam/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,4 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
</plugins>
</build>
</project>
1 change: 0 additions & 1 deletion choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@ private void synchronize(SynchronizedState state) {
CertifiedBlock current1;
if (state.lastCheckpoint() == null) {
log.info("Synchronizing from genesis: {} on: {}", state.genesis().hash, params.member().getId());
restore();
current1 = state.genesis().certifiedBlock;
} else {
log.info("Synchronizing from checkpoint: {} on: {}", state.lastCheckpoint().hash, params.member().getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ default boolean validate(HashedCertifiedBlock hb, Certification c, Map<Member, V

final boolean verified = verify.verify(new JohnHancock(c.getSignature()), hb.block.getHeader().toByteString());
if (!verified) {
log().debug("Failed verification: {} using: {} key: {} on: {}", verified, witness.getId(),
log().debug("Failed verification: false using: {} key: {} on: {}", witness.getId(),
DigestAlgorithm.DEFAULT.digest(verify.toString()), params.member().getId());
} else {
log().trace("Verified: {} using: {} key: {} on: {}", verified, witness,
log().trace("Verified: true using: {} key: {} on: {}", witness.getId(),
DigestAlgorithm.DEFAULT.digest(verify.toString()), params.member().getId());
}
return verified;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void submitMultiplTxn() throws Exception {
final var timeout = Duration.ofSeconds(15);

final var transactioneers = new ArrayList<Transactioneer>();
final var clientCount = LARGE_TESTS ? 1_500 : 50;
final var clientCount = LARGE_TESTS ? 1_500 : 5;
final var max = LARGE_TESTS ? 100 : 10;
final var countdown = new CountDownLatch(clientCount * choams.size());
choams.values().forEach(c -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Domain(ControlledIdentifierMember member, Parameters.Builder params, Stri
throw new IllegalArgumentException("Must be a directory: " + checkpointBaseDir);
}
var checkpointDir = new File(dir, qb64(member.getIdentifier().getDigest()));
sqlStateMachine = new SqlStateMachine(dbURL, new Properties(), checkpointDir);
sqlStateMachine = new SqlStateMachine(member.getId(), dbURL, new Properties(), checkpointDir);

paramsClone.getProducer().ethereal().setSigner(member);
this.params = paramsClone.build(runtimeClone.setCheckpointer(sqlStateMachine.getCheckpointer())
Expand Down
8 changes: 0 additions & 8 deletions sql-state/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.salesforce.apollo.archipelago.Router;
import com.salesforce.apollo.archipelago.ServerConnectionCache;
import com.salesforce.apollo.choam.CHOAM;
import com.salesforce.apollo.choam.CHOAM.TransactionExecutor;
import com.salesforce.apollo.choam.Parameters;
import com.salesforce.apollo.choam.Parameters.BootstrapParameters;
import com.salesforce.apollo.choam.Parameters.Builder;
Expand Down Expand Up @@ -41,8 +40,8 @@
import java.sql.Statement;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -82,7 +81,6 @@ abstract public class AbstractLifecycleTest {
protected final AtomicReference<ULong> checkpointHeight = new AtomicReference<>();
protected final Map<Member, SqlStateMachine> updaters = new HashMap<>();
private final Map<Member, Parameters> parameters = new HashMap<>();
protected Map<Digest, AtomicInteger> blocks;
protected CountDownLatch checkpointOccurred;
protected Map<Digest, CHOAM> choams;
protected List<SigningMember> members;
Expand Down Expand Up @@ -134,9 +132,8 @@ public void before() throws Exception {
baseDir = new File(System.getProperty("user.dir"), "target/cluster-" + Entropy.nextBitsStreamLong());
Utils.clean(baseDir);
baseDir.mkdirs();
blocks = new ConcurrentHashMap<>();
var entropy = SecureRandom.getInstance("SHA1PRNG");
entropy.setSeed(new byte[] { 6, 6, 6 });
entropy.setSeed(new byte[] { 6, 6, 6, disc() });
context = new DynamicContextImpl<>(DigestAlgorithm.DEFAULT.getOrigin(), CARDINALITY, 0.2, 3);
toleranceLevel = context.toleranceLevel();

Expand All @@ -145,7 +142,7 @@ public void before() throws Exception {

members = IntStream.range(0, CARDINALITY).mapToObj(i -> {
return stereotomy.newIdentifier();
}).map(cpk -> new ControlledIdentifierMember(cpk)).map(e -> (SigningMember) e).toList();
}).map(cpk -> new ControlledIdentifierMember(cpk)).map(e -> (SigningMember) e).collect(Collectors.toList());
System.out.println("Members: " + members.stream().map(s -> s.getId()).toList());
members.forEach(m -> context.activate(m));

Expand All @@ -171,14 +168,16 @@ public void before() throws Exception {

protected abstract int checkpointBlockSize();

abstract protected byte disc();

protected void post() throws Exception {

final var clearTxns = Utils.waitForCondition(120_000, 1000, () ->
final var clearTxns = Utils.waitForCondition(30_000, 1000, () ->
transactioneers.stream().mapToInt(t -> t.inFlight()).filter(t -> t == 0).count() == transactioneers.size());
assertTrue(clearTxns, "Transactions did not clear: " + Collections.singletonList(
transactioneers.stream().mapToInt(t -> t.inFlight()).filter(t -> t == 0).toArray()));

final var synchd = Utils.waitForCondition(120_000, 1000, () -> {
final var synchd = Utils.waitForCondition(30_000, 1000, () -> {

var max = members.stream()
.map(m -> updaters.get(m))
Expand Down Expand Up @@ -326,10 +325,9 @@ protected Txn update(Random entropy, Mutator mutator) {

private CHOAM createChoam(Random entropy, Builder params, SigningMember m, boolean testSubject,
Context<Member> context) {
blocks.put(m.getId(), new AtomicInteger());
String url = String.format("jdbc:h2:mem:test_engine-%s-%s", m.getId(), entropy.nextLong());
System.out.println("DB URL: " + url);
SqlStateMachine up = new SqlStateMachine(DigestAlgorithm.DEFAULT.getOrigin(), url, new Properties(),
SqlStateMachine up = new SqlStateMachine(m.getId(), url, new Properties(),
new File(checkpointDirBase, m.getId().toString()));
updaters.put(m, up);

Expand All @@ -342,7 +340,7 @@ private CHOAM createChoam(Random entropy, Builder params, SigningMember m, boole
.setCommunications(routers.get(m.getId()))
.setCheckpointer(wrap(up))
.setRestorer(up.getBootstrapper())
.setProcessor(wrap(m, up))
.setProcessor(up.getExecutor())
.build()));
}

Expand All @@ -364,41 +362,13 @@ private Builder parameters(Context<Member> context) {
.setGossipDuration(Duration.ofMillis(10))
.setCheckpointBlockDelta(checkpointBlockSize())
.setCheckpointSegmentSize(128);
params.getProducer().ethereal().setNumberOfEpochs(10);

params.getDrainPolicy().setInitialBackoff(Duration.ofMillis(1)).setMaxBackoff(Duration.ofMillis(1));
params.getProducer().ethereal().setNumberOfEpochs(2).setEpochLength(20);

return params;
}

private TransactionExecutor wrap(SigningMember m, SqlStateMachine up) {
return new TransactionExecutor() {
@Override
public void beginBlock(ULong height, Digest hash) {
blocks.get(m.getId()).incrementAndGet();
up.getExecutor().beginBlock(height, hash);
}

@Override
public void endBlock(ULong height, Digest hash) {
up.getExecutor().endBlock(height, hash);
}

@Override
public void execute(int i, Digest hash, Transaction tx,
@SuppressWarnings("rawtypes") CompletableFuture onComplete, Executor executor) {
up.getExecutor().execute(i, hash, tx, onComplete, executor);
}

@Override
public void genesis(Digest hash, List<Transaction> initialization) {
blocks.get(m.getId()).incrementAndGet();
up.getExecutor().genesis(hash, initialization);
}
};
}

private Function<ULong, File> wrap(SqlStateMachine up) {
final var checkpointer = up.getCheckpointer();
return l -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,17 @@ public void checkpointBootstrap() throws Exception {

assertTrue(Utils.waitForCondition(30_000, 1_000, () -> choam.active()),
"Test subject did not become active: " + choam.logState());

members.add(testSubject);
post();
}

@Override
protected int checkpointBlockSize() {
return 3;
}

@Override
protected byte disc() {
return 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
package com.salesforce.apollo.state;

import com.salesforce.apollo.context.DynamicContext;
import com.salesforce.apollo.utils.Utils;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author hal.hildebrand
*/
Expand All @@ -22,11 +25,20 @@ public void genesisBootstrap() throws Exception {
((DynamicContext) choam.context().delegate()).activate(testSubject);
choam.start();
routers.get(testSubject.getId()).start();

assertTrue(Utils.waitForCondition(30_000, 1_000, () -> choam.active()),
"Test subject did not become active: " + choam.logState());
members.add(testSubject);
post();
}

@Override
protected int checkpointBlockSize() {
return 1000;
}

@Override
protected byte disc() {
return 2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ void decorate(CompletableFuture<?> fs) {
} catch (InvalidTransaction e) {
e.printStackTrace();
}
}, log)), entropy.nextInt(100), TimeUnit.MILLISECONDS);
} else if (finished.compareAndSet(false, true)) {
}, log)), entropy.nextInt(2000), TimeUnit.MILLISECONDS);
} else {
countdown.countDown();
}
}
Expand Down
4 changes: 4 additions & 0 deletions sql-state/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
<appender-ref ref="STDOUT"/>
</logger>

<logger name="com.chiralbehaviors.tron" level="warn" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>

<logger name="com.salesforce.apollo.choam.Session" level="warn" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
Expand Down

0 comments on commit a7ed6e4

Please sign in to comment.