Skip to content

Only format debug log arguments when a logger is set - #293

Closed
guillaume-sainthillier wants to merge 1 commit into
libvips:masterfrom
silarhi:perf/lazy-debug-log
Closed

guillaume-sainthillier wants to merge 1 commit into
libvips:masterfrom
silarhi:perf/lazy-debug-log

Conversation

@guillaume-sainthillier

Copy link
Copy Markdown

VipsObject::get() and VipsOperation::callBase() call var_export() to build their debug log arguments on every call, and Introspect casts itself to a string, even though Utils::debugLog() discards the message when no logger is set. These are now only built when a logger is configured.

This makes calls ~3–5% faster on small images (26.5–27.1 µs → 25.7–25.8 µs per operation in a loop of invert()/add()/flip() + get() on a 16x16 image, libvips 8.16). Tests pass (the streaming tests need zend.max_allowed_stack_size=-1, as on master).

VipsObject::get() and VipsOperation::callBase() ran var_export() for
their debug log on every call, and Introspect cast itself to a string,
even though debugLog() drops the message when no logger is set.
@kleisauke

Copy link
Copy Markdown
Member

Please do not use LLMs to generate code or PR descriptions when contributing to libvips:
https://github.com/libvips/libvips/blob/master/CONTRIBUTING.md#ai-policy

Evidence

The GitHub audit log indicate that the contribution was made using Claude Code:

user_agent	GitHub CLI 2.100.0 Agent/claude-code_2-1-286_agent

See also: https://agentscan.tools/user/guillaume-sainthillier.

@kleisauke kleisauke closed this Oct 2, 2026
@guillaume-sainthillier

Copy link
Copy Markdown
Author

@kleisauke my bad sorry for that 👍 the changes are still relevant and would be happy to open another PR

@kleisauke

Copy link
Copy Markdown
Member

I just opened PR #294 as alternative to this. Thanks for reporting!

@guillaume-sainthillier
guillaume-sainthillier deleted the perf/lazy-debug-log branch October 5, 2026 07:36
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