Page MenuHomePhabricator

[fuchsia] Add line buffering in RawWrite
ClosedPublic

Authored by jakehehrlich on May 21 2018, 5:36 PM.

Details

Summary

This change causes RawWrite to buffer upto 128 bytes or until a line is reached. This helps group calls into more readable lines.

Diff Detail

Event Timeline

jakehehrlich created this revision.May 21 2018, 5:36 PM
Herald added subscribers: Restricted Project, kubamracek. · View Herald TranscriptMay 21 2018, 5:36 PM
mcgrathr added inline comments.May 21 2018, 5:44 PM
compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cc
415

Ideally you'd buffer multiple short lines when they're all in the same call and do a single __sanitizer_log_write call.
To really flush only when necessary you'd compact the buffer if there's a partial line left after a flush or do some sort of ring-buffer arrangement.
You can do a bit better than the by-char loop using internal_strchr (which might get optimized though it isn't now).

Modified to group multiple lines into a single flush but still flush at least once if a newline is found.

mcgrathr added inline comments.May 22 2018, 4:42 PM
compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cc
419

if lastNewline was null now it's line and so this writes a count of 0.
Seems like the code would be simpler if lastNewline were an index too.

428

This seems like an odd way to describe it. The behavior is just "Flush all complete lines before returning".

Switched to use index. Fixed to print out full buffer in case no newline exists.

This revision is now accepted and ready to land.May 23 2018, 3:18 PM