In each Q&A video, I answer questions from the comments on the previous Q&A video, which can be from any part of the course. Transcripts are not available for Q&A videos due to length. I do produce closed captions for them, but Substack still has not enabled closed captions on videos :(
Questions addressed in this video:
[00:51] “This way of measuring profiler overhead is pretty straightforward for a command line program that takes its input from a file, does the work and is done with it. We can compare the total execution time with and without profiler and get an idea of the overhead.
How would that translate to more complex cases, for instance a UI application that runs until the user clicks on the quit button, and where the workload also depends on user interaction?”
[06:34] “You said there were caveats to signed arithmetic in C and C++ and for that reason you try to always use unsigned integral types which were at least guaranteed to implement modular arithmetic (as the hardware does) where signed does not. I had heard about the modular vs not modular difference between signed and unsigned types in C, but I thought the takeaway was to always used the signed types, since, for instance, the following loop:”
[22:25] “When you demonstrated the code to answer the first interview question, rectangle copy, you talk later on about modern versions needing to use SIMD and there's something I'm unsure about - when you batch operations together with SIMD, you might not need to do the full width of computations all the time, e.g. you want to add 10 numbers but the instruction adds 16 - the rest of the register width bits are added, but you ignore them. In the case of rectangle copy though I can't see how you could safely convert it to SIMD since the width of the rows will be different from the SIMD register widths - what I'm getting at is if you use a SIMD pointer copy operation, it's going to write register-wide rows no matter how wide the rectangle is. How do you work around this - is there masking involved?”
[30:24] “I'm just getting caught up on the lessons and I've missed a few Q&A's, so forgive me if someone already asked this! I'm wondering how instrumenting profilers can be incorporated into a long-running real-time program like a game (or a video editor, in my case). It would be great to have some way to keep a pulse on performance as I'm developing. Do you set up some sort of performance "event" system that lets you monitor anchors in real time? Do you break out functions and measure/tune them in isolation? Some hidden third thing?”
[33:32] “How do you handle overflow/underflow when multiplying or dividing? I remember hearing that handling this requires an extra bit for padding, so does that mean every f64 * f64 should really be f65 * f65? I imagine this would be a significant hit to performance, but still, should we check for overflows on every `*` or `/` in our code base? When is it prudent and when is it excessive?”