hsf-training / cpluspluscourse

C++ Course Taught at CERN, from Sebastien Ponce (LHCb)
Apache License 2.0
169 stars 65 forks source link

Dropped useless bigdata member in the functions example #488

Closed sponce closed 1 year ago

sponce commented 1 year ago

It served no purpose (copy was not slow there, only a sleep made it slow) and was discovered (the hard way) to make windows users having very strange segfaults. Simply because it was too large to be on the stack in such context and was screwing memory !

bernhardmgruber commented 1 year ago

Haha, AFAIK Visual C++ on Windows uses a default stack size of 1MiB. I am surprised we never ran into this.

However, now it's less obvious that SlowToCopy is slow because it's "big". Would it work if you just reduce the size of the data member? Maybe just to int bigdata[10'000];.

sponce commented 1 year ago

Most probably because we've never had real windows users. I mean that they were using WSL so far.

Anyway, reducing will most probably work, but it's not the size that matters here, the thing is fast whatever happens, so I think for the point we want to make, keeping only the sleep is absolutely fine