From fb6fb6ed7e5734bffbff0af8d67a177ee7640f39 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 2 Apr 2024 12:04:54 +0200 Subject: pkg/symbolizer: add Cache type When the same crash happens all over again, we repeatedly symbolize the same PCs. This is slow and blocks VM loop in the manager. Cache PCs we already symbolize, we are likely to symbolize them again. --- pkg/report/linux.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pkg/report/linux.go') diff --git a/pkg/report/linux.go b/pkg/report/linux.go index a1dafccfd..43f55d918 100644 --- a/pkg/report/linux.go +++ b/pkg/report/linux.go @@ -34,6 +34,7 @@ type linux struct { reportStartIgnores []*regexp.Regexp infoMessagesWithStack [][]byte eoi []byte + symbolizerCache symbolizer.Cache } func ctorLinux(cfg *config) (reporterImpl, []string, error) { @@ -399,13 +400,16 @@ func (ctx *linux) Symbolize(rep *Report) error { func (ctx *linux) symbolize(rep *Report) error { symb := symbolizer.NewSymbolizer(ctx.config.target) defer symb.Close() + symbFunc := func(bin string, pc uint64) ([]symbolizer.Frame, error) { + return ctx.symbolizerCache.Symbolize(symb.Symbolize, bin, pc) + } var symbolized []byte s := bufio.NewScanner(bytes.NewReader(rep.Report)) prefix := rep.reportPrefixLen for s.Scan() { line := append([]byte{}, s.Bytes()...) line = append(line, '\n') - newLine := symbolizeLine(symb.Symbolize, ctx.symbols, ctx.vmlinux, ctx.kernelBuildSrc, line) + newLine := symbolizeLine(symbFunc, ctx.symbols, ctx.vmlinux, ctx.kernelBuildSrc, line) if prefix > len(symbolized) { prefix += len(newLine) - len(line) } -- cgit mrf-deployment