Skip to content

optimize handling of console output / errors - #12077

Merged
kevinushey merged 15 commits into
mainfrom
feature/console-output-newline-count
Oct 4, 2022
Merged

kevinushey merged 15 commits into
mainfrom
feature/console-output-newline-count

Conversation

@kevinushey

@kevinushey kevinushey commented Sep 30, 2022 •

Copy link
Copy Markdown
Collaborator

Intent

Part of #12059.

Approach

This PR bundles a number of changes that should improve the responsiveness of both the Console pane and the Build pane, in the cases where we're receiving a very large amount of text.

  1. We now bundle output on stderr in the same way we bundle stdout. This is necessary as R users may produce output on stderr via the message() function, so it can become overloaded in the same way that stdout might.

  2. We also now truncate output shown in the Build pane. This is especially important for projects that compile C / C++ code, as the Build pane can become overwhelmed by warning output from the compiler.

Just to drive the second point home, this is what I see if I compile the rstan package with -Weverything:

kevin@MBP-P2MQ:~/r/pkg/rstan/rstan/rstan [develop]
$ R CMD INSTALL --preclean . &> output.log
$ ll output.log
-rw-r--r--  1 kevin  staff    70M Oct  3 11:33 output.log

Automated Tests

N/A

QA Notes

Test via notes in #12059.

Checklist

  • If this PR adds a new feature, or fixes a bug in a previously released version, it includes an entry in NEWS.md
  • If this PR adds or changes UI, the updated UI meets accessibility standards
  • A reviewer is assigned to this PR (if unsure who to assign, check Area Owners list)
  • This PR passes all local unit tests

@kevinushey
kevinushey marked this pull request as draft September 30, 2022 22:28
@kevinushey

Copy link
Copy Markdown
Collaborator Author

Unit tests aren't happy with these changes, so will need to investigate.

@kevinushey
kevinushey force-pushed the feature/console-output-newline-count branch from 6cfe1d8 to 5b7c79b Compare October 1, 2022 01:11
@kevinushey

Copy link
Copy Markdown
Collaborator Author

Unit tests are happier now.

@kevinushey
kevinushey marked this pull request as ready for review October 1, 2022 01:27
@kevinushey

Copy link
Copy Markdown
Collaborator Author

I realized while putting this PR together that we're already coalescing stdout in the console process; I think it makes sense to do the same for stderr here as well (since R users might write large amounts of output to stderr() via the message() function).

With this PR, the following is much more performant:

for (i in 1:200000) writeLines(paste(i), con = stdout())
for (i in 1:200000) writeLines(paste(i), con = stderr())

However, the following can still lock up RStudio:

for (i in 1:200000) {
  writeLines("stdout", con = stdout())
  writeLines("stderr", con = stderr())
}

but such patterns should hopefully be far less common.

@kevinushey kevinushey changed the title use optimized count of newlines for console output optimize handling of console output / errors Oct 1, 2022

@jeffvroom jeffvroom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! This is going to make a big difference!

@kevinushey
kevinushey merged commit 94769c0 into main Oct 4, 2022
@kevinushey
kevinushey deleted the feature/console-output-newline-count branch October 4, 2022 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants