Skip to content

Commit

Permalink
Add BlobMetrics (hyperledger#7622)
Browse files Browse the repository at this point in the history
* Add BlobMetrics

Signed-off-by: 7suyash7 <[email protected]>

* refactor

Signed-off-by: 7suyash7 <[email protected]>

* remove unused blob_storage

Signed-off-by: 7suyash7 <[email protected]>

* add .size() to BlobCache

Signed-off-by: 7suyash7 <[email protected]>

* Add to Changelog

Signed-off-by: 7suyash7 <[email protected]>

---------

Signed-off-by: 7suyash7 <[email protected]>
Co-authored-by: Fabio Di Fabio <[email protected]>
  • Loading branch information
7suyash7 and fab-10 authored Sep 19, 2024
1 parent 96e9873 commit beaee59
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Additions and Improvements
- Remove privacy test classes support [#7569](https://github.com/hyperledger/besu/pull/7569)
- Add Blob Transaction Metrics [#7622](https://github.com/hyperledger/besu/pull/7622)

### Bug fixes
- Fix mounted data path directory permissions for besu user [#7575](https://github.com/hyperledger/besu/pull/7575)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,8 @@ public Optional<Transaction> restoreBlob(final Transaction transaction) {
public BlobsWithCommitments.BlobQuad get(final VersionedHash vh) {
return cache.getIfPresent(vh);
}

public long size() {
return cache.estimatedSize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public TransactionPool(
this.blockAddedEventOrderedProcessor =
ethContext.getScheduler().createOrderedProcessor(this::processBlockAddedEvent);
this.cacheForBlobsOfTransactionsAddedToABlock = blobCache;
initializeBlobMetrics();
initLogForReplay();
subscribePendingTransactions(this::mapBlobsOnTransactionAdded);
subscribeDroppedTransactions(this::unmapBlobsOnTransactionDropped);
Expand Down Expand Up @@ -686,6 +687,19 @@ public boolean isEnabled() {
return isPoolEnabled.get();
}

public int getBlobCacheSize() {
return (int) cacheForBlobsOfTransactionsAddedToABlock.size();
}

public int getBlobMapSize() {
return mapOfBlobsInTransactionPool.size();
}

private void initializeBlobMetrics() {
metrics.createBlobCacheSizeMetric(this::getBlobCacheSize);
metrics.createBlobMapSizeMetric(this::getBlobMapSize);
}

class PendingTransactionsListenersProxy {
private final Subscribers<PendingTransactionAddedListener> onAddedListeners =
Subscribers.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.function.DoubleSupplier;
import java.util.function.IntSupplier;

import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
Expand Down Expand Up @@ -285,4 +286,20 @@ private String location(final boolean receivedFromLocalSource) {
private String priority(final boolean hasPriority) {
return hasPriority ? "yes" : "no";
}

public void createBlobCacheSizeMetric(final IntSupplier sizeSupplier) {
metricsSystem.createIntegerGauge(
BesuMetricCategory.TRANSACTION_POOL,
"blob_cache_size",
"Current size of the blob cache",
sizeSupplier);
}

public void createBlobMapSizeMetric(final IntSupplier sizeSupplier) {
metricsSystem.createIntegerGauge(
BesuMetricCategory.TRANSACTION_POOL,
"blob_map_size",
"Current size of the blob map",
sizeSupplier);
}
}

0 comments on commit beaee59

Please sign in to comment.