-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Docs: Add debugging page and how to work with runtime/trace
#5134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,76 @@ | ||||||||||||||
| --- | ||||||||||||||
| title: Debugging | ||||||||||||||
| description: Investigating issues and profiling app performance | ||||||||||||||
| sidebar: | ||||||||||||||
| order: 3 | ||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
| import { Steps, Tabs, TabItem } from "@astrojs/starlight/components"; | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| We will demonstrate use of various tools to provide how to inspect and investigate possible performance issues within your Wails app using | ||||||||||||||
| - [`runtime/trace`](https://pkg.go.dev/runtime/trace) to create performance graphs and inspect them in a browser | ||||||||||||||
|
|
||||||||||||||
| ## Creating performance traces | ||||||||||||||
|
|
||||||||||||||
| <Steps> | ||||||||||||||
|
|
||||||||||||||
| 1. **Prepare your app for Tracing** | ||||||||||||||
|
|
||||||||||||||
| Close to your program entrypoint, ensure code along the following lines exists | ||||||||||||||
|
|
||||||||||||||
| ```go | ||||||||||||||
| // Create the file to store our trace data within | ||||||||||||||
| traceFile, err := os.Create("trace.out") | ||||||||||||||
| if err != nil { | ||||||||||||||
| log.Fatalf("trace.out could not be created: %v", err) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Start the trace | ||||||||||||||
| if err := trace.Start(traceFile); err != nil { | ||||||||||||||
| _ = traceFile.Close() | ||||||||||||||
| log.Fatalf("trace.start could not start: %v", err) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Trace cleanup on exit. Alternatively, | ||||||||||||||
| defer func() { | ||||||||||||||
| trace.Stop() | ||||||||||||||
| _ = traceFile.Close() | ||||||||||||||
| }() | ||||||||||||||
|
|
||||||||||||||
| ...Start your wails app here... | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| Output will be saved to `trace.out` within your working path with metrics covering the complete runtime of your app. The default trace is quite raw; you are well advised to do further reading on trace to add more contextual information and limit what you actually record. For example: `WithRegion, NewTask, Log` | ||||||||||||||
|
|
||||||||||||||
| 2. **Run your app to create the trace** | ||||||||||||||
|
|
||||||||||||||
| With your app running, a continuous trace will be produced up to the point of exit so go ahead and perform some actions in your app and exit when complete | ||||||||||||||
|
|
||||||||||||||
| 3. **Install Visualisation helpers** | ||||||||||||||
|
|
||||||||||||||
| Some views need [Graphviz](https://graphviz.org/). You can verify it is installed by running `dot -V` | ||||||||||||||
|
|
||||||||||||||
| ```bash | ||||||||||||||
| # macOS | ||||||||||||||
| brew install graphviz | ||||||||||||||
|
|
||||||||||||||
| # Ubuntu/Debian | ||||||||||||||
| sudo apt-get install graphviz | ||||||||||||||
|
|
||||||||||||||
| # Arch | ||||||||||||||
| sudo pacman -S graphviz | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| 4. **Visualize your trace** | ||||||||||||||
|
|
||||||||||||||
| With your trace data available, we can start up the web interface | ||||||||||||||
|
|
||||||||||||||
| ```bash | ||||||||||||||
| go tool trace trace.out | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| This should open up your default browser (recommended to use Chrome based) with the trace event viewer home page. | ||||||||||||||
|
|
||||||||||||||
| For first time users, the `Syscall profile` screen is probably the most useful. This provides a breakdown of exactly what the program is doing along with timings | ||||||||||||||
|
Comment on lines
+73
to
+75
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix hyphenation in user-facing prose. Use compound-word hyphenation on Line 73 and Line 75 for polished docs copy ( ✏️ Proposed copy edit-This should open up your default browser (recommended to use Chrome based) with the trace event viewer home page.
+This should open your default browser (a Chrome-based browser is recommended) with the trace event viewer home page.
-For first time users, the `Syscall profile` screen is probably the most useful.
+For first-time users, the `Syscall profile` screen is probably the most useful.📝 Committable suggestion
Suggested change
🧰 Tools🪛 LanguageTool[grammar] ~73-~73: Use a hyphen to join words. (QB_NEW_EN_HYPHEN) [grammar] ~75-~75: Use a hyphen to join words. (QB_NEW_EN_HYPHEN) 🤖 Prompt for AI Agents |
||||||||||||||
| </Steps> | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tighten the intro sentence for clarity.
Line 11 reads awkwardly (“provide how to inspect”). A small wording fix will improve readability.
✏️ Proposed wording tweak
📝 Committable suggestion
🤖 Prompt for AI Agents