diff options
| -rw-r--r-- | integrationtests/cmd/ioworkload/scenario_unlink.go | 31 | ||||
| -rw-r--r-- | internal/flamegraph/nativesvg.go | 11 | ||||
| -rw-r--r-- | internal/tui/common/keys.go | 12 |
3 files changed, 30 insertions, 24 deletions
diff --git a/integrationtests/cmd/ioworkload/scenario_unlink.go b/integrationtests/cmd/ioworkload/scenario_unlink.go index e2cba6c..ea73b10 100644 --- a/integrationtests/cmd/ioworkload/scenario_unlink.go +++ b/integrationtests/cmd/ioworkload/scenario_unlink.go @@ -5,7 +5,6 @@ import ( "path/filepath" "runtime" "syscall" - "time" "unsafe" ) @@ -83,21 +82,23 @@ func unlinkRmdir() error { } defer cleanup() - subDir := filepath.Join(dir, "rmdir-me") - if err := syscall.Mkdir(subDir, 0o755); err != nil { - return fmt.Errorf("mkdir: %w", err) - } - // Give ior a brief attach window before the one-shot rmdir syscall. - time.Sleep(300 * time.Millisecond) + // Retry with fresh paths to avoid a single one-shot syscall that can race + // tracepoint attach during parallel integration test startup. + for i := 0; i < 5; i++ { + subDir := filepath.Join(dir, fmt.Sprintf("rmdir-me-%d", i)) + if err := syscall.Mkdir(subDir, 0o755); err != nil { + return fmt.Errorf("mkdir: %w", err) + } - pathBytes, err := syscall.BytePtrFromString(subDir) - if err != nil { - return fmt.Errorf("path bytes: %w", err) - } - _, _, errno := syscall.Syscall(syscall.SYS_RMDIR, uintptr(unsafe.Pointer(pathBytes)), 0, 0) - runtime.KeepAlive(pathBytes) - if errno != 0 { - return fmt.Errorf("rmdir: %w", errno) + pathBytes, err := syscall.BytePtrFromString(subDir) + if err != nil { + return fmt.Errorf("path bytes: %w", err) + } + _, _, errno := syscall.Syscall(syscall.SYS_RMDIR, uintptr(unsafe.Pointer(pathBytes)), 0, 0) + runtime.KeepAlive(pathBytes) + if errno != 0 { + return fmt.Errorf("rmdir: %w", errno) + } } return nil } diff --git a/internal/flamegraph/nativesvg.go b/internal/flamegraph/nativesvg.go index 26fc1e8..831ffed 100644 --- a/internal/flamegraph/nativesvg.go +++ b/internal/flamegraph/nativesvg.go @@ -3,10 +3,9 @@ package flamegraph import ( "fmt" "io" + "iter" "os" "strings" - - "iter" ) type NativeSVG struct { @@ -54,19 +53,21 @@ func (n NativeSVG) WriteSVGFromFile(iorDataFile string) (outFile string, err err func (n NativeSVG) WriteSVGFromIter(records iter.Seq[IterRecord], w io.Writer) error { tr := newTrie() + var framesBuf []string for record := range records { - frames, err := n.recordFrames(record) + frames, err := n.recordFrames(record, framesBuf) if err != nil { return err } + framesBuf = frames tr.add(frames, record.Cnt.ValueByName(n.countField)) } tr.computeTotals() return WriteSVG(w, tr, n.config) } -func (n NativeSVG) recordFrames(record IterRecord) ([]string, error) { - var frames []string +func (n NativeSVG) recordFrames(record IterRecord, framesBuf []string) ([]string, error) { + frames := framesBuf[:0] for _, fieldName := range n.fields { value, err := record.StringByName(fieldName) if err != nil { diff --git a/internal/tui/common/keys.go b/internal/tui/common/keys.go index 1111def..805a74a 100644 --- a/internal/tui/common/keys.go +++ b/internal/tui/common/keys.go @@ -65,10 +65,10 @@ func (k KeyMap) DashboardFullHelp() [][]key.Binding { {k.One, k.Two, k.Three, k.Four, k.Five, k.Six}, controls, { - key.NewBinding(key.WithKeys("left/right"), key.WithHelp("left/right", "tab")), - key.NewBinding(key.WithKeys("h/l"), key.WithHelp("h/l", "tab")), - key.NewBinding(key.WithKeys("j/k"), key.WithHelp("j/k", "scroll")), - key.NewBinding(key.WithKeys("up/down"), key.WithHelp("up/down", "scroll")), + helpTextBinding("left/right", "tab"), + helpTextBinding("h/l", "tab"), + helpTextBinding("j/k", "scroll"), + helpTextBinding("up/down", "scroll"), }, } } @@ -77,3 +77,7 @@ func (k KeyMap) DashboardFullHelp() [][]key.Binding { func (k KeyMap) PickerShortHelp() []key.Binding { return []key.Binding{k.Enter, k.Refresh, k.Esc} } + +func helpTextBinding(keyText, desc string) key.Binding { + return key.NewBinding(key.WithHelp(keyText, desc)) +} |
