Remove log statements that are keeping references to objects for too long (#4705)

* Remove log statements that are keeping references to objects for too much time

Improvement in terms of reducing java heap used,
since the logs were keeping reference to blocks sent by newPayload,
that causes high memory consumption during initial sync,
and could be one of the causes that prevent to complete snap sync on low spec machines.
Exceptions are also logged by the backward sync, so there is no loss of information.

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
pull/4708/head
Fabio Di Fabio 2 years ago committed by GitHub
parent 6d6e8e0727
commit 098558a274
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 17
      consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java
  3. 13
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayload.java

@ -17,6 +17,7 @@
- Shanghai implementation of EIP-3651 Warm coinbase [#4620](https://github.com/hyperledger/besu/pull/4620)
- Shanghai implementation of EIP-3855 Push0 [#4660](https://github.com/hyperledger/besu/pull/4660)
- Shanghai implementation of EIP-3540 and EIP-3670 Ethereum Object Format and Code Validation [#4644](https://github.com/hyperledger/besu/pull/4644)
- Remove some log statements that are keeping some objects live in heap for a long time, to reduce the amount of memory required during initial sync [#4705](https://github.com/hyperledger/besu/pull/4705)
### Bug Fixes

@ -364,9 +364,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
debugLambda(LOG, "BlockHeader {} is already present", () -> optHeader.get().toLogString());
} else {
debugLambda(LOG, "appending block hash {} to backward sync", blockHash::toHexString);
backwardSyncContext
.syncBackwardsUntil(blockHash)
.exceptionally(e -> logSyncException(blockHash, e));
backwardSyncContext.syncBackwardsUntil(blockHash);
}
return optHeader;
}
@ -382,22 +380,11 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
} else {
debugLambda(LOG, "appending block hash {} to backward sync", blockHash::toHexString);
backwardSyncContext.updateHeads(blockHash, finalizedBlockHash);
backwardSyncContext
.syncBackwardsUntil(blockHash)
.exceptionally(e -> logSyncException(blockHash, e));
backwardSyncContext.syncBackwardsUntil(blockHash);
}
return optHeader;
}
private Void logSyncException(final Hash blockHash, final Throwable exception) {
debugLambda(
LOG,
"Sync to block hash {} failed, reason {}",
blockHash::toHexString,
exception::getMessage);
return null;
}
@Override
public BlockProcessingResult validateBlock(final Block block) {

@ -187,17 +187,8 @@ public class EngineNewPayload extends ExecutionEngineJsonRpcMethod {
mergeContext.get().isSyncing(),
parentHeader.isEmpty(),
block.getHash());
mergeCoordinator
.appendNewPayloadToSync(block)
.exceptionally(
exception -> {
debugLambda(
LOG,
"Sync to block {} failed, reason {}",
block::toLogString,
exception::getMessage);
return null;
});
mergeCoordinator.appendNewPayloadToSync(block);
return respondWith(reqId, blockParam, null, SYNCING);
}

Loading…
Cancel
Save