loading up the forgejo repo on tangled to test page performance
1//go:build go1.24
2
3// Copyright 2024 The Forgejo Authors. All rights reserved.
4// SPDX-License-Identifier: MIT
5
6package log
7
8import "unsafe"
9
10//go:linkname runtime_getProfLabel runtime/pprof.runtime_getProfLabel
11func runtime_getProfLabel() unsafe.Pointer //nolint
12
13// Struct definitions copied from: https://github.com/golang/go/blob/ca63101df47a4467bc80faa654fc19d68e583952/src/runtime/pprof/label.go
14type label struct {
15 key string
16 value string
17}
18
19type LabelSet struct {
20 list []label
21}
22
23type labelMap struct {
24 LabelSet
25}
26
27func getGoroutineLabels() map[string]string {
28 l := (*labelMap)(runtime_getProfLabel())
29 if l == nil {
30 return nil
31 }
32
33 m := make(map[string]string, len(l.list))
34 for _, label := range l.list {
35 m[label.key] = label.value
36 }
37 return m
38}