You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: performance-eval/performance-eval.md
+70-14Lines changed: 70 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -294,28 +294,84 @@ solution is, as root to run
294
294
295
295
Stellar-core has built-in support for Tracy traces.
296
296
297
-
To install the visualizer, follow the [build and install instructions](https://github.com/wolfpld/tracy) from the main Tracy site.
297
+
To install the visualizer, follow the directions in [INSTALL.md](../INSTALL.md).
298
298
299
-
At a high level you need to
299
+
### General Visual Studio profiler
300
300
301
-
install the required pre-requesites to build clients, run in a shell:
301
+
The main page for the profiler built into Visual Studio Community Edition is located there: https://docs.microsoft.com/en-us/visualstudio/profiling/index
Intel V-Tune (free, unlimited license 90 days renewal) https://software.intel.com/en-us/system-studio/choose-download
307
306
308
-
Solutions for servers compatible with the version of stellar-core can be found under:
307
+
# Memory-use profiling
309
308
310
-
* lib/tracy/profiler/build/win32 (GUI)
311
-
* lib/tracy/capture/build/win32
309
+
Tools for memory use profiling are less well-developed than CPU profiling, but there are some options available.
312
310
313
-
Note: when connecting, use `localhost` instead of `127.0.0.1` as Tracy binds by default to IPV6 addresses.
311
+
## Tracy
314
312
315
-
### General Visual Studio profiler
313
+
Tracy has some built-in support for memory profiling, but turning it on will
314
+
slow down core significantly and will use memory in the tracy client _very
315
+
quickly_, easily overwhelming your workstation if you're not careful. So you can
316
+
usually only turn it on for a brief period of time.
316
317
317
-
The main page for the profiler built into Visual Studio Community Edition is located there: https://docs.microsoft.com/en-us/visualstudio/profiling/index
318
+
It is most useful for examining a small part of the code for a short period of
319
+
time, where you already have a fairly good idea of there being memory allocation
320
+
issues that you want to see a precise accounting of. Allocations get linked to
321
+
zones (as a list in each zone detail view) and are available for inspection in
322
+
the "memory" window, along with a total map of memory and a list of all
323
+
allocations.
318
324
319
-
## All platforms
325
+
Stellar-core has support for this mode separate from normal tracy tracing,
326
+
because it is so performance intensive and memory hungry. You need to configure
327
+
with --enable-tracy-memory-tracking and --disable-tcmalloc.
328
+
329
+
## Heaptrack
330
+
331
+
A better option for a high level "profile" of memory is the "heaptrack" tool,
332
+
which is available on Linux.
333
+
334
+
$ sudo apt install heaptrack heaptrack-gui
335
+
336
+
To use it you will also need to configure with --disable-tcmalloc, because it
337
+
works by intercepting malloc/free calls underlying the default operator
338
+
new/delete, and tcmalloc's operator new and delete will bypass that
339
+
interception.
340
+
341
+
Heaptrack should also be run only for a moderate amount of time, otherwise the
342
+
recording will be huge. But it at least writes its recording to disk, and the
343
+
recording is much more compact than tracy's in-memory structure, so it can run
344
+
much longer than tracy in memory-recording mode without issue.
345
+
346
+
Heaptrack can run a program as a subprocess or attach remotely. The remote
347
+
attach mode allows you to avoid starting it until the program is close to the
348
+
period you want to measure, so is recommended. You will need to enable ptrace
349
+
permissions.
350
+
351
+
Heaptrack's default recording mode is very slow as it symbolicates all the
352
+
stacks while it runs. A better way is to record a _raw_ profile and then
353
+
symbolicate the data after the fact.
354
+
355
+
Combining these facts, the best execution we've found is like the following:
356
+
357
+
# in one terminal...
358
+
$ stellar-core ...
359
+
360
+
# in another terminal...
361
+
$ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
362
+
$ heaptrack --raw $(pidof stellar-core)
363
+
364
+
# switch back core and stop it with Ctrl-C when done
365
+
366
+
# heaptrack will exit and write a file like
367
+
# heaptrack.stellar-core.12345.raw.zst along with, hopefully, instructions
368
+
# to run something like this to post-process the raw file into a more
369
+
# compact and symbolicated form. This will run a long time:
0 commit comments