53 lines
4.4 KiB
Plaintext
53 lines
4.4 KiB
Plaintext
[video output=day182 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Fast Thread ID Retrieval" vod_platform=youtube id=fNufyLQacDw annotator=Miblo annotator=debiatan]
|
|
[0:36][Recap and plan for today]
|
|
[2:52][On the benefits of having a nice inline profiling system][quote 223]
|
|
[5:10][The profiling system is only slow in the collation phase, and that is acceptable]
|
|
[6:45][Limitations of the current implementation of the profiling system:]
|
|
[7:48][1) It is possible for the profiler to read bogus data under extremely improbable conditions]
|
|
[10:40][2) The debug records are not stamped with core and thread indices]
|
|
[11:00][The core indices are not that important...]
|
|
[11:39][... thread indices, on the other hand, are crucial]
|
|
[13:33][Two options to disambiguate between threads:]
|
|
[13:37][1) Getting a thread index]
|
|
[14:32][2) Generating unique IDs with an atomic operation to pair our begin and end timed blocks]
|
|
[15:36][Can we find out the thread index with a simple function call?]
|
|
[16:24][How does GetCurrentThreadId work?]
|
|
[18:18][It looks like GetCurrentThreadId only issues a couple of instructions to get the thread ID back]
|
|
[19:27][Thread local storage]
|
|
[20:59][Segmented addressing]
|
|
[23:47][Is there some intrinsic that allows us to replicate GetCurrentThreadId's behavior?]
|
|
[26:45][Yes, _readgsqword]
|
|
[27:40][Replicating the behaviour of GetCurrentThreadId]
|
|
[27:48][Debugger: Step in there after the jump][quote 224]
|
|
[29:51][Testing our version]
|
|
[30:43][It works!]
|
|
[31:23][Recording the thread ID inside RecordDebugEvent]
|
|
[32:20][Abstracting GetThreadId on the platform layer]
|
|
[35:55][Unifying the timer counters of platform and game layers]
|
|
[36:58][Exposing the debug system to the platform layer]
|
|
[40:28][How do we find the locations of the debug structures?]
|
|
[41:35][We could store them on the platform layer side...]
|
|
[42:09][...or we could leave the debug arrays on the DLL side and use DLL binding to patch their addresses]
|
|
[42:54][DLL binding with _declspec(ddlimport)]
|
|
[44:26][Consolidating the debug structs into a single struct (debug_table)]
|
|
[48:40][Using the TRANSLATION_UNIT_INDEX preprocessor symbol instead of RecordArrayIndexConstant]
|
|
[49:11][Accessing only the debug_table from inside the debug-related routines]
|
|
[57:45][Moving the necessary intrinsics to the platform layer]
|
|
[58:46][Testing. There's a bug]
|
|
[1:00:42][Getting rid of GlobalDebugEventArray]
|
|
[1:01:10][And... we're back!]
|
|
[1:01:50][Q&A][:speech]
|
|
[1:02:38][@elxenoaizd][What do you think is an effective way to get better at assembly? Go over a book / tutorial? Read the code disassembly in VS? Mike Acton can look at a piece of code for a couple of seconds and estimate how many cycles it takes and what the assembly code for it is. I'd like to reach that level one day]
|
|
[1:04:57][@Pseudonym73][We're actually a pre-recorded laugh track]
|
|
[1:05:08][@insofaras][How would you deal with switching between multiple APIs in a single application (like software / hardware renderer)? Would it be structured similar to the platform layer?]
|
|
[1:11:35][@elxenoaizd][Why don't compilers expose API that gives us information about our code (access to the AST, etc.)? Because when we write a top-down parser we're essentially writing something that the compiler already has]
|
|
[1:14:35][@OriginalName667][Are you still using the software renderer or did you move over to DirectX or OpenGL?]
|
|
[1:14:40][@CaptainKraft][At what point does a person become a good programmer? When do you think you became a good programmer?]
|
|
[1:15:46][@elxenoaizd][How do you handle programmer burnout / depression? Those days when you're just not in the mood to do anything, not productive, you're demotivated, you can barely do any coding, you'd rather do 'anything' else other than what you should be doing]
|
|
[1:17:39][@inliferty][Do you really prefer to save two unconditional jumps (so the CPU pipeline won't be flushed at any chance) instead of Compiler & Platform Independence (referring to the GetThreadId part)?]
|
|
[1:18:48][@thegujhack][Why are you making an engine instead of a game?]
|
|
[1:21:27][@elxenoaizd][Do you think implementing a regex matcher is worth it / useful for meta programming?]
|
|
[1:21:41][@obiwanus][You seem to be pretty unhappy with the quality of modern software. Do you think programmers were better in the past? Is the software you produce always flawless and bugless? Asking seriously, just trying to understand your point more clearly. Thanks][quote 225]
|
|
[1:27:21][Wrap it up][:speech]
|
|
[/video]
|