Skip to content

Commit f08421c

Browse files
committed
tracer: load the most expensive eBPF programs first
Signed-off-by: Alban Crequy <albancrequy@microsoft.com> Assisted-by: Claude Opus 5
1 parent 6dc0e5c commit f08421c

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tracer/tracer.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,21 @@ func loadPrograms(jobs []loadJob, bpfVerifierLogLevel uint32,
917917
}
918918
defer restoreRlimit()
919919

920+
// Start the most expensive programs first (longest-processing-time-first
921+
// scheduling). Load times are dominated by a few programs -- unwind_python
922+
// alone is ~30% of the total verification work -- so if one of those starts
923+
// late it keeps running after everything else has finished, and it, rather
924+
// than the total amount of work, determines how long this phase takes.
925+
//
926+
// The instruction count is only a coarse proxy for verifier cost: it ranks
927+
// unwind_python and unwind_native, the two dominant programs, correctly, but
928+
// it misranks cheaper ones (unwind_stop is large yet verifies quickly, while
929+
// go_labels is small yet verifies slowly). That is sufficient here, because
930+
// the schedule only depends on the expensive programs being started early.
931+
slices.SortStableFunc(jobs, func(a, b loadJob) int {
932+
return len(b.progSpec.Instructions) - len(a.progSpec.Instructions)
933+
})
934+
920935
eg := &errgroup.Group{}
921936
eg.SetLimit(min(runtime.GOMAXPROCS(0), len(jobs)))
922937
for i := range jobs {

0 commit comments

Comments
 (0)