Handmade Hero » Forums » Code » [Day 118] Occasional Spikes on Cycle Count (Draw Rectangle Hopefully Quickly)
DanZaidan
Daniel Zaidan
15 posts
#15363 [Day 118] Occasional Spikes on Cycle Count (Draw Rectangle Hopefully Quickly)
1 month ago Edited by Daniel Zaidan on May 21, 2018, 3:21 p.m. Reason: Initial post

Hello everybody!

I'm going through all the episodes of HMH in order and I'm learning a lot!
Recently, I'm going through the optimization pass on the software rendering and (probably because I've never done this kind of optimization before) I have a question about it.

We are currently outputting the average cycle count that takes to run each pixel in the draw rectangle hopefully quickly function.
On stream, Casey gets a very consistent number, a little below 50 cycles.

On my code, I also get around 50, but it oscillates a lot and occasionally it goes over 120 cycles for a frame of two. (I tested it with no player input, so everything should be static):

3: 43243094cy 845733h 51cy/h
3: 43162425cy 845733h 51cy/h
3: 42933697cy 845733h 50cy/h
3: 42998116cy 845733h 50cy/h
3: 43012084cy 845733h 50cy/h
3: 87496074cy 845733h 103cy/h
3: 52160754cy 845733h 61cy/h
3: 108275849cy 845733h 128cy/h
3: 60571265cy 845733h 71cy/h
3: 42565086cy 845733h 50cy/h
3: 40120944cy 845733h 47cy/h
3: 39108831cy 845733h 46cy/h

So I compiled Casey's code in my computer from day 118 and it also has these spikes!

3: 48649913cy 880561h 55cy/h
3: 47996994cy 880561h 54cy/h
3: 49275761cy 880561h 55cy/h
3: 49820967cy 880561h 56cy/h
3: 44064311cy 880561h 50cy/h
3: 43641969cy 880561h 49cy/h
3: 43786379cy 880561h 49cy/h
3: 115311163cy 880561h 130cy/h
3: 106051675cy 880561h 120cy/h
3: 97296550cy 880561h 110cy/h
3: 43216607cy 880561h 49cy/h
3: 51624879cy 880561h 58cy/h
3: 51160035cy 880561h 58cy/h
3: 51151959cy 880561h 58cy/h

So I figured it must have something to do with my CPU (Intel i7-5820K @3.3GHz).
My questions are:
Is this something I should worry about?
If so, how would I go about debugging it? (Setting breakpoints mess with the cycle count).

Thanks!
Dan Zaidan
DanZaidan
Daniel Zaidan
15 posts
#15372 [Day 118] Occasional Spikes on Cycle Count (Draw Rectangle Hopefully Quickly)
1 month ago

Figured it out! (thanks to a question on day 119 :D )
It turns out Windows's power saving options were messing around with my CPU...