From 086caebc015a4dd6c2f1c7a37e58126735483237 Mon Sep 17 00:00:00 2001 From: Cody Littley Date: Wed, 4 Mar 2026 12:42:19 -0600 Subject: [PATCH 1/6] Show time spent per block. --- .../dashboards/cryptosim-dashboard.json | 506 ++++++++++++------ 1 file changed, 332 insertions(+), 174 deletions(-) diff --git a/docker/monitornode/dashboards/cryptosim-dashboard.json b/docker/monitornode/dashboards/cryptosim-dashboard.json index 5ffc37c4c8..12d6542a09 100644 --- a/docker/monitornode/dashboards/cryptosim-dashboard.json +++ b/docker/monitornode/dashboards/cryptosim-dashboard.json @@ -97,6 +97,69 @@ "title": "Time Spent", "type": "piechart" }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [], + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 16, + "w": 12, + "x": 12, + "y": 1 + }, + "id": 275, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "pieType": "pie", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "sort": "desc", + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.4.0", + "targets": [ + { + "editorMode": "code", + "expr": "rate(seidb_main_thread_phase_duration_seconds_total[$__rate_interval])\n/ on() group_left()\nrate(cryptosim_blocks_finalized_total[$__rate_interval])", + "legendFormat": "{{phase}}", + "range": true, + "refId": "A" + } + ], + "title": "Time Spent Per Block (amortized)", + "type": "piechart" + }, { "datasource": { "type": "prometheus", @@ -162,8 +225,8 @@ "gridPos": { "h": 8, "w": 12, - "x": 12, - "y": 1 + "x": 0, + "y": 17 }, "id": 15, "options": { @@ -192,6 +255,101 @@ "title": "Time Spent", "type": "timeseries" }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "showValues": false, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 17 + }, + "id": 276, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.4.0", + "targets": [ + { + "editorMode": "code", + "expr": "rate(seidb_main_thread_phase_duration_seconds_total[$__rate_interval])\n/ on() group_left()\nrate(cryptosim_blocks_finalized_total[$__rate_interval])", + "legendFormat": "{{phase}}", + "range": true, + "refId": "A" + } + ], + "title": "Time Spent Per Block (amortized)", + "type": "timeseries" + }, { "datasource": { "type": "prometheus", @@ -257,8 +415,8 @@ "gridPos": { "h": 8, "w": 12, - "x": 12, - "y": 9 + "x": 0, + "y": 25 }, "id": 16, "options": { @@ -293,7 +451,7 @@ "h": 1, "w": 24, "x": 0, - "y": 17 + "y": 33 }, "id": 9, "panels": [ @@ -363,7 +521,7 @@ "h": 8, "w": 12, "x": 0, - "y": 4103 + "y": 18 }, "id": 6, "options": { @@ -493,7 +651,7 @@ "h": 8, "w": 12, "x": 12, - "y": 4103 + "y": 18 }, "id": 7, "options": { @@ -588,7 +746,7 @@ "h": 8, "w": 12, "x": 0, - "y": 4111 + "y": 3370 }, "id": 10, "options": { @@ -682,7 +840,7 @@ "h": 8, "w": 12, "x": 12, - "y": 4111 + "y": 3370 }, "id": 11, "options": { @@ -721,7 +879,7 @@ "h": 1, "w": 24, "x": 0, - "y": 18 + "y": 34 }, "id": 13, "panels": [ @@ -751,7 +909,7 @@ "h": 16, "w": 12, "x": 0, - "y": 3900 + "y": 19 }, "id": 20, "options": { @@ -854,7 +1012,7 @@ "h": 8, "w": 12, "x": 12, - "y": 3900 + "y": 19 }, "id": 19, "options": { @@ -985,7 +1143,7 @@ "h": 8, "w": 12, "x": 12, - "y": 3948 + "y": 3243 }, "id": 21, "options": { @@ -1080,7 +1238,7 @@ "h": 8, "w": 12, "x": 0, - "y": 3956 + "y": 3291 }, "id": 22, "options": { @@ -1211,7 +1369,7 @@ "h": 8, "w": 12, "x": 12, - "y": 3956 + "y": 3291 }, "id": 23, "options": { @@ -1342,7 +1500,7 @@ "h": 8, "w": 12, "x": 0, - "y": 3964 + "y": 3299 }, "id": 24, "options": { @@ -1473,7 +1631,7 @@ "h": 8, "w": 12, "x": 12, - "y": 3964 + "y": 3299 }, "id": 25, "options": { @@ -1604,7 +1762,7 @@ "h": 8, "w": 12, "x": 0, - "y": 3972 + "y": 3307 }, "id": 26, "options": { @@ -1735,7 +1893,7 @@ "h": 8, "w": 12, "x": 12, - "y": 3972 + "y": 3307 }, "id": 27, "options": { @@ -1866,7 +2024,7 @@ "h": 8, "w": 12, "x": 0, - "y": 3980 + "y": 3315 }, "id": 28, "options": { @@ -1941,7 +2099,7 @@ "h": 1, "w": 24, "x": 0, - "y": 19 + "y": 35 }, "id": 8, "panels": [ @@ -2010,7 +2168,7 @@ "h": 8, "w": 12, "x": 0, - "y": 4101 + "y": 44 }, "id": 1, "options": { @@ -2034,7 +2192,7 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "code", - "expr": "rate(cryptosim_blocks_finalized_total[$__rate_interval ])", + "expr": "rate(cryptosim_blocks_finalized_total[$__rate_interval])", "legendFormat": "Blocks / Second", "range": true, "refId": "A" @@ -2109,7 +2267,7 @@ "h": 8, "w": 12, "x": 12, - "y": 4101 + "y": 44 }, "id": 18, "options": { @@ -2184,7 +2342,7 @@ "h": 1, "w": 24, "x": 0, - "y": 20 + "y": 36 }, "id": 12, "panels": [ @@ -2253,7 +2411,7 @@ "h": 8, "w": 12, "x": 0, - "y": 4102 + "y": 7478 }, "id": 3, "options": { @@ -2352,7 +2510,7 @@ "h": 8, "w": 12, "x": 12, - "y": 4102 + "y": 7478 }, "id": 4, "options": { @@ -2427,7 +2585,7 @@ "h": 1, "w": 24, "x": 0, - "y": 21 + "y": 37 }, "id": 29, "panels": [ @@ -2497,7 +2655,7 @@ "h": 8, "w": 12, "x": 0, - "y": 4104 + "y": 3382 }, "id": 31, "options": { @@ -2592,7 +2750,7 @@ "h": 8, "w": 12, "x": 12, - "y": 4104 + "y": 3382 }, "id": 36, "options": { @@ -2687,7 +2845,7 @@ "h": 8, "w": 12, "x": 0, - "y": 4112 + "y": 3390 }, "id": 38, "options": { @@ -2726,7 +2884,7 @@ "h": 1, "w": 24, "x": 0, - "y": 22 + "y": 38 }, "id": 35, "panels": [ @@ -2795,7 +2953,7 @@ "h": 8, "w": 12, "x": 0, - "y": 4713 + "y": 8089 }, "id": 30, "options": { @@ -2890,7 +3048,7 @@ "h": 8, "w": 12, "x": 12, - "y": 4713 + "y": 8089 }, "id": 33, "options": { @@ -2985,7 +3143,7 @@ "h": 8, "w": 12, "x": 0, - "y": 4753 + "y": 8129 }, "id": 34, "options": { @@ -3024,7 +3182,7 @@ "h": 1, "w": 24, "x": 0, - "y": 23 + "y": 39 }, "id": 37, "panels": [ @@ -3094,7 +3252,7 @@ "h": 8, "w": 12, "x": 0, - "y": 4106 + "y": 7482 }, "id": 39, "options": { @@ -3189,7 +3347,7 @@ "h": 8, "w": 12, "x": 12, - "y": 4106 + "y": 7482 }, "id": 40, "options": { @@ -3284,7 +3442,7 @@ "h": 8, "w": 12, "x": 0, - "y": 4114 + "y": 7490 }, "id": 41, "options": { @@ -3379,7 +3537,7 @@ "h": 8, "w": 12, "x": 12, - "y": 4114 + "y": 7490 }, "id": 42, "options": { @@ -3474,7 +3632,7 @@ "h": 8, "w": 12, "x": 0, - "y": 4122 + "y": 7498 }, "id": 32, "options": { @@ -3513,7 +3671,7 @@ "h": 1, "w": 24, "x": 0, - "y": 24 + "y": 40 }, "id": 44, "panels": [ @@ -3583,7 +3741,7 @@ "h": 8, "w": 12, "x": 0, - "y": 3907 + "y": 7283 }, "id": 43, "options": { @@ -3622,7 +3780,7 @@ "h": 1, "w": 24, "x": 0, - "y": 25 + "y": 41 }, "id": 117, "panels": [ @@ -3882,7 +4040,7 @@ "h": 8, "w": 12, "x": 0, - "y": 530 + "y": 218 }, "id": 261, "options": { @@ -3977,7 +4135,7 @@ "h": 8, "w": 12, "x": 12, - "y": 530 + "y": 218 }, "id": 263, "options": { @@ -4072,7 +4230,7 @@ "h": 8, "w": 12, "x": 0, - "y": 586 + "y": 226 }, "id": 262, "options": { @@ -4167,7 +4325,7 @@ "h": 8, "w": 12, "x": 12, - "y": 586 + "y": 226 }, "id": 264, "options": { @@ -4206,7 +4364,7 @@ "h": 1, "w": 24, "x": 0, - "y": 26 + "y": 42 }, "id": 191, "panels": [ @@ -4275,7 +4433,7 @@ "h": 8, "w": 12, "x": 0, - "y": 27 + "y": 3403 }, "id": 155, "options": { @@ -4370,7 +4528,7 @@ "h": 8, "w": 12, "x": 12, - "y": 27 + "y": 3403 }, "id": 111, "options": { @@ -4465,7 +4623,7 @@ "h": 8, "w": 12, "x": 0, - "y": 91 + "y": 3467 }, "id": 175, "options": { @@ -4560,7 +4718,7 @@ "h": 8, "w": 12, "x": 12, - "y": 91 + "y": 3467 }, "id": 173, "options": { @@ -4654,7 +4812,7 @@ "h": 8, "w": 12, "x": 0, - "y": 99 + "y": 3475 }, "id": 138, "options": { @@ -4749,7 +4907,7 @@ "h": 8, "w": 12, "x": 12, - "y": 99 + "y": 3475 }, "id": 172, "options": { @@ -4844,7 +5002,7 @@ "h": 8, "w": 12, "x": 0, - "y": 107 + "y": 3483 }, "id": 236, "options": { @@ -4883,7 +5041,7 @@ "h": 1, "w": 24, "x": 0, - "y": 27 + "y": 43 }, "id": 118, "panels": [ @@ -4952,7 +5110,7 @@ "h": 8, "w": 12, "x": 0, - "y": 28 + "y": 1556 }, "id": 127, "options": { @@ -5047,7 +5205,7 @@ "h": 8, "w": 12, "x": 12, - "y": 28 + "y": 1556 }, "id": 120, "options": { @@ -5141,7 +5299,7 @@ "h": 8, "w": 12, "x": 0, - "y": 36 + "y": 1564 }, "id": 128, "options": { @@ -5236,7 +5394,7 @@ "h": 8, "w": 12, "x": 12, - "y": 36 + "y": 1564 }, "id": 121, "options": { @@ -5330,7 +5488,7 @@ "h": 8, "w": 12, "x": 0, - "y": 44 + "y": 1572 }, "id": 129, "options": { @@ -5425,7 +5583,7 @@ "h": 8, "w": 12, "x": 12, - "y": 44 + "y": 1572 }, "id": 122, "options": { @@ -5519,7 +5677,7 @@ "h": 8, "w": 12, "x": 0, - "y": 52 + "y": 1580 }, "id": 130, "options": { @@ -5614,7 +5772,7 @@ "h": 8, "w": 12, "x": 12, - "y": 52 + "y": 1580 }, "id": 123, "options": { @@ -5708,7 +5866,7 @@ "h": 8, "w": 12, "x": 0, - "y": 60 + "y": 1588 }, "id": 131, "options": { @@ -5803,7 +5961,7 @@ "h": 8, "w": 12, "x": 12, - "y": 60 + "y": 1588 }, "id": 124, "options": { @@ -5897,7 +6055,7 @@ "h": 8, "w": 12, "x": 0, - "y": 68 + "y": 1596 }, "id": 132, "options": { @@ -5992,7 +6150,7 @@ "h": 8, "w": 12, "x": 12, - "y": 68 + "y": 1596 }, "id": 125, "options": { @@ -6086,7 +6244,7 @@ "h": 8, "w": 12, "x": 0, - "y": 76 + "y": 1604 }, "id": 119, "options": { @@ -6181,7 +6339,7 @@ "h": 8, "w": 12, "x": 12, - "y": 76 + "y": 1604 }, "id": 126, "options": { @@ -6220,7 +6378,7 @@ "h": 1, "w": 24, "x": 0, - "y": 28 + "y": 44 }, "id": 115, "panels": [ @@ -6289,7 +6447,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1705 + "y": 53 }, "id": 101, "options": { @@ -6383,7 +6541,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1705 + "y": 53 }, "id": 187, "options": { @@ -6478,7 +6636,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1713 + "y": 61 }, "id": 113, "options": { @@ -6572,7 +6730,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1713 + "y": 61 }, "id": 103, "options": { @@ -6667,7 +6825,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1721 + "y": 69 }, "id": 102, "options": { @@ -6762,7 +6920,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1721 + "y": 69 }, "id": 116, "options": { @@ -6856,7 +7014,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1729 + "y": 77 }, "id": 135, "options": { @@ -6951,7 +7109,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1729 + "y": 77 }, "id": 134, "options": { @@ -7045,7 +7203,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1737 + "y": 85 }, "id": 136, "options": { @@ -7140,7 +7298,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1737 + "y": 85 }, "id": 159, "options": { @@ -7179,7 +7337,7 @@ "h": 1, "w": 24, "x": 0, - "y": 29 + "y": 45 }, "id": 193, "panels": [ @@ -7248,7 +7406,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1754 + "y": 5130 }, "id": 141, "options": { @@ -7342,7 +7500,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1754 + "y": 5130 }, "id": 148, "options": { @@ -7436,7 +7594,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1762 + "y": 5138 }, "id": 142, "options": { @@ -7530,7 +7688,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1762 + "y": 5138 }, "id": 149, "options": { @@ -7624,7 +7782,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1770 + "y": 5146 }, "id": 143, "options": { @@ -7718,7 +7876,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1770 + "y": 5146 }, "id": 150, "options": { @@ -7812,7 +7970,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1778 + "y": 5154 }, "id": 144, "options": { @@ -7906,7 +8064,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1778 + "y": 5154 }, "id": 151, "options": { @@ -8000,7 +8158,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1786 + "y": 5162 }, "id": 145, "options": { @@ -8094,7 +8252,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1786 + "y": 5162 }, "id": 152, "options": { @@ -8188,7 +8346,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1794 + "y": 5170 }, "id": 146, "options": { @@ -8282,7 +8440,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1794 + "y": 5170 }, "id": 153, "options": { @@ -8376,7 +8534,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1802 + "y": 5178 }, "id": 147, "options": { @@ -8470,7 +8628,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1802 + "y": 5178 }, "id": 154, "options": { @@ -8509,7 +8667,7 @@ "h": 1, "w": 24, "x": 0, - "y": 30 + "y": 46 }, "id": 192, "panels": [ @@ -8578,7 +8736,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1530 + "y": 4906 }, "id": 190, "options": { @@ -8673,7 +8831,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1530 + "y": 4906 }, "id": 184, "options": { @@ -8767,7 +8925,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1538 + "y": 4914 }, "id": 188, "options": { @@ -8862,7 +9020,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1538 + "y": 4914 }, "id": 186, "options": { @@ -8957,7 +9115,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1546 + "y": 4922 }, "id": 185, "options": { @@ -9051,7 +9209,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1546 + "y": 4922 }, "id": 189, "options": { @@ -9145,7 +9303,7 @@ "h": 8, "w": 12, "x": 0, - "y": 1554 + "y": 4930 }, "id": 181, "options": { @@ -9240,7 +9398,7 @@ "h": 8, "w": 12, "x": 12, - "y": 1554 + "y": 4930 }, "id": 182, "options": { @@ -9279,7 +9437,7 @@ "h": 1, "w": 24, "x": 0, - "y": 31 + "y": 47 }, "id": 194, "panels": [ @@ -9348,7 +9506,7 @@ "h": 8, "w": 12, "x": 0, - "y": 112 + "y": 856 }, "id": 170, "options": { @@ -9443,7 +9601,7 @@ "h": 8, "w": 12, "x": 12, - "y": 112 + "y": 856 }, "id": 171, "options": { @@ -9537,7 +9695,7 @@ "h": 8, "w": 12, "x": 0, - "y": 488 + "y": 1256 }, "id": 162, "options": { @@ -9632,7 +9790,7 @@ "h": 8, "w": 12, "x": 12, - "y": 488 + "y": 1256 }, "id": 108, "options": { @@ -9727,7 +9885,7 @@ "h": 8, "w": 12, "x": 0, - "y": 496 + "y": 1264 }, "id": 169, "options": { @@ -9821,7 +9979,7 @@ "h": 8, "w": 12, "x": 12, - "y": 496 + "y": 1264 }, "id": 166, "options": { @@ -9915,7 +10073,7 @@ "h": 8, "w": 12, "x": 0, - "y": 504 + "y": 1272 }, "id": 157, "options": { @@ -10010,7 +10168,7 @@ "h": 8, "w": 12, "x": 12, - "y": 504 + "y": 1272 }, "id": 158, "options": { @@ -10104,7 +10262,7 @@ "h": 8, "w": 12, "x": 0, - "y": 512 + "y": 1280 }, "id": 167, "options": { @@ -10199,7 +10357,7 @@ "h": 8, "w": 12, "x": 12, - "y": 512 + "y": 1280 }, "id": 168, "options": { @@ -10293,7 +10451,7 @@ "h": 8, "w": 12, "x": 0, - "y": 520 + "y": 1288 }, "id": 137, "options": { @@ -10388,7 +10546,7 @@ "h": 8, "w": 12, "x": 12, - "y": 520 + "y": 1288 }, "id": 183, "options": { @@ -10483,7 +10641,7 @@ "h": 8, "w": 12, "x": 0, - "y": 528 + "y": 1296 }, "id": 241, "options": { @@ -10578,7 +10736,7 @@ "h": 8, "w": 12, "x": 12, - "y": 528 + "y": 1296 }, "id": 242, "options": { @@ -10673,7 +10831,7 @@ "h": 8, "w": 12, "x": 0, - "y": 536 + "y": 1304 }, "id": 243, "options": { @@ -10768,7 +10926,7 @@ "h": 8, "w": 12, "x": 12, - "y": 536 + "y": 1304 }, "id": 244, "options": { @@ -10863,7 +11021,7 @@ "h": 8, "w": 12, "x": 0, - "y": 544 + "y": 1312 }, "id": 245, "options": { @@ -10958,7 +11116,7 @@ "h": 8, "w": 12, "x": 12, - "y": 544 + "y": 1312 }, "id": 246, "options": { @@ -11053,7 +11211,7 @@ "h": 8, "w": 12, "x": 0, - "y": 552 + "y": 1320 }, "id": 247, "options": { @@ -11148,7 +11306,7 @@ "h": 8, "w": 12, "x": 12, - "y": 552 + "y": 1320 }, "id": 248, "options": { @@ -11187,7 +11345,7 @@ "h": 1, "w": 24, "x": 0, - "y": 32 + "y": 48 }, "id": 195, "panels": [ @@ -11256,7 +11414,7 @@ "h": 8, "w": 12, "x": 0, - "y": 113 + "y": 81 }, "id": 161, "options": { @@ -11350,7 +11508,7 @@ "h": 8, "w": 12, "x": 12, - "y": 113 + "y": 81 }, "id": 104, "options": { @@ -11445,7 +11603,7 @@ "h": 8, "w": 12, "x": 0, - "y": 377 + "y": 89 }, "id": 105, "options": { @@ -11539,7 +11697,7 @@ "h": 8, "w": 12, "x": 12, - "y": 377 + "y": 89 }, "id": 164, "options": { @@ -11633,7 +11791,7 @@ "h": 8, "w": 12, "x": 0, - "y": 385 + "y": 97 }, "id": 163, "options": { @@ -11728,7 +11886,7 @@ "h": 8, "w": 12, "x": 12, - "y": 385 + "y": 97 }, "id": 165, "options": { @@ -11823,7 +11981,7 @@ "h": 8, "w": 12, "x": 0, - "y": 393 + "y": 105 }, "id": 223, "options": { @@ -11862,7 +12020,7 @@ "h": 1, "w": 24, "x": 0, - "y": 33 + "y": 49 }, "id": 210, "panels": [ @@ -11932,7 +12090,7 @@ "h": 8, "w": 12, "x": 0, - "y": 587 + "y": 858 }, "id": 211, "options": { @@ -12027,7 +12185,7 @@ "h": 8, "w": 12, "x": 12, - "y": 587 + "y": 858 }, "id": 212, "options": { @@ -12122,7 +12280,7 @@ "h": 8, "w": 12, "x": 0, - "y": 595 + "y": 938 }, "id": 213, "options": { @@ -12217,7 +12375,7 @@ "h": 8, "w": 12, "x": 12, - "y": 595 + "y": 938 }, "id": 214, "options": { @@ -12312,7 +12470,7 @@ "h": 8, "w": 12, "x": 0, - "y": 603 + "y": 946 }, "id": 215, "options": { @@ -12407,7 +12565,7 @@ "h": 8, "w": 12, "x": 12, - "y": 603 + "y": 946 }, "id": 216, "options": { @@ -12502,7 +12660,7 @@ "h": 8, "w": 12, "x": 0, - "y": 611 + "y": 954 }, "id": 217, "options": { @@ -12597,7 +12755,7 @@ "h": 8, "w": 12, "x": 12, - "y": 611 + "y": 954 }, "id": 218, "options": { @@ -12636,7 +12794,7 @@ "h": 1, "w": 24, "x": 0, - "y": 34 + "y": 50 }, "id": 230, "panels": [ @@ -12706,7 +12864,7 @@ "h": 8, "w": 12, "x": 0, - "y": 324 + "y": 3700 }, "id": 231, "options": { @@ -12800,7 +12958,7 @@ "h": 8, "w": 12, "x": 12, - "y": 324 + "y": 3700 }, "id": 178, "options": { @@ -12895,7 +13053,7 @@ "h": 8, "w": 12, "x": 0, - "y": 332 + "y": 3708 }, "id": 179, "options": { @@ -12989,7 +13147,7 @@ "h": 8, "w": 12, "x": 12, - "y": 332 + "y": 3708 }, "id": 156, "options": { @@ -13028,7 +13186,7 @@ "h": 1, "w": 24, "x": 0, - "y": 35 + "y": 51 }, "id": 250, "panels": [ @@ -13098,7 +13256,7 @@ "h": 8, "w": 12, "x": 0, - "y": 116 + "y": 3492 }, "id": 251, "options": { @@ -13193,7 +13351,7 @@ "h": 8, "w": 12, "x": 12, - "y": 116 + "y": 3492 }, "id": 252, "options": { @@ -13288,7 +13446,7 @@ "h": 8, "w": 12, "x": 0, - "y": 228 + "y": 3604 }, "id": 253, "options": { @@ -13383,7 +13541,7 @@ "h": 8, "w": 12, "x": 12, - "y": 228 + "y": 3604 }, "id": 254, "options": { @@ -13478,7 +13636,7 @@ "h": 8, "w": 12, "x": 0, - "y": 236 + "y": 3612 }, "id": 273, "options": { @@ -13517,7 +13675,7 @@ "h": 1, "w": 24, "x": 0, - "y": 36 + "y": 52 }, "id": 100, "panels": [ @@ -13586,7 +13744,7 @@ "h": 8, "w": 12, "x": 0, - "y": 37 + "y": 861 }, "id": 107, "options": { @@ -13681,7 +13839,7 @@ "h": 8, "w": 12, "x": 12, - "y": 37 + "y": 861 }, "id": 110, "options": { @@ -13776,7 +13934,7 @@ "h": 8, "w": 12, "x": 0, - "y": 45 + "y": 869 }, "id": 180, "options": { @@ -13870,7 +14028,7 @@ "h": 8, "w": 12, "x": 12, - "y": 45 + "y": 869 }, "id": 160, "options": { @@ -13964,7 +14122,7 @@ "h": 8, "w": 12, "x": 0, - "y": 53 + "y": 877 }, "id": 139, "options": { @@ -14058,7 +14216,7 @@ "h": 8, "w": 12, "x": 12, - "y": 53 + "y": 877 }, "id": 176, "options": { @@ -14152,7 +14310,7 @@ "h": 8, "w": 12, "x": 0, - "y": 61 + "y": 885 }, "id": 133, "options": { @@ -14247,7 +14405,7 @@ "h": 8, "w": 12, "x": 12, - "y": 61 + "y": 885 }, "id": 221, "options": { @@ -14341,7 +14499,7 @@ "h": 8, "w": 12, "x": 0, - "y": 69 + "y": 893 }, "id": 177, "options": { @@ -14436,7 +14594,7 @@ "h": 8, "w": 12, "x": 12, - "y": 69 + "y": 893 }, "id": 271, "options": { @@ -14531,7 +14689,7 @@ "h": 8, "w": 12, "x": 0, - "y": 77 + "y": 901 }, "id": 274, "options": { @@ -14626,7 +14784,7 @@ "h": 8, "w": 12, "x": 12, - "y": 77 + "y": 901 }, "id": 272, "options": { @@ -14721,7 +14879,7 @@ "h": 8, "w": 12, "x": 0, - "y": 85 + "y": 909 }, "id": 232, "options": { @@ -14816,7 +14974,7 @@ "h": 8, "w": 12, "x": 12, - "y": 85 + "y": 909 }, "id": 233, "options": { @@ -14911,7 +15069,7 @@ "h": 8, "w": 12, "x": 0, - "y": 93 + "y": 917 }, "id": 234, "options": { @@ -15006,7 +15164,7 @@ "h": 8, "w": 12, "x": 12, - "y": 93 + "y": 917 }, "id": 235, "options": { @@ -15101,7 +15259,7 @@ "h": 8, "w": 12, "x": 0, - "y": 101 + "y": 925 }, "id": 222, "options": { @@ -15150,6 +15308,6 @@ "timezone": "browser", "title": "CryptoSim", "uid": "adnqfm4", - "version": 25, + "version": 29, "weekStart": "" } \ No newline at end of file From 13865432478b406629c5226fafe316666612c21f Mon Sep 17 00:00:00 2001 From: Cody Littley Date: Wed, 4 Mar 2026 14:47:56 -0600 Subject: [PATCH 2/6] Handle block creation on background goroutine. --- .../bench/cryptosim/config/basic-config.json | 3 +- sei-db/state_db/bench/cryptosim/cryptosim.go | 77 ++++++++++--------- .../bench/cryptosim/cryptosim_config.go | 4 + .../bench/cryptosim/cryptosim_metrics.go | 11 +-- .../bench/cryptosim/data_generator.go | 6 +- sei-db/state_db/bench/cryptosim/database.go | 10 ++- 6 files changed, 56 insertions(+), 55 deletions(-) diff --git a/sei-db/state_db/bench/cryptosim/config/basic-config.json b/sei-db/state_db/bench/cryptosim/config/basic-config.json index dea1b2a229..26001cd944 100644 --- a/sei-db/state_db/bench/cryptosim/config/basic-config.json +++ b/sei-db/state_db/bench/cryptosim/config/basic-config.json @@ -29,5 +29,6 @@ "TransactionsPerBlock": 1024, "MaxRuntimeSeconds": 0, "TransactionMetricsSampleRate": 0.001, - "BackgroundMetricsScrapeInterval": 60 + "BackgroundMetricsScrapeInterval": 60, + "BlockChannelCapacity": 8 } diff --git a/sei-db/state_db/bench/cryptosim/cryptosim.go b/sei-db/state_db/bench/cryptosim/cryptosim.go index 04fc441b1a..1468332aa9 100644 --- a/sei-db/state_db/bench/cryptosim/cryptosim.go +++ b/sei-db/state_db/bench/cryptosim/cryptosim.go @@ -48,6 +48,9 @@ type CryptoSim struct { // The data generator for the benchmark. dataGenerator *DataGenerator + // Builds blocks of transactions. + blockBuilder *blockBuilder + // The database for the benchmark. database *Database @@ -142,6 +145,8 @@ func NewCryptoSim( ctx, cancel, database, dataGenerator.FeeCollectionAddress(), config.ExecutorQueueSize, metrics) } + blockBuilder := NewBlockBuilder(ctx, config, metrics, dataGenerator) + c := &CryptoSim{ ctx: ctx, cancel: cancel, @@ -151,6 +156,7 @@ func NewCryptoSim( lastConsoleUpdateTransactionCount: 0, closeChan: make(chan struct{}, 1), dataGenerator: dataGenerator, + blockBuilder: blockBuilder, database: database, executors: executors, metrics: metrics, @@ -166,7 +172,10 @@ func NewCryptoSim( c.database.ResetTransactionCount() c.startTimestamp = time.Now() - c.metrics.StartBackgroundSampling(c.startTimestamp) + + // Now that we are done generating initial data, it is thread safe to start the block builder. + // (dataGenerator is not thread safe, and is used both for initial setup and for transaction generation) + c.blockBuilder.Start() go c.run() return c, nil @@ -210,7 +219,7 @@ func (c *CryptoSim) setupAccounts() error { if err != nil { return fmt.Errorf("failed to create new account: %w", err) } - c.database.IncrementTransactionCount() + c.database.IncrementTransactionCount(1) finalized, err := c.database.MaybeFinalizeBlock( c.dataGenerator.NextAccountID(), c.dataGenerator.NextErc20ContractID()) if err != nil { @@ -218,7 +227,7 @@ func (c *CryptoSim) setupAccounts() error { } if finalized { c.dataGenerator.ReportAccountCounts() - c.dataGenerator.ReportFinalizeBlock() + c.dataGenerator.ReportEndOfBlock() } if c.dataGenerator.NextAccountID()%c.config.SetupUpdateIntervalCount == 0 { @@ -237,7 +246,7 @@ func (c *CryptoSim) setupAccounts() error { return fmt.Errorf("failed to finalize block: %w", err) } c.dataGenerator.ReportAccountCounts() - c.dataGenerator.ReportFinalizeBlock() + c.dataGenerator.ReportEndOfBlock() fmt.Printf("There are now %s accounts in the database.\n", int64Commas(c.dataGenerator.NextAccountID())) @@ -267,7 +276,7 @@ func (c *CryptoSim) setupErc20Contracts() error { break } - c.database.IncrementTransactionCount() + c.database.IncrementTransactionCount(1) _, _, err := c.dataGenerator.CreateNewErc20Contract(c.config.Erc20ContractSize, true) if err != nil { @@ -279,7 +288,7 @@ func (c *CryptoSim) setupErc20Contracts() error { return fmt.Errorf("failed to maybe commit batch: %w", err) } if finalized { - c.dataGenerator.ReportFinalizeBlock() + c.dataGenerator.ReportEndOfBlock() c.metrics.SetTotalNumberOfERC20Contracts(c.dataGenerator.NextErc20ContractID()) } @@ -301,7 +310,7 @@ func (c *CryptoSim) setupErc20Contracts() error { if err != nil { return fmt.Errorf("failed to finalize block: %w", err) } - c.dataGenerator.ReportFinalizeBlock() + c.dataGenerator.ReportEndOfBlock() c.metrics.SetTotalNumberOfERC20Contracts(c.dataGenerator.NextErc20ContractID()) fmt.Printf("There are now %s simulated ERC20 contracts in the database.\n", @@ -316,10 +325,14 @@ func (c *CryptoSim) run() { defer c.teardown() haltTime := time.Now().Add(time.Duration(c.config.MaxRuntimeSeconds) * time.Second) - - c.metrics.SetMainThreadPhase("executing") + var timeoutChan <-chan time.Time + if c.config.MaxRuntimeSeconds > 0 { + timeoutChan = time.After(time.Until(haltTime)) + } for { + c.metrics.SetMainThreadPhase("get_block") + select { case <-c.ctx.Done(): if c.database.TransactionCount() > 0 { @@ -331,42 +344,31 @@ func (c *CryptoSim) run() { if isSuspended { c.suspend() } - default: - c.handleNextCycle(haltTime) + case <-timeoutChan: + fmt.Printf("\nBenchmark timed out after %s.\n", formatDuration(time.Since(c.startTimestamp), 1)) + c.cancel() + return + case blk := <-c.blockBuilder.blocksChan: + c.handleNextBlock(blk) } - } -} -// Process the next benchmark cycle, creating a new transaction and executing it. -func (c *CryptoSim) handleNextCycle(haltTime time.Time) { - txn, err := BuildTransaction(c.dataGenerator) - if err != nil { - fmt.Printf("\nfailed to build transaction: %v\n", err) - c.cancel() - return + c.generateConsoleReport(false) } +} - c.executors[c.nextExecutorIndex].ScheduleForExecution(txn) - c.nextExecutorIndex = (c.nextExecutorIndex + 1) % len(c.executors) +// Execute and finalize the next block. +func (c *CryptoSim) handleNextBlock(blk *block) { + c.metrics.SetMainThreadPhase("send_to_executors") - finalized, err := c.database.MaybeFinalizeBlock( - c.dataGenerator.NextAccountID(), c.dataGenerator.NextErc20ContractID()) - if err != nil { - fmt.Printf("error finalizing block: %v\n", err) - c.cancel() - return - } - if finalized { - c.dataGenerator.ReportAccountCounts() - c.dataGenerator.ReportFinalizeBlock() + c.database.IncrementTransactionCount(blk.TransactionCount()) - if c.config.MaxRuntimeSeconds > 0 && time.Now().After(haltTime) { - c.cancel() - } + for _, txn := range blk.transactions { + c.executors[c.nextExecutorIndex].ScheduleForExecution(txn) + c.nextExecutorIndex = (c.nextExecutorIndex + 1) % len(c.executors) } - c.database.IncrementTransactionCount() - c.generateConsoleReport(false) + c.database.FinalizeBlock(blk.NextAccountID(), blk.NextErc20ContractID(), false) + blk.ReportBlockMetrcs() } // Suspends the benchmark. This method blocks until the benchmark is resumed or shut down. @@ -380,6 +382,7 @@ func (c *CryptoSim) suspend() { } fmt.Printf("Benchmark suspended.\n") + c.metrics.SetMainThreadPhase("suspended") for { select { diff --git a/sei-db/state_db/bench/cryptosim/cryptosim_config.go b/sei-db/state_db/bench/cryptosim/cryptosim_config.go index a33e5a42ff..c6e368b0cb 100644 --- a/sei-db/state_db/bench/cryptosim/cryptosim_config.go +++ b/sei-db/state_db/bench/cryptosim/cryptosim_config.go @@ -132,6 +132,9 @@ type CryptoSimConfig struct { // If true, pressing Enter in the terminal will toggle suspend/resume of the benchmark. // If false, Enter has no effect. EnableSuspension bool + + // The capacity of the channel that holds blocks awaiting execution. + BlockChannelCapacity int } // Returns the default configuration for the cryptosim benchmark. @@ -170,6 +173,7 @@ func DefaultCryptoSimConfig() *CryptoSimConfig { TransactionMetricsSampleRate: 0.001, BackgroundMetricsScrapeInterval: 60, EnableSuspension: true, + BlockChannelCapacity: 8, } } diff --git a/sei-db/state_db/bench/cryptosim/cryptosim_metrics.go b/sei-db/state_db/bench/cryptosim/cryptosim_metrics.go index a25ac9ebc6..c5b16408b8 100644 --- a/sei-db/state_db/bench/cryptosim/cryptosim_metrics.go +++ b/sei-db/state_db/bench/cryptosim/cryptosim_metrics.go @@ -172,20 +172,11 @@ func NewCryptosimMetrics( m.startDataDirSizeSampling(dataDir, config.BackgroundMetricsScrapeInterval) } m.startProcessIOSampling(config.BackgroundMetricsScrapeInterval) + m.startUptimeSampling(time.Now()) } return m } -// StartBackgroundSampling starts goroutines that periodically update gauges -// (uptime, etc.). Call this when the benchmark is about to run, after initial -// state is loaded. Does not start any HTTP server; the caller configures export. -func (m *CryptosimMetrics) StartBackgroundSampling(startTime time.Time) { - if m == nil { - return - } - m.startUptimeSampling(startTime) -} - func (m *CryptosimMetrics) startUptimeSampling(startTime time.Time) { if m == nil || m.uptimeSeconds == nil { return diff --git a/sei-db/state_db/bench/cryptosim/data_generator.go b/sei-db/state_db/bench/cryptosim/data_generator.go index 5920366814..8347d6bd2d 100644 --- a/sei-db/state_db/bench/cryptosim/data_generator.go +++ b/sei-db/state_db/bench/cryptosim/data_generator.go @@ -138,7 +138,6 @@ func (d *DataGenerator) CreateNewAccount( accountID := d.nextAccountID d.nextAccountID++ - // Use EVMKeyCode for account data (balance+padding); EVMKeyNonce only accepts 8-byte values. addr := d.rand.Address(accountPrefix, accountID, AddressLen) address = evm.BuildMemIAVLEVMKey(evm.EVMKeyCode, addr) @@ -289,7 +288,8 @@ func (d *DataGenerator) FeeCollectionAddress() []byte { return d.feeCollectionAddress } -// This method should be called after a block is finalized. -func (d *DataGenerator) ReportFinalizeBlock() { +// Call this to signal that we have reached the end of a block. This is a signal that it is now safe to use +// recently created accounts as read/write targets. +func (d *DataGenerator) ReportEndOfBlock() { d.highestSafeAccountIDInBlock = d.nextAccountID - 1 } diff --git a/sei-db/state_db/bench/cryptosim/database.go b/sei-db/state_db/bench/cryptosim/database.go index 2b723fbdbc..25b3888dda 100644 --- a/sei-db/state_db/bench/cryptosim/database.go +++ b/sei-db/state_db/bench/cryptosim/database.go @@ -80,10 +80,10 @@ func (d *Database) Get(key []byte) ([]byte, bool, error) { return nil, false, nil } -// Signal that a transaction has been executed. -func (d *Database) IncrementTransactionCount() { - d.transactionCount++ - d.transactionsInCurrentBlock++ +// Signal that transactions have been added to the current block. +func (d *Database) IncrementTransactionCount(count int64) { + d.transactionCount += count + d.transactionsInCurrentBlock += count } // Reset the transaction count. Useful for when changing test phases. @@ -120,6 +120,8 @@ func (d *Database) FinalizeBlock( forceCommit bool, ) error { + d.metrics.SetMainThreadPhase("execute_block") + // Wait for all transactions in the current block to be executed. if d.flushFunc != nil { d.flushFunc() From 8ecfba52ac466118524ef0e4280ebb8ff11213a5 Mon Sep 17 00:00:00 2001 From: Cody Littley Date: Wed, 4 Mar 2026 15:10:19 -0600 Subject: [PATCH 3/6] added missing files --- sei-db/state_db/bench/cryptosim/block.go | 94 +++++++++++++++++++ .../state_db/bench/cryptosim/block_builder.go | 82 ++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 sei-db/state_db/bench/cryptosim/block.go create mode 100644 sei-db/state_db/bench/cryptosim/block_builder.go diff --git a/sei-db/state_db/bench/cryptosim/block.go b/sei-db/state_db/bench/cryptosim/block.go new file mode 100644 index 0000000000..2963389db2 --- /dev/null +++ b/sei-db/state_db/bench/cryptosim/block.go @@ -0,0 +1,94 @@ +package cryptosim + +import "iter" + +// A simulated block of transactions. +type block struct { + config *CryptoSimConfig + + // The transactions in the block. + transactions []*transaction + + // The block number. This is not currently preserved across benchmark restarts, but otherwise monotonically + // increases as you'd expect. + blockNumber int64 + + // The next account ID to be used when creating a new account, as of the end of this block. + nextAccountID int64 + + // The number of cold accounts, as of the end of this block. + numberOfColdAccounts int64 + + // The next ERC20 contract ID to be used when creating a new ERC20 contract, as of the end of this block. + nextErc20ContractID int64 + + metrics *CryptosimMetrics +} + +// Creates a new block with the given capacity. +func NewBlock( + config *CryptoSimConfig, + metrics *CryptosimMetrics, + blockNumber int64, + capacity int, +) *block { + return &block{ + config: config, + blockNumber: blockNumber, + transactions: make([]*transaction, 0, capacity), + metrics: metrics, + } +} + +// Returns an iterator over the transactions in the block. +func (b *block) Iterator() iter.Seq[*transaction] { + return func(yield func(*transaction) bool) { + for _, txn := range b.transactions { + if !yield(txn) { + return + } + } + } +} + +// Adds a transaction to the block. +func (b *block) AddTransaction(txn *transaction) { + b.transactions = append(b.transactions, txn) +} + +// Returns the block number. +func (b *block) BlockNumber() int64 { + return b.blockNumber +} + +// Sets information about account state as of the end of this block. +func (b *block) SetBlockAccountStats( + nextAccountID int64, + numberOfColdAccounts int64, + nextErc20ContractID int64, +) { + b.nextAccountID = nextAccountID + b.numberOfColdAccounts = numberOfColdAccounts + b.nextErc20ContractID = nextErc20ContractID +} + +// This method should be called after a block is finished executing and finalized. +// Reports metrics about the block. +func (b *block) ReportBlockMetrcs() { + b.metrics.SetTotalNumberOfAccounts(b.nextAccountID, int64(b.config.NumberOfHotAccounts), b.numberOfColdAccounts) +} + +// Returns the next account ID to be used when creating a new account, as of the end of this block. +func (b *block) NextAccountID() int64 { + return b.nextAccountID +} + +// Returns the next ERC20 contract ID to be used when creating a new ERC20 contract, as of the end of this block. +func (b *block) NextErc20ContractID() int64 { + return b.nextErc20ContractID +} + +// Returns the number of transactions in the block. +func (b *block) TransactionCount() int64 { + return int64(len(b.transactions)) +} diff --git a/sei-db/state_db/bench/cryptosim/block_builder.go b/sei-db/state_db/bench/cryptosim/block_builder.go new file mode 100644 index 0000000000..eb36b5d281 --- /dev/null +++ b/sei-db/state_db/bench/cryptosim/block_builder.go @@ -0,0 +1,82 @@ +package cryptosim + +import ( + "context" + "fmt" +) + +// A builder for blocks of transactions. +type blockBuilder struct { + ctx context.Context + + config *CryptoSimConfig + + // Metrics for the benchmark. + metrics *CryptosimMetrics + + // Produces random data. + dataGenerator *DataGenerator + + // Blocks are sent to this channel. + blocksChan chan *block + + // The next block number to be used. + nextBlockNumber int64 +} + +// Asyncronously produces blocks of transactions. +func NewBlockBuilder( + ctx context.Context, + config *CryptoSimConfig, + metrics *CryptosimMetrics, + dataGenerator *DataGenerator, +) *blockBuilder { + return &blockBuilder{ + ctx: ctx, + config: config, + metrics: metrics, + dataGenerator: dataGenerator, + blocksChan: make(chan *block, config.BlockChannelCapacity), + } +} + +// Starts the block builder. This should not be called until all other threads are done using the data generator, +// as the data generator is not thread-safe. +func (b *blockBuilder) Start() { + go b.mainLoop() +} + +// Builds blocks and sends them to the blocks channel. +func (b *blockBuilder) mainLoop() { + for { + block := b.buildBlock() + select { + case <-b.ctx.Done(): + return + case b.blocksChan <- block: + } + } +} + +func (b *blockBuilder) buildBlock() *block { + blk := NewBlock(b.config, b.metrics, b.nextBlockNumber, b.config.TransactionsPerBlock) + b.nextBlockNumber++ + + for i := 0; i < b.config.TransactionsPerBlock; i++ { + txn, err := BuildTransaction(b.dataGenerator) + if err != nil { + fmt.Printf("failed to build transaction: %v\n", err) + continue + } + blk.AddTransaction(txn) + } + + blk.SetBlockAccountStats( + b.dataGenerator.NextAccountID(), + b.dataGenerator.NumberOfColdAccounts(), + b.dataGenerator.NextErc20ContractID()) + + b.dataGenerator.ReportEndOfBlock() + + return blk +} From 8938c6de599494283aa7ec563182c6924bd98431 Mon Sep 17 00:00:00 2001 From: Cody Littley Date: Wed, 4 Mar 2026 15:14:43 -0600 Subject: [PATCH 4/6] adjust executor queue size Signed-off-by: Cody Littley --- sei-db/state_db/bench/cryptosim/config/basic-config.json | 2 +- sei-db/state_db/bench/cryptosim/cryptosim_config.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sei-db/state_db/bench/cryptosim/config/basic-config.json b/sei-db/state_db/bench/cryptosim/config/basic-config.json index 26001cd944..53cdf98724 100644 --- a/sei-db/state_db/bench/cryptosim/config/basic-config.json +++ b/sei-db/state_db/bench/cryptosim/config/basic-config.json @@ -11,7 +11,7 @@ "Erc20ContractSize": 2048, "Erc20InteractionsPerAccount": 10, "Erc20StorageSlotSize": 32, - "ExecutorQueueSize": 64, + "ExecutorQueueSize": 1024, "HotAccountProbability": 0.1, "HotErc20ContractProbability": 0.5, "HotErc20ContractSetSize": 100, diff --git a/sei-db/state_db/bench/cryptosim/cryptosim_config.go b/sei-db/state_db/bench/cryptosim/cryptosim_config.go index c6e368b0cb..cb2451f0ec 100644 --- a/sei-db/state_db/bench/cryptosim/cryptosim_config.go +++ b/sei-db/state_db/bench/cryptosim/cryptosim_config.go @@ -167,7 +167,7 @@ func DefaultCryptoSimConfig() *CryptoSimConfig { SetupUpdateIntervalCount: 100_000, ThreadsPerCore: 2.0, ConstantThreadCount: 0, - ExecutorQueueSize: 64, + ExecutorQueueSize: 1024, MaxRuntimeSeconds: 0, MetricsAddr: ":9090", TransactionMetricsSampleRate: 0.001, From a7d0c5419a7c62eb36e99dac2521772ca06170dd Mon Sep 17 00:00:00 2001 From: Cody Littley Date: Thu, 5 Mar 2026 11:33:07 -0600 Subject: [PATCH 5/6] lint --- sei-db/state_db/bench/cryptosim/cryptosim.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sei-db/state_db/bench/cryptosim/cryptosim.go b/sei-db/state_db/bench/cryptosim/cryptosim.go index 1468332aa9..6e9cb41018 100644 --- a/sei-db/state_db/bench/cryptosim/cryptosim.go +++ b/sei-db/state_db/bench/cryptosim/cryptosim.go @@ -367,7 +367,11 @@ func (c *CryptoSim) handleNextBlock(blk *block) { c.nextExecutorIndex = (c.nextExecutorIndex + 1) % len(c.executors) } - c.database.FinalizeBlock(blk.NextAccountID(), blk.NextErc20ContractID(), false) + if err := c.database.FinalizeBlock(blk.NextAccountID(), blk.NextErc20ContractID(), false); err != nil { + fmt.Printf("failed to finalize block: %v\n", err) + c.cancel() + return + } blk.ReportBlockMetrcs() } From 86743304bbe748bffa2e1dd1c3d75f51a026507d Mon Sep 17 00:00:00 2001 From: Cody Littley Date: Fri, 6 Mar 2026 08:58:10 -0600 Subject: [PATCH 6/6] made suggested changes --- sei-db/state_db/bench/cryptosim/block.go | 2 +- sei-db/state_db/bench/cryptosim/cryptosim.go | 40 ++++++++++++++----- .../bench/cryptosim/cryptosim_config.go | 3 ++ sei-db/state_db/bench/cryptosim/database.go | 11 +++++ 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/sei-db/state_db/bench/cryptosim/block.go b/sei-db/state_db/bench/cryptosim/block.go index 2963389db2..a7833f957d 100644 --- a/sei-db/state_db/bench/cryptosim/block.go +++ b/sei-db/state_db/bench/cryptosim/block.go @@ -74,7 +74,7 @@ func (b *block) SetBlockAccountStats( // This method should be called after a block is finished executing and finalized. // Reports metrics about the block. -func (b *block) ReportBlockMetrcs() { +func (b *block) ReportBlockMetrics() { b.metrics.SetTotalNumberOfAccounts(b.nextAccountID, int64(b.config.NumberOfHotAccounts), b.numberOfColdAccounts) } diff --git a/sei-db/state_db/bench/cryptosim/cryptosim.go b/sei-db/state_db/bench/cryptosim/cryptosim.go index 6e9cb41018..94fdd02d3a 100644 --- a/sei-db/state_db/bench/cryptosim/cryptosim.go +++ b/sei-db/state_db/bench/cryptosim/cryptosim.go @@ -67,6 +67,14 @@ type CryptoSim struct { // benchmark, sending "false" will resume it. Suspending an already suspended benchmark will have no effect, // and resuming an already resumed benchmark will likewise have no effect. suspendChan chan bool + + // The most recent block that has been processed. + mostRecentBlock *block + + // The next ERC20 contract ID to be used when creating a new ERC20 contract. + // This is fixed after initial setup is complete, since we don't currently simulate + // the creation of new ERC20 contracts during the benchmark. + nextERC20ContractID int64 } // Creates a new cryptosim benchmark runner. @@ -316,6 +324,8 @@ func (c *CryptoSim) setupErc20Contracts() error { fmt.Printf("There are now %s simulated ERC20 contracts in the database.\n", int64Commas(c.dataGenerator.NextErc20ContractID())) + c.nextERC20ContractID = c.dataGenerator.NextErc20ContractID() + return nil } @@ -358,11 +368,12 @@ func (c *CryptoSim) run() { // Execute and finalize the next block. func (c *CryptoSim) handleNextBlock(blk *block) { + c.mostRecentBlock = blk c.metrics.SetMainThreadPhase("send_to_executors") c.database.IncrementTransactionCount(blk.TransactionCount()) - for _, txn := range blk.transactions { + for txn := range blk.Iterator() { c.executors[c.nextExecutorIndex].ScheduleForExecution(txn) c.nextExecutorIndex = (c.nextExecutorIndex + 1) % len(c.executors) } @@ -372,17 +383,19 @@ func (c *CryptoSim) handleNextBlock(blk *block) { c.cancel() return } - blk.ReportBlockMetrcs() + blk.ReportBlockMetrics() } // Suspends the benchmark. This method blocks until the benchmark is resumed or shut down. func (c *CryptoSim) suspend() { - err := c.database.FinalizeBlock(c.dataGenerator.NextAccountID(), c.dataGenerator.NextErc20ContractID(), true) - if err != nil { - fmt.Printf("failed to finalize block: %v\n", err) - c.cancel() - return + if c.mostRecentBlock != nil { + err := c.database.FinalizeBlock(c.mostRecentBlock.nextAccountID, c.nextERC20ContractID, true) + if err != nil { + fmt.Printf("failed to finalize block: %v\n", err) + c.cancel() + return + } } fmt.Printf("Benchmark suspended.\n") @@ -410,9 +423,16 @@ func (c *CryptoSim) suspend() { // Clean up the benchmark and release any resources. func (c *CryptoSim) teardown() { - err := c.database.Close(c.dataGenerator.NextAccountID(), c.dataGenerator.NextErc20ContractID()) - if err != nil { - fmt.Printf("failed to close database: %v\n", err) + if c.mostRecentBlock == nil { + err := c.database.CloseWithoutFinalizing() + if err != nil { + fmt.Printf("failed to close database: %v\n", err) + } + } else { + err := c.database.Close(c.mostRecentBlock.nextAccountID, c.nextERC20ContractID) + if err != nil { + fmt.Printf("failed to close database: %v\n", err) + } } c.dataGenerator.Close() diff --git a/sei-db/state_db/bench/cryptosim/cryptosim_config.go b/sei-db/state_db/bench/cryptosim/cryptosim_config.go index cb2451f0ec..a6434c269e 100644 --- a/sei-db/state_db/bench/cryptosim/cryptosim_config.go +++ b/sei-db/state_db/bench/cryptosim/cryptosim_config.go @@ -246,6 +246,9 @@ func (c *CryptoSimConfig) Validate() error { if c.BackgroundMetricsScrapeInterval < 0 { return fmt.Errorf("BackgroundMetricsScrapeInterval must be non-negative (got %d)", c.BackgroundMetricsScrapeInterval) } + if c.BlockChannelCapacity < 1 { + return fmt.Errorf("BlockChannelCapacity must be at least 1 (got %d)", c.BlockChannelCapacity) + } return nil } diff --git a/sei-db/state_db/bench/cryptosim/database.go b/sei-db/state_db/bench/cryptosim/database.go index 25b3888dda..21d9a48937 100644 --- a/sei-db/state_db/bench/cryptosim/database.go +++ b/sei-db/state_db/bench/cryptosim/database.go @@ -206,6 +206,17 @@ func (d *Database) Close(nextAccountID int64, nextErc20ContractID int64) error { return nil } +// Close the database and release any resources without finalizing the last batch. +func (d *Database) CloseWithoutFinalizing() error { + fmt.Printf("Closing database.\n") + err := d.db.Close() + if err != nil { + return fmt.Errorf("failed to close database: %w", err) + } + + return nil +} + // Set the function that flushes the executors. This setter is required to break a circular dependency. func (d *Database) SetFlushFunc(flushFunc func()) { d.flushFunc = flushFunc