github.com/zhonglinlynn/go-eth@v1.9.7/metrics/memory.md (about) 1 Memory usage 2 ============ 3 4 (Highly unscientific.) 5 6 Command used to gather static memory usage: 7 8 ```sh 9 grep ^Vm "/proc/$(ps fax | grep [m]etrics-bench | awk '{print $1}')/status" 10 ``` 11 12 Program used to gather baseline memory usage: 13 14 ```go 15 package main 16 17 import "time" 18 19 func main() { 20 time.Sleep(600e9) 21 } 22 ``` 23 24 Baseline 25 -------- 26 27 ``` 28 VmPeak: 42604 kB 29 VmSize: 42604 kB 30 VmLck: 0 kB 31 VmHWM: 1120 kB 32 VmRSS: 1120 kB 33 VmData: 35460 kB 34 VmStk: 136 kB 35 VmExe: 1020 kB 36 VmLib: 1848 kB 37 VmPTE: 36 kB 38 VmSwap: 0 kB 39 ``` 40 41 Program used to gather metric memory usage (with other metrics being similar): 42 43 ```go 44 package main 45 46 import ( 47 "fmt" 48 "metrics" 49 "time" 50 ) 51 52 func main() { 53 fmt.Sprintf("foo") 54 metrics.NewRegistry() 55 time.Sleep(600e9) 56 } 57 ``` 58 59 1000 counters registered 60 ------------------------ 61 62 ``` 63 VmPeak: 44016 kB 64 VmSize: 44016 kB 65 VmLck: 0 kB 66 VmHWM: 1928 kB 67 VmRSS: 1928 kB 68 VmData: 36868 kB 69 VmStk: 136 kB 70 VmExe: 1024 kB 71 VmLib: 1848 kB 72 VmPTE: 40 kB 73 VmSwap: 0 kB 74 ``` 75 76 **1.412 kB virtual, TODO 0.808 kB resident per counter.** 77 78 100000 counters registered 79 -------------------------- 80 81 ``` 82 VmPeak: 55024 kB 83 VmSize: 55024 kB 84 VmLck: 0 kB 85 VmHWM: 12440 kB 86 VmRSS: 12440 kB 87 VmData: 47876 kB 88 VmStk: 136 kB 89 VmExe: 1024 kB 90 VmLib: 1848 kB 91 VmPTE: 64 kB 92 VmSwap: 0 kB 93 ``` 94 95 **0.1242 kB virtual, 0.1132 kB resident per counter.** 96 97 1000 gauges registered 98 ---------------------- 99 100 ``` 101 VmPeak: 44012 kB 102 VmSize: 44012 kB 103 VmLck: 0 kB 104 VmHWM: 1928 kB 105 VmRSS: 1928 kB 106 VmData: 36868 kB 107 VmStk: 136 kB 108 VmExe: 1020 kB 109 VmLib: 1848 kB 110 VmPTE: 40 kB 111 VmSwap: 0 kB 112 ``` 113 114 **1.408 kB virtual, 0.808 kB resident per counter.** 115 116 100000 gauges registered 117 ------------------------ 118 119 ``` 120 VmPeak: 55020 kB 121 VmSize: 55020 kB 122 VmLck: 0 kB 123 VmHWM: 12432 kB 124 VmRSS: 12432 kB 125 VmData: 47876 kB 126 VmStk: 136 kB 127 VmExe: 1020 kB 128 VmLib: 1848 kB 129 VmPTE: 60 kB 130 VmSwap: 0 kB 131 ``` 132 133 **0.12416 kB virtual, 0.11312 resident per gauge.** 134 135 1000 histograms with a uniform sample size of 1028 136 -------------------------------------------------- 137 138 ``` 139 VmPeak: 72272 kB 140 VmSize: 72272 kB 141 VmLck: 0 kB 142 VmHWM: 16204 kB 143 VmRSS: 16204 kB 144 VmData: 65100 kB 145 VmStk: 136 kB 146 VmExe: 1048 kB 147 VmLib: 1848 kB 148 VmPTE: 80 kB 149 VmSwap: 0 kB 150 ``` 151 152 **29.668 kB virtual, TODO 15.084 resident per histogram.** 153 154 10000 histograms with a uniform sample size of 1028 155 --------------------------------------------------- 156 157 ``` 158 VmPeak: 256912 kB 159 VmSize: 256912 kB 160 VmLck: 0 kB 161 VmHWM: 146204 kB 162 VmRSS: 146204 kB 163 VmData: 249740 kB 164 VmStk: 136 kB 165 VmExe: 1048 kB 166 VmLib: 1848 kB 167 VmPTE: 448 kB 168 VmSwap: 0 kB 169 ``` 170 171 **21.4308 kB virtual, 14.5084 kB resident per histogram.** 172 173 50000 histograms with a uniform sample size of 1028 174 --------------------------------------------------- 175 176 ``` 177 VmPeak: 908112 kB 178 VmSize: 908112 kB 179 VmLck: 0 kB 180 VmHWM: 645832 kB 181 VmRSS: 645588 kB 182 VmData: 900940 kB 183 VmStk: 136 kB 184 VmExe: 1048 kB 185 VmLib: 1848 kB 186 VmPTE: 1716 kB 187 VmSwap: 1544 kB 188 ``` 189 190 **17.31016 kB virtual, 12.88936 kB resident per histogram.** 191 192 1000 histograms with an exponentially-decaying sample size of 1028 and alpha of 0.015 193 ------------------------------------------------------------------------------------- 194 195 ``` 196 VmPeak: 62480 kB 197 VmSize: 62480 kB 198 VmLck: 0 kB 199 VmHWM: 11572 kB 200 VmRSS: 11572 kB 201 VmData: 55308 kB 202 VmStk: 136 kB 203 VmExe: 1048 kB 204 VmLib: 1848 kB 205 VmPTE: 64 kB 206 VmSwap: 0 kB 207 ``` 208 209 **19.876 kB virtual, 10.452 kB resident per histogram.** 210 211 10000 histograms with an exponentially-decaying sample size of 1028 and alpha of 0.015 212 -------------------------------------------------------------------------------------- 213 214 ``` 215 VmPeak: 153296 kB 216 VmSize: 153296 kB 217 VmLck: 0 kB 218 VmHWM: 101176 kB 219 VmRSS: 101176 kB 220 VmData: 146124 kB 221 VmStk: 136 kB 222 VmExe: 1048 kB 223 VmLib: 1848 kB 224 VmPTE: 240 kB 225 VmSwap: 0 kB 226 ``` 227 228 **11.0692 kB virtual, 10.0056 kB resident per histogram.** 229 230 50000 histograms with an exponentially-decaying sample size of 1028 and alpha of 0.015 231 -------------------------------------------------------------------------------------- 232 233 ``` 234 VmPeak: 557264 kB 235 VmSize: 557264 kB 236 VmLck: 0 kB 237 VmHWM: 501056 kB 238 VmRSS: 501056 kB 239 VmData: 550092 kB 240 VmStk: 136 kB 241 VmExe: 1048 kB 242 VmLib: 1848 kB 243 VmPTE: 1032 kB 244 VmSwap: 0 kB 245 ``` 246 247 **10.2932 kB virtual, 9.99872 kB resident per histogram.** 248 249 1000 meters 250 ----------- 251 252 ``` 253 VmPeak: 74504 kB 254 VmSize: 74504 kB 255 VmLck: 0 kB 256 VmHWM: 24124 kB 257 VmRSS: 24124 kB 258 VmData: 67340 kB 259 VmStk: 136 kB 260 VmExe: 1040 kB 261 VmLib: 1848 kB 262 VmPTE: 92 kB 263 VmSwap: 0 kB 264 ``` 265 266 **31.9 kB virtual, 23.004 kB resident per meter.** 267 268 10000 meters 269 ------------ 270 271 ``` 272 VmPeak: 278920 kB 273 VmSize: 278920 kB 274 VmLck: 0 kB 275 VmHWM: 227300 kB 276 VmRSS: 227300 kB 277 VmData: 271756 kB 278 VmStk: 136 kB 279 VmExe: 1040 kB 280 VmLib: 1848 kB 281 VmPTE: 488 kB 282 VmSwap: 0 kB 283 ``` 284 285 **23.6316 kB virtual, 22.618 kB resident per meter.**