Note that there are some explanatory texts on larger screens.

plurals
  1. POPerformance hitches of some sort in a return or parameter (Java)
    primarykey
    data
    text
    <p>I am running a complicated multithread java game, which is working perfectly with the exception of this function. This function, when called, approximately 0.01% of the time, will cause a thread hitch of a quarter of second. Through a series of debug lines and time measurements, it's absolutely down to this function (and three others almost exactly like it).</p> <p>The usage of this function is to provide the light level of a nearby block within a voxel engine game. It is only run when a section of the world is updated, which can happen alongside rendering.</p> <p>Please note: </p> <ul> <li>This function works accurately 100% of the time for its intended function.</li> <li>This function causes a thread hitch of approximately a quarter second 0.01% of the time.</li> <li>The variables are not synchronized. </li> <li>The function is never called more than once at a time in the program.</li> <li>All variables are valid fields of a larger, non-synchronized class.</li> <li>All variables are integers.</li> <li>The array <code>light[][][]</code> is a <code>byte[][][]</code>.</li> <li>This method is never called more than once at a time, as it is synchronized by a larger method on a wide interval.</li> </ul> <p>I'm pretty sure external synchronization is not the issue.</p> <p>What part(s) of this function may be causing an issue with thread synchronization, CPU overuse, or stack filling, and how can I go about improving performance to get rid of these render hitches?</p> <pre><code>public byte nsleftlighting(int[] coords){ if(coords[0]&lt;0)return 16; difx=chunkedx-chunks[coords[0]].X; difz=chunkedz-chunks[coords[0]].Z; if(coords[1]==0){ if(-difx&lt;=-(chunklimit)){return 16;} else if (-difx==0) { if(-difz&gt;=0){ proz=0; specialz=-difz; }else{ specialz=difz-1; proz=1; } if(chunks[chunkxyid[1][proz][0][specialz]].loaded){ return chunks[chunkxyid[1][proz][0][specialz]].light[15][coords[2]][coords[3]]; } else{return 16;} } else { if(-difz&gt;=0){ proz=0; specialz=-difz; }else{ specialz=difz-1; proz=1; } if(-difx&gt;0){ prox=0; specialx=-difx-1; }else{ specialx=difx; prox=1; } if(chunks[chunkxyid[prox][proz][specialx][specialz]].loaded){ return chunks[chunkxyid[prox][proz][specialx][specialz]].light[15][coords[2]][coords[3]]; } else {return 16;} } } if(coords[1]&gt;0){ return chunks[coords[0]].light[coords[1]-1][coords[2]][coords[3]]; } return 16; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload