Skip to content

Commit aaed4eb

Browse files
authored
Merge pull request #4148 from jayz22/update-docs
Add soroban metrics for selected network limits Reviewed-by: dmkozh
2 parents edad113 + 651e9f3 commit aaed4eb

File tree

5 files changed

+132
-0
lines changed

5 files changed

+132
-0
lines changed

docs/metrics.md

+40
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,43 @@ state-archival.eviction.bytes-scanned | counter | number of bytes that evi
162162
state-archival.eviction.entries-evicted | counter | number of entries that have been evicted
163163
state-archival.eviction.incomplete-scan | counter | number of buckets that were too large to be fully scanned for eviction
164164
state-archival.eviction.period | counter | number of ledgers to complete an eviction scan
165+
soroban.host-fn-op.read-entry | meter | number of entries read
166+
soroban.host-fn-op.write-entry | meter | number of entries written
167+
soroban.host-fn-op.read-key-byte | meter | number of key bytes in read entries
168+
soroban.host-fn-op.write-key-byte | meter | number of key bytes in written entries
169+
soroban.host-fn-op.read-ledger-byte | meter | number of data + code bytes in read entries
170+
soroban.host-fn-op.read-data-byte | meter | number of data bytes in read entries
171+
soroban.host-fn-op.read-code-byte | meter | number of code bytes in read entries
172+
soroban.host-fn-op.write-ledger-byte | meter | number of data + code bytes in written entries
173+
soroban.host-fn-op.write-data-byte | meter | number of data bytes in written entries
174+
soroban.host-fn-op.write-code-byte | meter | number of code bytes in written entries
175+
soroban.host-fn-op.emit-event | meter | number of events emitted
176+
soroban.host-fn-op.emit-event-byte | meter | number of event bytes emitted
177+
soroban.host-fn-op.cpu-insn | meter | metered cpu instructions
178+
soroban.host-fn-op.mem-byte | meter | metered memory bytes
179+
soroban.host-fn-op.invoke-time-nsecs | meter | time [nsecs] spent in `invoke_host_function`
180+
soroban.host-fn-op.cpu-insn-excl-vm | meter | metered cpu instructions excluding VM instantation
181+
soroban.host-fn-op.invoke-time-nsecs-excl-vm | meter | time [nsecs] spent in `invoke_host_function` excluding VM instantation
182+
soroban.host-fn-op.max-rw-key-byte | meter | bytes of the largest key in entries read/written
183+
soroban.host-fn-op.max-rw-data-byte | meter | bytes of the largest data entry read/written
184+
soroban.host-fn-op.max-rw-code-byte | meter | bytes of the largest code entry read/written
185+
soroban.host-fn-op.max-emit-event-byte | meter | bytes of the largest event emitted
186+
soroban.host-fn-op.success | meter | if `InvokeHostFunctionOp` results in a success
187+
soroban.host-fn-op.failure | meter | if `InvokeHostFunctionOp` results in a failure
188+
soroban.host-fn-op.exec | timer | time spent in `InvokeHostFunctionOp`
189+
soroban.config.contract-max-size-bytes | meter | soroban config setting `contract_max_size_bytes`
190+
soroban.config.ledger-max-instructions | meter | soroban config setting `ledger_max_instructions`
191+
soroban.config.tx-max-instructions | meter | soroban config setting `tx_max_instructions`
192+
soroban.config.tx-memory-limit | meter | soroban config setting `tx_memory_limit`
193+
soroban.config.ledger-max-read-ledger-entries | meter | soroban config setting `ledger_max_read_ledger_entries`
194+
soroban.config.ledger-max-read-bytes | meter | soroban config setting `ledger_max_read_bytes`
195+
soroban.config.ledger-max-write-ledger-entries | meter | soroban config setting `ledger_max_write_ledger_entries`
196+
soroban.config.ledger-max-write-bytes | meter | soroban config setting `ledger_max_write_bytes`
197+
soroban.config.tx-max-read-ledger-entries | meter | soroban config setting `tx_max_read_ledger_entries`
198+
soroban.config.tx-max-read-bytes | meter | soroban config setting `tx_max_read_bytes`
199+
soroban.config.tx-max-write-ledger-entries | meter | soroban config setting `tx_max_write_ledger_entries`
200+
soroban.config.tx-max-write-bytes | meter | soroban config setting `tx_max_write_bytes`
201+
soroban.config.bucket-list-target-size-bytes | meter | soroban config setting `bucket_list_target_size_bytes`
202+
soroban.config.tx-max-contract-events-size-bytes | meter | soroban config setting `tx_max_contract_events_size_bytes`
203+
soroban.config.contract-data-key-size-bytes | meter | soroban config setting `contract_data_key_size_bytes`
204+
soroban.config.contract-data-entry-size-bytes | meter | soroban config setting `contract_data_entry_size_bytes`

