|
| 1 | +# Introduction |
| 2 | +This repo provides a script which construct a visual call graph representation of a set of call stacks. It's currently optimized for SQL Server call stacks symbolized by [SQLCallStackResolver](https://aka.ms/SQLStack). Users can use these generated call graphs to visually understand the flow in the SQL Server functions being executed in their scenario. Call graphs can be especially useful to diagnose memory leaks. An example of such a visualized call graph for a memory leak case is shown below. The intuition behind using these call graphs is to follow the thicker connections in the graph - thick lines indicate high rate of calls of those functions. If there are equal or comparable calls to new() and free() - conceptually speaking - then you may conclude there's no leak; in this specific case, there's hardly any calls to free(); indicating a potential memory leak. |
| 3 | + |
| 4 | +<img src="images/call-graph-leak-sample.png" alt="Sample call graph for a memory leak scenario" style="width: 1280px"> |
| 5 | + |
| 6 | +# Usage |
| 7 | +First, ensure you have installed the pre-requisites. Then, just run export-callgraph-graphviz.py with the full path to the file containing the call stacks to be visualized. |
| 8 | + |
| 9 | +``` |
| 10 | +cd C:\SCSR-Graphs |
| 11 | +python .\src\export-callgraph-graphviz.py C:\temp\generate-series-leak-cu19.txt |
| 12 | +``` |
| 13 | +The script will output 2 files - a DOT file, which is in standard GraphViz format; and a SVG file which can be viewed in your browser, or in more specialized tools like [InkScape](https://inkscape.org). Here is a sample screenshot of the output files: |
| 14 | + |
| 15 | +<img src="images/output-files.png" alt="Output files" style="width: 400px"> |
| 16 | + |
1 | 17 | # Installation on Windows |
2 | 18 |
|
3 | 19 | * Clone this repo to `C:\SCSR-Graphs` |
4 | 20 |
|
5 | 21 | * Install [Python 3.13.5 for Windows](https://www.python.org/ftp/python/3.13.5/python-3.13.5-amd64.exe). Ensure the "Add Python to environmental variables" checkbox is selected. |
6 | 22 |
|
7 | | -  |
| 23 | +<img src="images/python-installer.png" alt="Python installation screen" style="width: 400px"> |
8 | 24 |
|
9 | 25 | * Download [GraphViz for Windows](https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/13.0.1/windows_10_cmake_Release_Graphviz-13.0.1-win64.zip) and extract it to a folder like `C:\GraphViz`. |
10 | 26 |
|
11 | | -  |
| 27 | +<img src="images/graphviz-folder.png" alt="Contents of GraphViz folder after extraction" style="width: 300px"> |
12 | 28 |
|
13 | 29 | * Add the GraphViz `bin` folder to the system PATH variable. |
14 | 30 |
|
|
18 | 34 |
|
19 | 35 | * Install [Visual C++ Build Tools](https://aka.ms/vs/17/release/vs_BuildTools.exe) and restart Windows if prompted to, at the end of the installation. |
20 | 36 |
|
21 | | -  |
| 37 | +<img src="images/vcbuildtools.png" alt="Visual C++ Build Tools installation screen" style="width: 600px"> |
22 | 38 |
|
23 | 39 | * Install PyGraphViz using pip by running the following command within a PowerShell window: |
24 | 40 |
|
@@ -68,13 +84,3 @@ Successfully installed networkx-3.5 pydot-4.0.1 pyparsing-3.2.3 |
68 | 84 |
|
69 | 85 | At this stage, you are ready to use the Python script! |
70 | 86 |
|
71 | | -# Running the Python script |
72 | | -Just run export-callgraph-graphviz.py with the full path to the file containing the call stacks to be visualized. |
73 | | - |
74 | | -``` |
75 | | -cd C:\SCSR-Graphs |
76 | | -python .\src\export-callgraph-graphviz.py C:\temp\generate-series-leak-cu19.txt |
77 | | -``` |
78 | | -The script will output 2 files - a DOT file, which is in standard GraphViz format; and a SVG file which can be viewed in your browser, or in more specialized tools like [InkScape](https://inkscape.org). Here is a sample screenshot of the output files: |
79 | | - |
80 | | -  |
|
0 commit comments