Add a subsection for microbenchmarks to the profiling page. - #12200
Add a subsection for microbenchmarks to the profiling page.#12200Ivorforce wants to merge 1 commit into
Conversation
71a3894 to
856f27b
Compare
|
More things to mention (specially for c++):
These are all very sensitive to other things using your OS. As an alternative for microbenching you can use RDTSC / RDTSCP (forces processor to finish previous instructions) to measure CPU clock ticks. This used to be easier, but on modern multicore PCs which scale speeds there's more considerations, but most have invariant TSC on the CPU regardless of stepping (check this though for your CPU). (in fact I must revisit using RDTSC for a recent couple of benchmarks in PRs) More possibles:
Obviously we shouldn't need to be a full reference, but we should probably include some of the major pitfalls, otherwise we'll get new benchmarkers and have to explain the same artifacts each time. And emphasize how difficult it can be to get correct results, I regularly get artifacts even after having done benchmarks here and there for many years 😁 . |
Those are all good tips, but I deliberately didn't include any in my PR. If we wanted to be a "best benchmarking practices" reference, we'd have to include a lot more info, for example about how to avoid dead code elimination or why cold checks are often more important than hot checks. I don't think this is in scope for the docs, so I opted for saying "hey be careful about it and read a guide somewhere" instead.
I'd rather find a blessed guide to link to somewhere and not give any tips here at all. I don't have one at hand, unfortunately, but it sounds like you might be interested in writing one 😄 |
856f27b to
68c5aa8
Compare
Absolutely not 🤣 https://quick-bench.com Unfortunately most tutorials seem to be directing you to use pre-existing libraries / tools for benchmarking instead of doing it from scratch, which is a bit sad, but maybe we'll find one. Maybe it's because it's so easy to get wrong (even for the pros!), beginners get steered away from it. |
|
I had an AI research credible stable resources we can link, found 3:
I've only heard of the last one, but the first two also look like incredible fits, so I think they are all worth linking. I'll adjust in a push. |
68c5aa8 to
a3e853e
Compare
I mostly feel the same way, although I'm trying to begrudgingly recognise that for most people spending hours diagnosing artifacts in their benchmarks isn't their idea of fun (like it might be for you or I 😁 ), and I know some quite advanced programmers will still just use off the shelf libs rather than write their own, just because of the pitfalls. I did check brendangregg's website earlier but didn't spot that particular article (most were quite in depth). The Bakhvalov book I may have looked through before at some point, seems like a good one to link covering optimization and benchmarking. 👍 |
|
If you think some people would prefer a library for it we could mention that and perhaps link one or two examples. |
|
Looks good. Something may be worth adding that gdscript benchmarking can be difficult to use / not hugely enlightening when the cost of the function under test (e.g. c++) is very cheap in relation to the overheads of gdscript. In many situations you get so much variation from the gdscript overheads, these might be 1000x as e.g. a c++ function that you are trying to optimize. But still I've seen people making PRs and trying to use a gdscript benchmark where it is clearly inappropriate. Not quite sure how to word it. |
lawnjelly
left a comment
There was a problem hiding this comment.
Although there's a few things we could add, this is fine to get started imo.
a3e853e to
d27e1d2
Compare
We currently have no documented way of performing microbenchmarks.
There is no perfectly suitable page to add this to, but I think the profiling page is a well suited candidate even though it's not technically profiling, because people are somewhat likely to find it here.
But I'm open to moving the information elsewhere!