Add metrics to track the distance of content requested and offered (#1903)

This commit is contained in:
Kim De Mey 2023-11-23 18:49:15 +01:00 committed by GitHub
parent c46706ac75
commit 11e3171723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 236 additions and 5 deletions

View File

@ -232,6 +232,75 @@
"title": "RSS mem", "title": "RSS mem",
"type": "stat" "type": "stat"
}, },
{
"datasource": {
"type": "prometheus",
"uid": "P5354BB48EF90EBE5"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 2,
"w": 2,
"x": 6,
"y": 0
},
"id": 51,
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "auto"
},
"pluginVersion": "9.2.5",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "P5354BB48EF90EBE5"
},
"editorMode": "code",
"exemplar": false,
"expr": "nim_gc_mem_occupied_bytes{instance=\"${instance}\",container=\"${container}\"}",
"interval": "",
"legendFormat": "",
"range": true,
"refId": "A"
}
],
"title": "GC Mem Used",
"type": "stat"
},
{ {
"aliasColors": {}, "aliasColors": {},
"bars": false, "bars": false,
@ -579,11 +648,13 @@
"type": "prometheus", "type": "prometheus",
"uid": "P5354BB48EF90EBE5" "uid": "P5354BB48EF90EBE5"
}, },
"editorMode": "code",
"exemplar": false, "exemplar": false,
"expr": "sum(nim_gc_mem_occupied_bytes{instance=\"${instance}\",container=\"${container}\"})", "expr": "sum(nim_gc_mem_occupied_bytes{instance=\"${instance}\",container=\"${container}\"})",
"hide": false, "hide": false,
"interval": "", "interval": "",
"legendFormat": "Nim GC mem used", "legendFormat": "Nim GC mem used",
"range": true,
"refId": "E" "refId": "E"
} }
], ],
@ -2133,6 +2204,76 @@
"align": false "align": false
} }
}, },
{
"datasource": {
"type": "prometheus",
"uid": "P5354BB48EF90EBE5"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 12,
"x": 12,
"y": 68
},
"id": 52,
"options": {
"displayMode": "gradient",
"minVizHeight": 10,
"minVizWidth": 0,
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showUnfilled": true,
"text": {}
},
"pluginVersion": "9.2.5",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "P5354BB48EF90EBE5"
},
"editorMode": "code",
"exemplar": false,
"expr": "portal_find_content_log_distance_bucket{instance=\"${instance}\",container=\"${container}\"}",
"format": "heatmap",
"hide": false,
"interval": "",
"legendFormat": "{{le}}",
"range": true,
"refId": "B"
}
],
"title": "log. distance of requested content ",
"type": "bargauge"
},
{ {
"aliasColors": {}, "aliasColors": {},
"bars": false, "bars": false,
@ -2267,7 +2408,8 @@
"mode": "absolute", "mode": "absolute",
"steps": [ "steps": [
{ {
"color": "green" "color": "green",
"value": null
}, },
{ {
"color": "red", "color": "red",
@ -2328,6 +2470,76 @@
], ],
"title": "History network pruning statistics", "title": "History network pruning statistics",
"type": "timeseries" "type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "P5354BB48EF90EBE5"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 12,
"x": 12,
"y": 78
},
"id": 53,
"options": {
"displayMode": "gradient",
"minVizHeight": 10,
"minVizWidth": 0,
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showUnfilled": true,
"text": {}
},
"pluginVersion": "9.2.5",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "P5354BB48EF90EBE5"
},
"editorMode": "code",
"exemplar": false,
"expr": "portal_offer_log_distance_bucket{instance=\"${instance}\",container=\"${container}\"}",
"format": "heatmap",
"hide": false,
"interval": "",
"legendFormat": "{{le}}",
"range": true,
"refId": "B"
}
],
"title": "log. distance of offered content",
"type": "bargauge"
} }
], ],
"refresh": "5s", "refresh": "5s",
@ -2398,6 +2610,6 @@
"timezone": "", "timezone": "",
"title": "Nimbus Fluffy Dashboard", "title": "Nimbus Fluffy Dashboard",
"uid": "iWQQPuPnkadsf", "uid": "iWQQPuPnkadsf",
"version": 10, "version": 11,
"weekStart": "" "weekStart": ""
} }

View File

@ -66,7 +66,6 @@ declareCounter portal_gossip_without_lookup,
"Portal wire protocol neighborhood gossip that did not require a node lookup", "Portal wire protocol neighborhood gossip that did not require a node lookup",
labels = ["protocol_id"] labels = ["protocol_id"]
# Note: These metrics are to get some idea on how many enrs are send on average. # Note: These metrics are to get some idea on how many enrs are send on average.
# Relevant issue: https://github.com/ethereum/portal-network-specs/issues/136 # Relevant issue: https://github.com/ethereum/portal-network-specs/issues/136
const enrsBuckets = [0.0, 1.0, 3.0, 5.0, 8.0, 9.0, Inf] const enrsBuckets = [0.0, 1.0, 3.0, 5.0, 8.0, 9.0, Inf]
@ -79,6 +78,17 @@ declareHistogram portal_content_enrs_packed,
"Portal wire protocol amount of enrs packed in a content message", "Portal wire protocol amount of enrs packed in a content message",
labels = ["protocol_id"], buckets = enrsBuckets labels = ["protocol_id"], buckets = enrsBuckets
const distanceBuckets =
[float64 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252,
253, 254, 255, 256]
declareHistogram portal_find_content_log_distance,
"Portal wire protocol logarithmic distance of requested content",
labels = ["protocol_id"], buckets = distanceBuckets
declareHistogram portal_offer_log_distance,
"Portal wire protocol logarithmic distance of offered content",
labels = ["protocol_id"], buckets = distanceBuckets
logScope: logScope:
topics = "portal_wire" topics = "portal_wire"
@ -349,6 +359,10 @@ proc handleFindContent(
# discv5 layer. # discv5 layer.
return @[] return @[]
let logDistance = p.routingTable.logDistance(contentId, p.localNode.id)
portal_find_content_log_distance.observe(
int64(logDistance), labelValues = [$p.protocolId])
let contentResult = p.dbGet(fc.contentKey, contentId) let contentResult = p.dbGet(fc.contentKey, contentId)
if contentResult.isOk(): if contentResult.isOk():
@ -391,6 +405,11 @@ proc handleOffer(p: PortalProtocol, o: OfferMessage, srcId: NodeId): seq[byte] =
let contentIdResult = p.toContentId(contentKey) let contentIdResult = p.toContentId(contentKey)
if contentIdResult.isOk(): if contentIdResult.isOk():
let contentId = contentIdResult.get() let contentId = contentIdResult.get()
let logDistance = p.routingTable.logDistance(contentId, p.localNode.id)
portal_offer_log_distance.observe(
int64(logDistance), labelValues = [$p.protocolId])
if p.inRange(contentId): if p.inRange(contentId):
if p.dbGet(contentKey, contentId).isErr: if p.dbGet(contentKey, contentId).isErr:
contentKeysBitList.setBit(i) contentKeysBitList.setBit(i)

View File

@ -65,11 +65,11 @@ proc init*(
disablePoke: disablePoke disablePoke: disablePoke
) )
proc fromLogRadius*(T: type UInt256, logRadius: uint16): T = func fromLogRadius*(T: type UInt256, logRadius: uint16): T =
# Get the max value of the logRadius range # Get the max value of the logRadius range
pow((2).stuint(256), logRadius) - 1 pow((2).stuint(256), logRadius) - 1
proc getInitialRadius*(rc: RadiusConfig): UInt256 = func getInitialRadius*(rc: RadiusConfig): UInt256 =
case rc.kind case rc.kind
of Static: of Static:
return UInt256.fromLogRadius(rc.logRadius) return UInt256.fromLogRadius(rc.logRadius)