New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++ memory results might be a bit misleading #43
Comments
The memory tracking with cgroup is a bit tricky and not exactly correct (cgmemtime uses it as there is simply nothing better than that). The issue with it is that it counts caches and shared objects ( |
Yeah, that's why I used average instead of minimum in all of my testing, normally running 100 runs at a time (works fine for C++ and Nim, probably wouldn't do it for the slower candidates as it would take a really long time). |
I believe the minimum value is fair enough given the algorithm require a constant amount of allocations between executions. Averaging catches some irrelevant fluctuations. |
Yeah but as you say it also will count less if something else had a shared library cached. So you will catch irrelevant fluctuations both ways. Probably shouldn't use an average though, but rather a median. Just calculated some medians for my samples:
First line is time, second is memory. Medians are good for this sort of thing since (quote from Wikipedia):
What you are basically doing with choosing the minimum is choosing an outlier, something that doesn't represent a typical run. Note that this was run mostly to get memory data, so the machine was being used at the same time and as such the timing might be off. |
If I compile C++, D, and Nim solutions statically I see the following memory footprints stable:
|
Oh nice! What switches did you use to compile them statically? |
|
Really interesting, wasn't expecting to see much more speed increase on this without having to use some really dirty tricks. Reran on my machine all three versions with static linking.
Memory, order same as before:
Very interesting to see that Nim with garbage collector is able to keep up this well, albeit using a bit more memory. |
I still think median is the way to go though, it's more "correct" for this kind of thing. |
It's probably less accurate but Kostya uses this short ruby script for memory + time tracking: https://github.com/kostya/benchmarks/blob/master/xtime.rb Given how fast the tasks are it might not be precise enough though. |
Hmm, interesting. I tried to run the |
I have just updated the scoreboards! |
I still believe that the minimum memory consumption is the best way to estimate the solution memory footprint since the memory footprints of statically linked solutions do not fluctuate (i.e. the fluctuations are caused by something external to the solution itself). |
During my work on the Nim version of this code (which it it's most optimised version beats the C++ versions on speed), I did some runs of the C++ code as well. One thing I noticed is that I regularly got 504KiB memory usage, and not the 0.3MiB (so somewhere around the 300KiB mark). I did sometimes see it dip to 376KiB however, so I went to see how often this would happen.
To get lot's of measurements I went with:
However I did abort the run after 5826 samples as it was starting to drag on a bit. The average memory consumption of all the runs were 524KiB and the breakdown of samples was as follows:
As we can see only 71 of the 5825 runs used less than 500KiB, a mere 1.22%.
Running with the Nim version with manual memory allocation we actually get a better average at 513KiB with a breakdown of:
And just for comparison the Nim version using the GC get's an average of 899KiB with a breakdown of:
The speed seems to be affected as well, although not as much:
First row is average speed, second is minimum speed (C++ version run 5825 times, the Nim versions only 1000 times).
The text was updated successfully, but these errors were encountered: