posit-dev / positron

Positron, a next-generation data science IDE
https://positron.posit.co
Other
2.82k stars 90 forks source link

Console becomes slow after too many lines are printed #5441

Open dfalbel opened 11 hours ago

dfalbel commented 11 hours ago

System details:

Positron and OS details:

Positron Version: 2024.12.0 (Universal) build 51 Code - OSS Version: 1.93.0 Commit: 59b5b0c3c0a3de2068753811d7b19843d39437cf Date: 2024-11-21T02:46:07.218Z Electron: 30.4.0 Chromium: 124.0.6367.243 Node.js: 20.15.1 V8: 12.4.254.20-electron.0 OS: Darwin arm64 24.1.0

Interpreter details:

> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS 15.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Sao_Paulo
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.4.1 tools_4.4.1

Describe the issue:

In a long standing session that prints a good amount of output to the console, after some time the console starts to be very slow, specially if you switch from Terminal (or any other tab that causes the console to be hiddent) back to the Console:

https://github.com/user-attachments/assets/6c519c14-1ed3-4812-b414-d724bcbf0fed

Note that switching to the console takes ~2/3 s.

Steps to reproduce the issue:

  1. Run in R
    for (i in 1:100000) {
    cat("hello  world\n")
    }
  2. Switch from the terminal to the console

Expected or desired behavior:

We should probably trim and only render the last n lines to avoid the slow rendering. For instance, if you run R on the terminal and run the same loop printing a lot of lines, you won't see slowdowns when switching back to the terminal.

Were there any error messages in the UI, Output panel, or Developer Tools console?

N/A