Currently, optimize.go implements three types of optimizations. After these optimizations are applied, some functions may become redundant and can be removed.
For instance, consider the following optimization:
if ctx, skip := otel_trampoline_before(&arg); skip {
otel_trampoline_after(ctx, &retval)
return ...
} else {
;
...
}
=>
if false {
;
} else {
defer otel_trampoline_after(&HookContext{...}, &retval)
...
}
As a result of this transformation, the otel_trampoline_before function is no longer called, allowing us to remove its definition entirely.
In addition to this case, the other two optimizations can create similar opportunities for dead code elimination. This helps to reduce the final binary size and improve instruction cache performance.
Currently, optimize.go implements three types of optimizations. After these optimizations are applied, some functions may become redundant and can be removed.
For instance, consider the following optimization:
As a result of this transformation, the otel_trampoline_before function is no longer called, allowing us to remove its definition entirely.
In addition to this case, the other two optimizations can create similar opportunities for dead code elimination. This helps to reduce the final binary size and improve instruction cache performance.