Conversation
|
i think its not worth to do this change because it will introduce more weight to the log apis, but i can do some profiling if you just rebase the branch on top of master and remove the unrelated commits to the pr |
Work in progress for radareorg#12007. - Avoid stack-fixed buffer in r_log_vmessage by allocating the formatted message on the heap (r_str_newvf), preventing truncation. - Add a unit test to ensure long log messages are not truncated.
fce9493 to
ba5c563
Compare
|
I rebased the branch on top of current master and removed unrelated commits (the PR now contains only the RLog change + unit test). |
Use a small stack buffer for the common case and only allocate on the heap when the formatted message does not fit, preventing truncation without adding per-log heap overhead.
|
Rebased on top of current master and dropped unrelated commits (PR now only touches RLog + unit test). To address the 'more weight' concern: the implementation now uses a small stack buffer for the common case and only falls back to heap allocation when the formatted message doesn't fit. This avoids truncation while keeping the fast path allocation-free; heap is only used for long messages. |
|
augmented code review with opus 4.6: PR #25411 Review: RLog heap buffer fallbackPR: #25411 What the PR doesChanges The PR adds a "try stack, fallback to heap" pattern:
Performance impact analysisFast path (messages < 512 bytes — the vast majority):
Slow path (messages ≥ 512 bytes):
Overall: merging this would NOT measurably slow anything down. The logging path already does heap allocation ( Code quality issues
Do we really need this change?Arguments FOR:
Arguments AGAINST:
Verdict: The change is technically correct but over-engineered for the problem it solves. If truncation is a concern, bumping Suggested alternatives (simplest → most complex)
Recommendation: Option 1 is the pragmatic choice. If you want to be "correct" for arbitrarily long messages, Option 2 is cleaner than the current PR. |
Replace the stack+heap fallback with a fixed-size stack buffer (2048 bytes) to keep r_log_vmessage simple and low-overhead while covering realistic long messages.
|
Applied the simplification. Changes:
Rationale:
Validation:
|
Work in progress for #12007 (RLog improvements).
This PR addresses the first checklist item: avoid stack-fixed buffer usage in r_log_vmessage.
Changes:
Refs #12007