You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The print function in Swift is fully buffered by default, so when piping gen-ir output, the logger outputs get delayed and, occasionally, split.
Example (gen-ir 0.5.0-alpha)
In a CI script, I want to save off the output of gen-ir into a separate file, as well as see the progress in the console. I call gen-ir in a pipe to do so:
set -o pipefail && gen-ir <build-log><xcarchive> --project-path <workspace>| tee gen-ir.log
Here, each Running command (clang) XX of YY. Target modules processed: ZZ no longer is printed in real time, until enough are printed to fill the buffer. Occasionally, we'll also see, e.g., Running comm or similar split lines, when the full line doesn't fit inside the IO buffer.
Impact
Makes it more difficult to track the progress of gen-ir. In our case, it takes ~15 minutes to process everything, so it would be nice to have the real-time updates instead of waiting for the buffer to fill, which takes ~30s - ~1min.
Suggested Fix
Flush stdout after printing a log message. Not sure what other ways there are, but adding fflush(__stdoutp) after the print call in StdoutLogHandler.swift did it for me.
The
print
function in Swift is fully buffered by default, so when pipinggen-ir
output, the logger outputs get delayed and, occasionally, split.Example (
gen-ir
0.5.0-alpha)In a CI script, I want to save off the output of
gen-ir
into a separate file, as well as see the progress in the console. I callgen-ir
in a pipe to do so:Here, each
Running command (clang) XX of YY. Target modules processed: ZZ
no longer is printed in real time, until enough are printed to fill the buffer. Occasionally, we'll also see, e.g.,Running comm
or similar split lines, when the full line doesn't fit inside the IO buffer.Impact
Makes it more difficult to track the progress of
gen-ir
. In our case, it takes ~15 minutes to process everything, so it would be nice to have the real-time updates instead of waiting for the buffer to fill, which takes ~30s - ~1min.Suggested Fix
Flush stdout after printing a log message. Not sure what other ways there are, but adding
fflush(__stdoutp)
after the print call in StdoutLogHandler.swift did it for me.gen-ir/Sources/GenIR/StdoutLogHandler.swift
Lines 29 to 43 in e8da32c
The text was updated successfully, but these errors were encountered: