mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Add duration log for DaoStateMonitoringService
Creating the daoStateHash is quite expensive (about 20-30 ms/block). As this happens while parsing it delays the parsing time (parsing is very fast). We persist t the hashes so it is only done for new blocks. For 1 month of blocks (4000) it would take about 80-120 seconds. It is not blocking the user thread as it is done per block and those are parsed one after another.
This commit is contained in:
parent
9db4d69276
commit
8521164adc
@ -117,6 +117,8 @@ public class DaoStateMonitoringService implements DaoSetupService, DaoStateListe
|
||||
);
|
||||
private boolean checkpointFailed;
|
||||
private boolean ignoreDevMsg;
|
||||
private int numCalls;
|
||||
private long accumulatedDuration;
|
||||
|
||||
private final File storageDir;
|
||||
|
||||
@ -176,6 +178,12 @@ public class DaoStateMonitoringService implements DaoSetupService, DaoStateListe
|
||||
if (!ignoreDevMsg) {
|
||||
verifyCheckpoints();
|
||||
}
|
||||
|
||||
log.info("ParseBlockChainComplete: Accumulated updateHashChain() calls for {} block took {} ms " +
|
||||
"({} ms in average / block)",
|
||||
numCalls,
|
||||
accumulatedDuration,
|
||||
(int) ((double) accumulatedDuration / (double) numCalls));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -277,6 +285,7 @@ public class DaoStateMonitoringService implements DaoSetupService, DaoStateListe
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void updateHashChain(Block block) {
|
||||
long ts = System.currentTimeMillis();
|
||||
byte[] prevHash;
|
||||
int height = block.getHeight();
|
||||
if (daoStateBlockChain.isEmpty()) {
|
||||
@ -316,6 +325,13 @@ public class DaoStateMonitoringService implements DaoSetupService, DaoStateListe
|
||||
int delayInSec = 5 + new Random().nextInt(10);
|
||||
UserThread.runAfter(() -> daoStateNetworkService.broadcastMyStateHash(myDaoStateHash), delayInSec);
|
||||
}
|
||||
long duration = System.currentTimeMillis() - ts;
|
||||
// We don't want to spam the outpu. We log accumulated time after parsing is completed.
|
||||
log.trace("updateHashChain for block {} took {} ms",
|
||||
block.getHeight(),
|
||||
duration);
|
||||
accumulatedDuration += duration;
|
||||
numCalls++;
|
||||
}
|
||||
|
||||
private boolean processPeersDaoStateHash(DaoStateHash daoStateHash, Optional<NodeAddress> peersNodeAddress,
|
||||
|
Loading…
Reference in New Issue
Block a user