Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid ...any allocs in debug logs in hot loops #563

Merged
merged 1 commit into from
Jul 6, 2022

Conversation

mvdan
Copy link
Member

@mvdan mvdan commented Jul 2, 2022

(see commit message)

These lines get executed for every identifier in every package in each
Go build, so one allocation per log.Printf call can quickly add up to
millions of allocations across a build.

Until https://go.dev/issue/53465 is fixed, the best way to avoid the
escaping due to `...any` is to not perform the function call at all.

	name      old time/op         new time/op         delta
	Build-16          10.5s ± 1%          10.5s ± 2%    ~     (p=0.604 n=9+10)

	name      old bin-B           new bin-B           delta
	Build-16          5.52M ± 0%          5.52M ± 0%    ~     (all equal)

	name      old cached-time/op  new cached-time/op  delta
	Build-16          506ms ±13%          500ms ± 7%    ~     (p=0.739 n=10+10)

	name      old mallocs/op      new mallocs/op      delta
	Build-16          31.7M ± 0%          30.1M ± 0%  -5.33%  (p=0.000 n=10+9)

	name      old sys-time/op     new sys-time/op     delta
	Build-16          5.70s ± 5%          5.78s ± 6%    ~     (p=0.278 n=9+10)
@mvdan mvdan requested a review from lu4p July 2, 2022 13:07
@mvdan
Copy link
Member Author

mvdan commented Jul 2, 2022

This is hopefully more reasonable than #556 :) See the upstream issue for details; hopefully the compiler can get smarter and then we can remove the conditionals.

@mvdan mvdan merged commit ec68fc6 into burrowers:master Jul 6, 2022
@mvdan mvdan deleted the debug-log-allocs branch July 6, 2022 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants