# Writing to CSV files and plotting are getting slower in every run

**URL:** <https://discourse.julialang.org/t/writing-to-csv-files-and-plotting-are-getting-slower-in-every-run/68711>\
**Category:** General Usage\
**Tags:** question\
**Created:** [September 24, 2021, 5:01pm UTC](https://discourse.julialang.org/t/writing-to-csv-files-and-plotting-are-getting-slower-in-every-run/68711 "2021-09-24T17:01:56Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![Marc.Cox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marc.cox/32/7514_2.png) [@Marc.Cox](https://discourse.julialang.org/u/Marc.Cox)\
**Post date:** [September 24, 2021, 8:39pm UTC](https://discourse.julialang.org/t/writing-to-csv-files-and-plotting-are-getting-slower-in-every-run/68711/9 "2021-09-24T20:39:14Z")

</div>

Hi Fredrik @baggepinnen , Fikri @fksayaci

I really appreciate your excellent Julia code packages,  
so Hopefully to save cycles for you 🙂 , I will speculatively  
hazard a low cost SWAG (Scientific/Speculative Wild A\*s Guess) to gather Debug Info  
to narrow down the root cause of the issue.

So to get more help first you probably need a few more debug steps to narrow down the root cause, so maybe try out @pdeffebac suggestion above ?  
Namely " … try and profile the time with just the CSV writing,  
and the time with both the CSV writing and the Plotting."

But speculating with what’s given - namely that :  
)) reporting\_results has both A) write CSV and B) using Plots steps  
)) Allocations stays the same @@ 22.6 GiB (GB ? Question know if that is CPU RAM ONLY ?)  
)) Per reporting\_results  
Ru **n#1** including “B) using Plots” taking **3854 seconds,** then  
**Run#2** including “B) using Plots” _ **taking 17882s ;** _

In order To narrow down root cause consider trying out this advice for  
GPU Detecting-memory-leaks / and Track GPU GC (garbage collection)  
@@ [https://juliagpu.gitlab.io/CUDA.jl/usage/memory/#Detecting-leaks](https://juliagpu.gitlab.io/CUDA.jl/usage/memory/#Detecting-leaks)  
NOTE … To keep track … feature is only available when running Julia on debug level 2 or higher (i.e., with the -g2 argument).  
When you do so, the memory\_status() function from above will display additional information:  
.  
@@ [Cuda kernel error - #2 by maleadt](https://discourse.julialang.org/t/cuda-kernel-error/31876/2)  
To see the actual error, and stack trace, you need to follow the suggestion:  
start Julia on debug level 2, e.g., julia -g2 my\_script.jl or just julia -g2 to get a REPL. The reason is that these messages and traces are embedded in the generated code (we don’t have stack unwinding), and thus have a fairly large cost in performance.

For example :  
… julia-1.4.2/bin/julia **-g2**  
julia\> using CUDA  
[Info: Precompiling CUDA [052768ef-…-66c8b64840ba]

julia\> CUDA.memory\_status()  
Downloading artifact: CUDA90  
Downloading artifact: CUDNN\_CUDA90

> > Effective **GPU memory usage: 98.50%** (3.882 GiB/3.941 GiB) \<\<

Naturally this is just a speculative SWAG to gather Debug Info  
if multiple runs of  
“B) using Plots” is the issue,  
so of course  
“A) write CSV” could still be the issue.

Let us know your test results so far ?

HTH,  
Marc

---

_[View the full topic](https://discourse.julialang.org/t/writing-to-csv-files-and-plotting-are-getting-slower-in-every-run/68711)._