src/ledger/LedgerManagerImpl.cpp

+79
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,84 @@ LedgerManagerImpl::getMutableSorobanNetworkConfig()
548548
}
549549
#endif
550550

551+
void
552+
LedgerManagerImpl::publishSorobanNetworkConfigMetrics()
553+
{
554+
releaseAssert(mSorobanNetworkConfig);
555+
medida::MetricsRegistry& metrics = mApp.getMetrics();
556+
557+
auto contractMaxSizeBytes = mSorobanNetworkConfig->maxContractSizeBytes();
558+
auto ledgerMaxInstructions = mSorobanNetworkConfig->ledgerMaxInstructions();
559+
auto txMaxInstructions = mSorobanNetworkConfig->txMaxInstructions();
560+
auto txMemoryLimit = mSorobanNetworkConfig->txMemoryLimit();
561+
auto ledgerMaxReadLedgerEntries =
562+
mSorobanNetworkConfig->ledgerMaxReadLedgerEntries();
563+
auto ledgerMaxReadBytes = mSorobanNetworkConfig->ledgerMaxReadBytes();
564+
auto ledgerMaxWriteLedgerEntries =
565+
mSorobanNetworkConfig->ledgerMaxWriteLedgerEntries();
566+
auto ledgerMaxWriteBytes = mSorobanNetworkConfig->ledgerMaxWriteBytes();
567+
auto txMaxReadLedgerEntries =
568+
mSorobanNetworkConfig->txMaxReadLedgerEntries();
569+
auto txMaxReadBytes = mSorobanNetworkConfig->txMaxReadBytes();
570+
auto txMaxWriteLedgerEntries =
571+
mSorobanNetworkConfig->txMaxWriteLedgerEntries();
572+
auto txMaxWriteBytes = mSorobanNetworkConfig->txMaxWriteBytes();
573+
auto bucketListTargetSizeBytes =
574+
mSorobanNetworkConfig->bucketListTargetSizeBytes();
575+
auto txMaxContractEventsSizeBytes =
576+
mSorobanNetworkConfig->txMaxContractEventsSizeBytes();
577+
auto contractDataKeySizeBytes =
578+
mSorobanNetworkConfig->maxContractDataKeySizeBytes();
579+
auto contractDataEntrySizeBytes =
580+
mSorobanNetworkConfig->maxContractDataEntrySizeBytes();
581+
582+
metrics.NewMeter({"soroban", "config", "contract-max-size-bytes"}, "byte")
583+
.Mark(contractMaxSizeBytes);
584+
metrics.NewMeter({"soroban", "config", "ledger-max-instructions"}, "insn")
585+
.Mark(ledgerMaxInstructions);
586+
metrics.NewMeter({"soroban", "config", "tx-max-instructions"}, "insn")
587+
.Mark(txMaxInstructions);
588+
metrics.NewMeter({"soroban", "config", "tx-memory-limit"}, "byte")
589+
.Mark(txMemoryLimit);
590+
metrics
591+
.NewMeter({"soroban", "config", "ledger-max-read-ledger-entries"},
592+
"entry")
593+
.Mark(ledgerMaxReadLedgerEntries);
594+
metrics.NewMeter({"soroban", "config", "ledger-max-read-bytes"}, "byte")
595+
.Mark(ledgerMaxReadBytes);
596+
metrics
597+
.NewMeter({"soroban", "config", "ledger-max-write-ledger-entries"},
598+
"entry")
599+
.Mark(ledgerMaxWriteLedgerEntries);
600+
metrics.NewMeter({"soroban", "config", "ledger-max-write-bytes"}, "byte")
601+
.Mark(ledgerMaxWriteBytes);
602+
metrics
603+
.NewMeter({"soroban", "config", "tx-max-read-ledger-entries"}, "entry")
604+
.Mark(txMaxReadLedgerEntries);
605+
metrics.NewMeter({"soroban", "config", "tx-max-read-bytes"}, "byte")
606+
.Mark(txMaxReadBytes);
607+
metrics
608+
.NewMeter({"soroban", "config", "tx-max-write-ledger-entries"}, "entry")
609+
.Mark(txMaxWriteLedgerEntries);
610+
metrics.NewMeter({"soroban", "config", "tx-max-write-bytes"}, "byte")
611+
.Mark(txMaxWriteBytes);
612+
metrics
613+
.NewMeter({"soroban", "config", "bucket-list-target-size-bytes"},
614+
"byte")
615+
.Mark(bucketListTargetSizeBytes);
616+
metrics
617+
.NewMeter({"soroban", "config", "tx-max-contract-events-size-bytes"},
618+
"byte")
619+
.Mark(txMaxContractEventsSizeBytes);
620+
metrics
621+
.NewMeter({"soroban", "config", "contract-data-key-size-bytes"}, "byte")
622+
.Mark(contractDataKeySizeBytes);
623+
metrics
624+
.NewMeter({"soroban", "config", "contract-data-entry-size-bytes"},
625+
"byte")
626+
.Mark(contractDataEntrySizeBytes);
627+
}
628+
551629
// called by txherder
552630
void
553631
LedgerManagerImpl::valueExternalized(LedgerCloseData const& ledgerData)
@@ -1222,6 +1300,7 @@ LedgerManagerImpl::updateNetworkConfig(AbstractLedgerTxn& rootLtx)
12221300
mSorobanNetworkConfig->loadFromLedger(
12231301
rootLtx, mApp.getConfig().CURRENT_LEDGER_PROTOCOL_VERSION,
12241302
ledgerVersion);
1303+
publishSorobanNetworkConfigMetrics();
12251304
}
12261305
else
12271306
{

src/ledger/LedgerManagerImpl.h

+5
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ class LedgerManagerImpl : public LedgerManager
102102

103103
SorobanNetworkConfig& getSorobanNetworkConfigInternal();
104104

105+
// Publishes selected network configured limits as medida metrics, useful
106+
// for contextualizing the other live metrics. This does not include all
107+
// settings, just includes ones relevant for display.
108+
void publishSorobanNetworkConfigMetrics();
109+
105110
protected:
106111
// initialLedgerVers must be the ledger version at the start of the ledger
107112
// and currLedgerVers is the ledger version in the current ltx header. These

src/ledger/NetworkConfig.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,12 @@ SorobanNetworkConfig::feeWrite1KB() const
10621062
return mFeeWrite1KB;
10631063
}
10641064

1065+
int64_t
1066+
SorobanNetworkConfig::bucketListTargetSizeBytes() const
1067+
{
1068+
return mBucketListTargetSizeBytes;
1069+
}
1070+
10651071
// Historical data (pushed to core archives) settings for contracts.
10661072
int64_t
10671073
SorobanNetworkConfig::feeHistorical1KB() const

src/ledger/NetworkConfig.h

+2
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ class SorobanNetworkConfig
260260
int64_t feeRead1KB() const;
261261
// Fee for writing 1KB
262262
int64_t feeWrite1KB() const;
263+
// Bucket list target size (in bytes)
264+
int64_t bucketListTargetSizeBytes() const;
263265

264266
// Historical data (pushed to core archives) settings for contracts.
265267
// Fee for storing 1KB in archives

0 commit comments

Comments
 (0)