Skip to content

Simplify debug level check #6820

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

Conversation

taylanisikdemir
Copy link
Member

What changed?

The recently added DebugOn() had some basic caching but benchmarks show that it doesn't matter much when debug level is not enabled. It helps save some cycles when log level is debug but is not worth the additional complexity (2 atomic operations etc.). Thanks @Groxx for pointing this out.

Benchmark results with level = debug

BenchmarkDebugOnCheckCached-12    	30902576	        38.90 ns/op	       0 B/op	       0 allocs/op
BenchmarkDebugOnCheckEachTime-12   	2618984	       		439.8 ns/op	     488 B/op	       4 allocs/op

Benchmark results with level = info

BenchmarkDebugOnCheckCached-12    	30820993	        38.28 ns/op	       0 B/op	       0 allocs/op
BenchmarkDebugOnCheckEachTime-12    30134168	        39.27 ns/op	       0 B/op	       0 allocs/op

So removing the cache and asking zap to check level each time.

Copy link
Member

@Groxx Groxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank ye :)

To stick it in writing too: I think the (marginal) added cost while debug-logging is completely fine because in debug-log-mode we really don't care about performance, and it's almost certainly dwarfed by whatever is being logged.

So all we really care about is prod behavior when not debug-logging, and that's essentially the same but much simpler now. Definitely seems worth it to avoid a pile of atomics.

@taylanisikdemir taylanisikdemir merged commit 53357c6 into cadence-workflow:master Apr 15, 2025
23 checks passed
@taylanisikdemir taylanisikdemir deleted the taylan/debugon_simplified branch April 15, 2025 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants