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

refact: avoid mem alloc for debug log #636

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

regeda
Copy link
Contributor

@regeda regeda commented Jan 7, 2025

Each check request creates unnecessary memory garbage for the debug message, even when the log level is set higher than debug.

Benchmark results.

goos: darwin
goarch: arm64
pkg: github.com/open-policy-agent/opa-envoy-plugin/internal
cpu: Apple M2 Pro

With Debug:

BenchmarkCheck-12            15576             78914 ns/op           54843 B/op       1088 allocs/op

Without Debug:

BenchmarkCheck-12            16891             75411 ns/op           51540 B/op       1037 allocs/op

@anderseknert
Copy link
Member

anderseknert commented Jan 7, 2025

Thanks! Can't we just wrap that call in a check for log level? The information may be available elsewhere, but if anyone expects to find it there with debug logging turned on, it'd be good if they still found it.

@regeda regeda changed the title refact: drop debug log from check request refact: avoid mem alloc for debug log Jan 7, 2025
@regeda
Copy link
Contributor Author

regeda commented Jan 7, 2025

Thanks! Can't we just wrap that call in a check for log level? The information may be available elsewhere, but if anyone expects to find it there with debug logging turned on, it'd be good if they still found it.

Agree. I've wrapped the log statement with a condition.

Signed-off-by: Anthony Regeda <regedaster@gmail.com>
@srenatus srenatus merged commit e2e9622 into open-policy-agent:main Jan 8, 2025
8 checks passed
@regeda regeda deleted the drop-check-debug branch January 8, 2025 23:42
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.

3 participants