sync.Workgroup: Don't use @func at runtime
It is true for any decorator, that it makes things faster if def+decorator is used globally instead of at runtime, but for @func it is especially true since @func, using decorator.decorate, has relatively high overhead if it is used not only once at program startup, but instead every time something is run. In particular moving @func out of WorkGroup.go() make things considerably faster: name old time/op new time/op delta workgroup_empty 195µs ± 0% 113µs ± 1% -41.91% (p=0.008 n=5+5) workgroup_raise 221µs ± 1% 137µs ± 1% -38.29% (p=0.008 n=5+5) See https://lab.nexedi.com/kirr/misc/raw/009c4fee/pygolang/prof_workgroup_empty.svg for bench_workgroup_empty profile, where it is seen that decorator.decorate was using ~ half of the whole WorkGroup.go() time.
Showing
Please register or sign in to comment