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

Change to non-line buffered output if output is not a TTY #64861

Closed
wants to merge 3 commits into from

Conversation

tbu-
Copy link
Contributor

@tbu- tbu- commented Sep 28, 2019

This matches glibc behavior.

This is determined using the isatty function on Unixes, and not
attempted at all for other operating systems.

Fixes #60673.

@rust-highfive
Copy link
Collaborator

r? @KodrAus

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 28, 2019
@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-09-28T01:42:09.4200348Z ##[command]git remote add origin https:/rust-lang/rust
2019-09-28T01:42:09.4371077Z ##[command]git config gc.auto 0
2019-09-28T01:42:09.4449989Z ##[command]git config --get-all http.https:/rust-lang/rust.extraheader
2019-09-28T01:42:09.4501303Z ##[command]git config --get-all http.proxy
2019-09-28T01:42:10.0172727Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/64861/merge:refs/remotes/pull/64861/merge
---
2019-09-28T01:52:23.0899110Z configure: build.locked-deps    := True
2019-09-28T01:52:23.0899180Z configure: llvm.ccache          := sccache
2019-09-28T01:52:23.0899403Z configure: build.cargo-native-static := True
2019-09-28T01:52:23.0899652Z configure: dist.missing-tools   := True
2019-09-28T01:52:23.0899949Z configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
2019-09-28T01:52:23.0900057Z configure: writing `config.toml` in current directory
2019-09-28T01:52:23.0900122Z configure: 
2019-09-28T01:52:23.0900376Z configure: run `python /checkout/x.py --help`
2019-09-28T01:52:23.0900425Z configure: 
---
2019-09-28T01:54:41.9225365Z     Checking backtrace v0.3.37
2019-09-28T01:54:44.0131786Z     Checking rustc-std-workspace-alloc v1.99.0 (/checkout/src/tools/rustc-std-workspace-alloc)
2019-09-28T01:54:44.0164990Z     Checking panic_unwind v0.0.0 (/checkout/src/libpanic_unwind)
2019-09-28T01:54:44.0573254Z     Checking hashbrown v0.5.0
2019-09-28T01:54:49.1371625Z error[E0599]: no method named `should_be_line_buffered` found for type `sys::windows::stdio::Stdout` in the current scope
2019-09-28T01:54:49.1372785Z    |
2019-09-28T01:54:49.1372785Z    |
2019-09-28T01:54:49.1373056Z 89 |         self.0.should_be_line_buffered()
2019-09-28T01:54:49.1373645Z    |         |      |
2019-09-28T01:54:49.1373957Z    |         |      this is an associated function, not a method
2019-09-28T01:54:49.1373957Z    |         |      this is an associated function, not a method
2019-09-28T01:54:49.1374872Z    |         help: use associated function syntax instead: `sys::windows::stdio::Stdout::should_be_line_buffered`
2019-09-28T01:54:49.1375353Z   ::: src/libstd/sys/windows/stdio.rs:17:1
2019-09-28T01:54:49.1375588Z    |
2019-09-28T01:54:49.1376018Z 17 | pub struct Stdout;
2019-09-28T01:54:49.1376018Z 17 | pub struct Stdout;
2019-09-28T01:54:49.1376361Z    | ------------------ method `should_be_line_buffered` not found for this
2019-09-28T01:54:49.1378004Z    |
2019-09-28T01:54:49.1379004Z    = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
2019-09-28T01:54:49.1379321Z note: the candidate is defined in an impl for the type `sys::windows::stdio::Stdout`
2019-09-28T01:54:49.1380122Z    |
2019-09-28T01:54:49.1380122Z    |
2019-09-28T01:54:49.1380379Z 249|     pub fn should_be_line_buffered() -> bool {
2019-09-28T01:54:49.1380737Z 
2019-09-28T01:54:50.1286748Z error: aborting due to previous error
2019-09-28T01:54:50.1287697Z 
2019-09-28T01:54:50.1288821Z For more information about this error, try `rustc --explain E0599`.
---
2019-09-28T01:54:50.1793221Z == clock drift check ==
2019-09-28T01:54:50.1848753Z   local time: Sat Sep 28 01:54:50 UTC 2019
2019-09-28T01:54:50.3339875Z   network time: Sat, 28 Sep 2019 01:54:50 GMT
2019-09-28T01:54:50.3340267Z == end clock drift check ==
2019-09-28T01:54:54.8557548Z ##[error]Bash exited with code '1'.
2019-09-28T01:54:54.8600628Z ##[section]Starting: Checkout
2019-09-28T01:54:54.8603267Z ==============================================================================
2019-09-28T01:54:54.8603316Z Task         : Get sources
2019-09-28T01:54:54.8603379Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

This matches glibc behavior.

This is determined using the `isatty` function on Unixes, and not
attempted at all for other operating systems.

Fixes rust-lang#60673.
@tbu-
Copy link
Contributor Author

tbu- commented Sep 28, 2019

I get a 4x speed up for the worst case of the old implementation:

fn main() {
    for _ in 0..(1<<20) {
        println!("y");
    }
}
$ hyperfine './old' './new'
Benchmark #1: ./old
  Time (mean ± σ):     462.1 ms ±   4.4 ms    [User: 241.5 ms, System: 218.2 ms]
  Range (min … max):   453.9 ms … 467.4 ms    10 runs
 
Benchmark #2: ./new
  Time (mean ± σ):     109.9 ms ±   5.5 ms    [User: 107.9 ms, System: 1.3 ms]
  Range (min … max):   102.0 ms … 120.6 ms    27 runs
 
Summary
  './new' ran
    4.20 ± 0.21 times faster than './old'

The old program is doing 1048576 write syscalls, the new one 256.

Changing the program to use an infinite loop, I get a throughput of 3MB/s vs 20MB/s.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-09-28T01:57:06.6594671Z ##[command]git remote add origin https:/rust-lang/rust
2019-09-28T01:57:06.6796758Z ##[command]git config gc.auto 0
2019-09-28T01:57:06.6880409Z ##[command]git config --get-all http.https:/rust-lang/rust.extraheader
2019-09-28T01:57:06.6915128Z ##[command]git config --get-all http.proxy
2019-09-28T01:57:06.7090133Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/64861/merge:refs/remotes/pull/64861/merge
---
2019-09-28T03:01:31.5772526Z .................................................................................................... 1500/9046
2019-09-28T03:01:37.9917212Z .................................................................................................... 1600/9046
2019-09-28T03:01:50.7137361Z .........................................................................i...............i.......... 1700/9046
2019-09-28T03:01:57.9519880Z .................................................................................................... 1800/9046
2019-09-28T03:02:06.7065912Z ................................................................iiiii............................... 1900/9046
2019-09-28T03:02:26.8561338Z .................................................................................................... 2100/9046
2019-09-28T03:02:29.5185506Z .................................................................................................... 2200/9046
2019-09-28T03:02:32.9472633Z .................................................................................................... 2300/9046
2019-09-28T03:02:41.5932803Z .................................................................................................... 2400/9046
---
2019-09-28T03:05:47.5317292Z ....................................................i...............i............................... 4700/9046
2019-09-28T03:05:57.4774467Z .................................................................................................... 4800/9046
2019-09-28T03:06:06.3313127Z .................................................................................................... 4900/9046
2019-09-28T03:06:14.2590696Z .................................................................................................... 5000/9046
2019-09-28T03:06:24.4154443Z ........................................ii.ii....................................................... 5100/9046
2019-09-28T03:06:34.8963478Z .................................................................................................... 5300/9046
2019-09-28T03:06:45.8081452Z .................................................................................................... 5400/9046
2019-09-28T03:06:53.5827706Z .....i.............................................................................................. 5500/9046
2019-09-28T03:06:59.2428515Z .................................................................................................... 5600/9046
2019-09-28T03:06:59.2428515Z .................................................................................................... 5600/9046
2019-09-28T03:07:11.6565895Z .................................................................................................... 5700/9046
2019-09-28T03:07:25.3248069Z ii...i..ii...........i.............................................................................. 5800/9046
2019-09-28T03:07:47.7539493Z .................................................................................................... 6000/9046
2019-09-28T03:07:57.3069040Z .................................................................................................... 6100/9046
2019-09-28T03:07:57.3069040Z .................................................................................................... 6100/9046
2019-09-28T03:08:13.0527577Z ...i..ii............................................................................................ 6200/9046
2019-09-28T03:08:32.7906827Z ...............................................................i.................................... 6400/9046
2019-09-28T03:08:35.1020316Z .................................................................................................... 6500/9046
2019-09-28T03:08:37.7873074Z ...................................i................................................................ 6600/9046
2019-09-28T03:08:42.0570308Z .................................................................................................... 6700/9046
---
2019-09-28T03:12:57.3747688Z ------------------------------------------
2019-09-28T03:12:57.3747886Z stderr:
2019-09-28T03:12:57.3748337Z ------------------------------------------
2019-09-28T03:12:57.3748871Z thread 'main' panicked at 'assertion failed: `(left == right)`
2019-09-28T03:12:57.3749064Z   left: `[104, 101, 108, 108, 111, 50, 10]`,
2019-09-28T03:12:57.3749552Z  right: `[104, 101, 108, 108, 111, 10, 104, 101, 108, 108, 111, 50, 10]`', /checkout/src/test/ui/command-pre-exec.rs:45:5
2019-09-28T03:12:57.3749914Z 
2019-09-28T03:12:57.3750270Z ------------------------------------------
2019-09-28T03:12:57.3750454Z 
2019-09-28T03:12:57.3750577Z 
---
2019-09-28T03:12:57.3763605Z ------------------------------------------
2019-09-28T03:12:57.3763653Z stderr:
2019-09-28T03:12:57.3763890Z ------------------------------------------
2019-09-28T03:12:57.3764125Z thread 'main' panicked at 'assertion failed: `(left == right)`
2019-09-28T03:12:57.3764177Z   left: `"child stderr\n"`,
2019-09-28T03:12:57.3764466Z  right: `"parent stdout\nchild stderr\n"`', /checkout/src/test/ui/issues/issue-30490.rs:79:5
2019-09-28T03:12:57.3764559Z 
2019-09-28T03:12:57.3764993Z ------------------------------------------
2019-09-28T03:12:57.3765074Z 
2019-09-28T03:12:57.3765099Z 
---
2019-09-28T03:12:57.3790805Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-09-28T03:12:57.3790900Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-09-28T03:12:57.3809439Z 
2019-09-28T03:12:57.3809706Z 
2019-09-28T03:12:57.3818429Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-09-28T03:12:57.3819127Z 
2019-09-28T03:12:57.3819566Z 
2019-09-28T03:12:57.3831707Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-09-28T03:12:57.3831793Z Build completed unsuccessfully in 1:08:24
2019-09-28T03:12:57.3831793Z Build completed unsuccessfully in 1:08:24
2019-09-28T03:12:57.3890054Z == clock drift check ==
2019-09-28T03:12:57.3906919Z   local time: Sat Sep 28 03:12:57 UTC 2019
2019-09-28T03:12:57.5414176Z   network time: Sat, 28 Sep 2019 03:12:57 GMT
2019-09-28T03:12:57.5414312Z == end clock drift check ==
2019-09-28T03:12:58.6725821Z ##[error]Bash exited with code '1'.
2019-09-28T03:12:58.6798284Z ##[section]Starting: Checkout
2019-09-28T03:12:58.6800587Z ==============================================================================
2019-09-28T03:12:58.6800649Z Task         : Get sources
2019-09-28T03:12:58.6800699Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@JohnCSimon
Copy link
Member

Ping from triage
@tbu- checks have failed
@KodrAus Can you please review this PR?
Thanks.

@tbu-
Copy link
Contributor Author

tbu- commented Oct 6, 2019

An interesting question here is what we should do exec. The answer is: probably nothing, like libc does.

#include <stdio.h>
#include <unistd.h>

int main() {
	printf("a\n");
	char *a[] = {"/bin/ls", NULL};
	execv(a[0], a);
	return 0;
}

This doesn't output the a if you pipe it into cat, because stdout will be linebuffered then.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-10-06T01:15:58.6842371Z ##[command]git remote add origin https:/rust-lang/rust
2019-10-06T01:15:58.7056879Z ##[command]git config gc.auto 0
2019-10-06T01:15:58.7122022Z ##[command]git config --get-all http.https:/rust-lang/rust.extraheader
2019-10-06T01:15:58.7183836Z ##[command]git config --get-all http.proxy
2019-10-06T01:15:58.7337102Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/64861/merge:refs/remotes/pull/64861/merge
---
2019-10-06T02:18:58.8035083Z .................................................................................................... 1500/9104
2019-10-06T02:19:05.9156027Z .................................................................................................... 1600/9104
2019-10-06T02:19:15.3070368Z .................................................................................................... 1700/9104
2019-10-06T02:19:24.9134887Z .......i...............i............................................................................ 1800/9104
2019-10-06T02:19:32.4269187Z ..................................................................................................ii 1900/9104
2019-10-06T02:19:49.5996018Z iii................................................................................................. 2000/9104
2019-10-06T02:19:58.6957298Z .................................................................................................... 2200/9104
2019-10-06T02:20:01.4724142Z .................................................................................................... 2300/9104
2019-10-06T02:20:08.0655049Z .................................................................................................... 2400/9104
2019-10-06T02:20:13.8533018Z .................................................................................................... 2500/9104
---
2019-10-06T02:23:13.7753028Z .......................................................................................i............ 4700/9104
2019-10-06T02:23:21.9718772Z ...i................................................................................................ 4800/9104
2019-10-06T02:23:33.2894731Z .................................................................................................... 4900/9104
2019-10-06T02:23:39.1618090Z .................................................................................................... 5000/9104
2019-10-06T02:23:51.8732701Z ................................................................................ii.ii............... 5100/9104
2019-10-06T02:24:01.8795988Z .................................................................................................... 5300/9104
2019-10-06T02:24:12.2756878Z .................................................................................................... 5400/9104
2019-10-06T02:24:19.4440817Z ..............................................i..................................................... 5500/9104
2019-10-06T02:24:27.2232142Z .................................................................................................... 5600/9104
2019-10-06T02:24:27.2232142Z .................................................................................................... 5600/9104
2019-10-06T02:24:37.7592599Z .................................................................................................... 5700/9104
2019-10-06T02:24:45.8288167Z ...........................................ii...i..ii...........i................................... 5800/9104
2019-10-06T02:25:12.8056382Z .................................................................................................... 6000/9104
2019-10-06T02:25:22.5370855Z .................................................................................................... 6100/9104
2019-10-06T02:25:22.5370855Z .................................................................................................... 6100/9104
2019-10-06T02:25:34.4718581Z .................................................i..ii.............................................. 6200/9104
2019-10-06T02:25:59.5048964Z .................................................................................................... 6400/9104
2019-10-06T02:26:01.8193660Z .........i.......................................................................................... 6500/9104
2019-10-06T02:26:04.1683967Z .................................................................................i.................. 6600/9104
2019-10-06T02:26:07.0538935Z .................................................................................................... 6700/9104
---
2019-10-06T02:30:24.4242179Z ---- [ui] ui/command-pre-exec.rs stdout ----
2019-10-06T02:30:24.4242242Z 
2019-10-06T02:30:24.4242599Z error: test compilation failed although it shouldn't!
2019-10-06T02:30:24.4242662Z status: exit code: 1
2019-10-06T02:30:24.4243412Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/command-pre-exec.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/command-pre-exec/a" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/command-pre-exec/auxiliary"
2019-10-06T02:30:24.4243812Z ------------------------------------------
2019-10-06T02:30:24.4243874Z 
2019-10-06T02:30:24.4244127Z ------------------------------------------
2019-10-06T02:30:24.4244180Z stderr:
2019-10-06T02:30:24.4244180Z stderr:
2019-10-06T02:30:24.4244418Z ------------------------------------------
2019-10-06T02:30:24.4244516Z error[E0599]: no method named `flush` found for type `std::io::Stdout` in the current scope
2019-10-06T02:30:24.4244870Z    |
2019-10-06T02:30:24.4244870Z    |
2019-10-06T02:30:24.4244921Z LL |                 io::stdout().flush().unwrap();
2019-10-06T02:30:24.4245662Z    |                              ^^^^^ method not found in `std::io::Stdout`
2019-10-06T02:30:24.4245787Z    = help: items from traits can only be used if the trait is in scope
2019-10-06T02:30:24.4245787Z    = help: items from traits can only be used if the trait is in scope
2019-10-06T02:30:24.4245842Z help: the following trait is implemented but not in scope; perhaps add a `use` for it:
2019-10-06T02:30:24.4245955Z LL | use std::io::Write;
2019-10-06T02:30:24.4245998Z    |
2019-10-06T02:30:24.4246027Z 
2019-10-06T02:30:24.4246071Z error: aborting due to previous error
---
2019-10-06T02:30:24.4280367Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-10-06T02:30:24.4280478Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-10-06T02:30:24.4303379Z 
2019-10-06T02:30:24.4303483Z 
2019-10-06T02:30:24.4305721Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-10-06T02:30:24.4306161Z 
2019-10-06T02:30:24.4306208Z 
2019-10-06T02:30:24.4309158Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-10-06T02:30:24.4310596Z Build completed unsuccessfully in 1:07:16
2019-10-06T02:30:24.4310596Z Build completed unsuccessfully in 1:07:16
2019-10-06T02:30:24.4365798Z == clock drift check ==
2019-10-06T02:30:24.4380046Z   local time: Sun Oct  6 02:30:24 UTC 2019
2019-10-06T02:30:24.5896967Z   network time: Sun, 06 Oct 2019 02:30:24 GMT
2019-10-06T02:30:24.5903897Z == end clock drift check ==
2019-10-06T02:30:26.0172793Z ##[error]Bash exited with code '1'.
2019-10-06T02:30:26.0219022Z ##[section]Starting: Checkout
2019-10-06T02:30:26.0220882Z ==============================================================================
2019-10-06T02:30:26.0220934Z Task         : Get sources
2019-10-06T02:30:26.0221000Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@tbu- tbu- force-pushed the pr_stdout_nonlinebuffered branch from 2436735 to 5279048 Compare October 6, 2019 09:46
Copy link
Contributor

@KodrAus KodrAus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @tbu-!

I've left a few comments. I think we can punt on Windows for a start if you're not too familiar with the platform :)

StdioReader::Fake => Ok(0),
}
}
#[inline]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this inline necessary?

pub fn should_be_line_buffered(&self) -> bool {
// FIXME: Fill in. I don't know how to check whether output is
// redirected on Windows.
true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For UWP I think we can also use GetConsoleMode.

pub fn should_be_line_buffered(&self) -> bool {
// FIXME: Fill in. I don't know how to check whether output is
// redirected on Windows.
true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows there's a GetConsoleMode function you can call. It's used in the atty library's Windows implementation. It looks like that crate also has some more complex heuristics for Windows but those might not be so important here.

/// A writer that can either be line-buffered, buffered, unbuffered or fake.
///
/// If it is fake, all outputs just succeed and are dropped silently.
enum StdioWriter<W: Write> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a comment in the original FIXME suggesting we should call flush when dropping the handle if we're panicking. Did you have any thoughts on this @tbu-?

StdioWriter::LineBuffered(i) => i.write_vectored(bufs),
StdioWriter::Buffered(i) => i.write_vectored(bufs),
StdioWriter::Unbuffered(i) => i.write_vectored(bufs),
StdioWriter::Fake => Ok(bufs.iter().map(|b| b.len()).sum()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sum could probably wrap around, seems like it should saturate instead (not sure what's reasonable), or return the first non-empty len.

@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 23, 2019
@Dylan-DPC-zz
Copy link

@tbu- waiting for you to answer the review

@joelpalmer
Copy link

Ping from Triage: @tbu- any updates?

@tbu-
Copy link
Contributor Author

tbu- commented Oct 29, 2019

Too little time right now.

@tbu- tbu- closed this Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

io::Stdout should use block bufferring when appropriate
7 participants