Skip to content

Commit

Permalink
std: Turn down the stdout chunk size
Browse files Browse the repository at this point in the history
I've found that 64k is still too much and continue to see the errors as reported
in #14940. I've locally found that 32k fails, and 24k succeeds, so I've trimmed
the size down to 8192 which libuv happens to use as well.

It sounds like the limit can still be hit with many threads in play, but I have
yet to reproduce this, so I figure we can wait until that's hit (if it's
possible) and then take action.
  • Loading branch information
alexcrichton committed Sep 8, 2014
1 parent 4e5d5ba commit 198030f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libstd/io/stdio.rs
Expand Up @@ -362,7 +362,14 @@ impl Writer for StdWriter {
// sizes. For an example, see #14940. For this reason, chunk the output
// buffer on windows, but on unix we can just write the whole buffer all
// at once.
let max_size = if cfg!(windows) {64 * 1024} else {uint::MAX};
//
// For some other references, it appears that this problem has been
// encountered by others [1] [2]. We choose the number 8KB just because
// libuv does the same.
//
// [1]: https://tahoe-lafs.org/trac/tahoe-lafs/ticket/1232
// [2]: http://www.mail-archive.com/log4net-dev@logging.apache.org/msg00661.html
let max_size = if cfg!(windows) {8192} else {uint::MAX};
for chunk in buf.chunks(max_size) {
try!(match self.inner {
TTY(ref mut tty) => tty.write(chunk),
Expand Down

13 comments on commit 198030f

@bors
Copy link
Contributor

@bors bors commented on 198030f Sep 8, 2014

Choose a reason for hiding this comment

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

saw approval from brson
at alexcrichton@198030f

@bors
Copy link
Contributor

@bors bors commented on 198030f Sep 8, 2014

Choose a reason for hiding this comment

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

merging alexcrichton/rust/windows-large-console-write = 198030f into auto

@bors
Copy link
Contributor

@bors bors commented on 198030f Sep 8, 2014

Choose a reason for hiding this comment

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

alexcrichton/rust/windows-large-console-write = 198030f merged ok, testing candidate = e59e12ab

@bors
Copy link
Contributor

@bors bors commented on 198030f Sep 8, 2014

Choose a reason for hiding this comment

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

saw approval from brson
at alexcrichton@198030f

@bors
Copy link
Contributor

@bors bors commented on 198030f Sep 8, 2014

Choose a reason for hiding this comment

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

merging alexcrichton/rust/windows-large-console-write = 198030f into auto

@bors
Copy link
Contributor

@bors bors commented on 198030f Sep 8, 2014

Choose a reason for hiding this comment

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

alexcrichton/rust/windows-large-console-write = 198030f merged ok, testing candidate = a46fd016

@bors
Copy link
Contributor

@bors bors commented on 198030f Sep 8, 2014

Choose a reason for hiding this comment

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

saw approval from brson
at alexcrichton@198030f

@bors
Copy link
Contributor

@bors bors commented on 198030f Sep 8, 2014

Choose a reason for hiding this comment

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

merging alexcrichton/rust/windows-large-console-write = 198030f into auto

@bors
Copy link
Contributor

@bors bors commented on 198030f Sep 8, 2014

Choose a reason for hiding this comment

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

alexcrichton/rust/windows-large-console-write = 198030f merged ok, testing candidate = 325808a

@bors
Copy link
Contributor

@bors bors commented on 198030f Sep 8, 2014

Choose a reason for hiding this comment

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

@bors
Copy link
Contributor

@bors bors commented on 198030f Sep 8, 2014

Choose a reason for hiding this comment

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

fast-forwarding master to auto = 325808a

Please sign in to comment.