R studio server session pegs CPU at 100% and hangs

I frequently but unpredictably have my rserver sessions hang with the cpu pegged at 100%. There are no errors but rstudio-server becomes unresponsive and I have to kill the process in order to get things working again. This seems to be related to writing to disk as it will often happen when I save a script, a csv (using readr::write_csv, but not utils::write.csv). I can make it happen predictably when I knit an rmarkdown to pdf. It gets to "output file:<>.knit.md" and gets stuck there.

I've tried to look up a way to get the log files for the rsession, but haven't been able to get it to work, maybe because I am on a VM?

I'm connecting to a google compute VM instance running:
Ubuntu 18.04.6 LTS
"Linux"
release
"5.4.0-1080-gcp"
version
"#87~18.04.1-Ubuntu SMP Fri Jun 10 18:50:42 UTC 2022"

Here's the version info:
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
version.string R version 4.2.0 (2022-04-22)
nickname Vigorous Calisthenics

Here's the rstudio-server information:
RStudio 2022.07.0+548 "Spotted Wakerobin" Release (34ea3031089fa4e38738a9256d6fa6d70629c822, 2022-07-06) for Ubuntu Bionic
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36.

I'd be happy to get any additional information that would be useful, and/or direction to some instructions on how to get the appropriate logs.
Thanks!

*** UPDATE ***
When I run perf while the process is hanging I get the following output:

Samples: 33K of event 'cpu-clock:pppH', 4000 Hz, Event count (approx.): 6900362281 lost: 0/0 drop: 0/0
  Children      Self  Command          Parent symbol  Shared Object                                                                                 Pid:Command
+   92.23%    33.40%  rsession         [other]        /lib/x86_64-linux-gnu/libc-2.27.so                                                           3918:rsession
+   38.20%    38.20%  rsession         [other]        /proc/kcore                                                                                  3918:rsession
+   23.64%    23.53%  rsession         [other]        /opt/intel/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin/libiomp5.so     3918:rsession
+    2.13%     1.91%  perf             [other]        /usr/lib/linux-gcp-5.4-tools-5.4.0-1083/perf                                                10593:perf
+    2.07%     0.02%  perf             [other]        /lib/x86_64-linux-gnu/libpthread-2.27.so                                                    10593:perf
+    2.06%     0.79%  perf             [other]        /lib/x86_64-linux-gnu/libc-2.27.so                                                          10593:perf
     1.30%     1.30%  perf             [other]        /proc/kcore                                                                                 10593:perf
+    0.91%     0.00%  rsession         [other]        [unknown]                                                                                    3918:rsession
     0.40%     0.40%  swapper          [other]        /proc/kcore                                                                                     0:swapper
+    0.15%     0.15%  perf             do_page_fault  /proc/kcore                                                                                 10593:perf
     0.15%     0.10%  perf             [other]        /lib/x86_64-linux-gnu/libc-2.27.so                                                          10581:perf
     0.05%     0.04%  perf             [other]        /usr/lib/linux-gcp-5.4-tools-5.4.0-1083/perf                                                10581:perf
     0.03%     0.01%  perf-top-UI      [other]        /usr/lib/linux-gcp-5.4-tools-5.4.0-1083/perf                                                10594:perf-top-UI
     0.02%     0.02%  perf-top-UI      [other]        /lib/x86_64-linux-gnu/libslang.so.2.3.1                                                     10594:perf-top-UI
     0.02%     0.02%  rcu_sched        [other]        /proc/kcore                                                                                    11:rcu_sched
     0.01%     0.00%  perf             [other]        [unknown]                                                                                   10581:perf
     0.01%     0.01%  rserver          [other]        /usr/lib/rstudio-server/bin/rserver                                                          1473:rserver
     0.01%     0.01%  perf             do_page_fault  /proc/kcore                                                                                 10581:perf
     0.01%     0.01%  rsession         [other]        /proc/kcore                                                                                  3921:rsession
     0.01%     0.01%  rserver          [other]        /usr/lib/rstudio-server/bin/rserver                                                          1472:rserver
     0.01%     0.01%  perf             [other]        /proc/kcore                                                                                 10581:perf
     0.01%     0.01%  rserver          [other]        /lib/x86_64-linux-gnu/libc-2.27.so                                                           1473:rserver
     0.01%     0.00%  perf             [other]        [unknown]                                                                                   10593:perf
     0.01%     0.00%  rserver          [other]        [unknown]                                                                                    1472:rserver
     0.01%     0.01%  rserver          [other]        /lib/x86_64-linux-gnu/libz.so.1.2.11                                                         1472:rserver
     0.01%     0.01%  rserver          [other]        /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25                                                1472:rserver
     0.01%     0.01%  rserver          [other]        /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25                                                1473:rserver
     0.01%     0.01%  rsession         [other]        /usr/lib/rstudio-server/bin/rsession                                                         3921:rsession
     0.01%     0.01%  perf             [other]        /usr/lib/x86_64-linux-gnu/libelf-0.170.so                                                   10593:perf
     0.01%     0.01%  perf-top-UI      [other]        /lib/x86_64-linux-gnu/libc-2.27.so                                                          10594:perf-top-UI
     0.00%     0.00%  kworker/5:4-mm_  [other]        /proc/kcore                                                                                  8344:kworker/5:4-mm_
     0.00%     0.00%  google_guest_ag  [other]        /usr/bin/google_guest_agent                                                                  1805:google_guest_ag
     0.00%     0.00%  google_guest_ag  [other]        [unknown]                                                                                    1805:google_guest_ag
     0.00%     0.00%  rsession         [other]        [unknown]                                                                                    3921:rsession
     0.00%     0.00%  rsession         [other]        /lib/x86_64-linux-gnu/libpthread-2.27.so                                                     3921:rsession
     0.00%     0.00%  cron             [other]        /proc/kcore                                                                                  2000:cron
     0.00%     0.00%  kworker/2:0-eve  [other]        /proc/kcore                                                                                 10255:kworker/2:0-eve
     0.00%     0.00%  snapd            [other]        /proc/kcore                                                                                  1758:snapd
     0.00%     0.00%  sshd             [other]        /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0                                                 9691:sshd
     0.00%     0.00%  perf             [other]        /lib/x86_64-linux-gnu/libslang.so.2.3.1                                                     10593:perf
     0.00%     0.00%  rserver          [other]        /usr/lib/rstudio-server/bin/rserver                                                          1470:rserver
     0.00%     0.00%  rserver          [other]        /lib/x86_64-linux-gnu/libc-2.27.so                                                           1470:rserver
     0.00%     0.00%  rserver          [other]        /proc/kcore                                                                                  1472:rserver
     0.00%     0.00%  sshd             [other]        /proc/kcore                                                                                  9691:sshd

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.