Q&A #28 (2023-09-25)

Answers to questions from the last Q&A thread.


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:26] “Doesn't the fact that a pointer is a packed structure break pointer math outside the scope of 4k chunks?” / “If one uses pointer arithmetic and adds a value larger than a page, what happens? Does this still work? I thought adding an integer to a pointer offsets the value into memory. But with page levels, this wouldn’t be correct.”

  • [11:38] “Does the four-level paging mean that for all memory move operations, the CPU has to read from 4 memory locations to resolve what memory address to actually read from? So each move means 5 memory reads? I'm assuming that the 4 table locations are usually in the L1 cache, but I'm guessing that's not guaranteed?”

  • [18:08] “Since the top 16-bits of the pointer are not used for addressing it could be used for tagged pointers. How portable is it?”

  • [22:30] “When you say “physical memory”, does that mean a memory address in hardware? Isn’t there a memory controller that maps addresses provided by the OS to addresses in actual hardware? (To my understanding, the memory controller keeps track of which memory bits are dead to prevent their use.). More generally, where does the memory controller come into play with pointers?”

  • [25:00] “Are page faults per processor? or per core? can multithreading allocating the buffer help the performance. thank you.”

  • [29:27] “If we assume we are not dealing with large pages, am I correct to assume that a check against a pointer for >4k alignment is actually meaningless?”

  • [32:01] “You're saying Reserve will make sure nobody else will place anything in the memory block we're requesting. So, how is this different than actually commiting it?”

  • [35:55] “As someone who has worked professionally using Unity for ~7 years how hard do you think it would be to transition to C++ as a gamedev? I'm already familiar with low-level concepts (SIMD, caches, assembly, etc) and data oriented design, I also know C/C++ basics, though I've never used it in a professional context. I have almost no knowledge of graphic APIs (OpenGL, Direct3D, etc)”

The full video is for paid subscribers