<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Clarification request on &quot;Cpu limit abusing&quot;]]></title><description><![CDATA[<p>Today was the first day I got a message in the game stating:</p>
<pre>Script execution has been terminated: Temporary blocked due to CPU limit abusing. Please optimize your script in order to prevent reaching the CPU limit too often.</pre>
<p> </p>
<p>When does this happen? I've never received this notification before. I only had one of these ( 13:00 UTC ).</p>
<p>I rarely go over the limit, the only time it happens is when I get hit with GC.</p>]]></description><link>http://screeps.com/forum/topic/316/clarification-request-on-cpu-limit-abusing</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 23:37:46 GMT</lastBuildDate><atom:link href="http://screeps.com/forum/topic/316.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 22 Jan 2017 13:14:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>Today was the first day I got a message in the game stating:</p>
<pre>Script execution has been terminated: Temporary blocked due to CPU limit abusing. Please optimize your script in order to prevent reaching the CPU limit too often.</pre>
<p> </p>
<p>When does this happen? I've never received this notification before. I only had one of these ( 13:00 UTC ).</p>
<p>I rarely go over the limit, the only time it happens is when I get hit with GC.</p>]]></description><link>http://screeps.com/forum/post/1565</link><guid isPermaLink="true">http://screeps.com/forum/post/1565</guid><dc:creator><![CDATA[Dissi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>How can abuse even be possible? What does abuse mean? If there's CPU in the bucket shouldn't we be able to use it- and if there isn't, shouldn't the script just abort at the time limit?</p>]]></description><link>http://screeps.com/forum/post/1566</link><guid isPermaLink="true">http://screeps.com/forum/post/1566</guid><dc:creator><![CDATA[tedivm]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<div id="wmd-preview-section-12" class="wmd-preview-section preview-content">
<p>There are two types of user scripts resets. In most cases, it happens using the <code>timeout</code> option in <a href="https://nodejs.org/api/vm.html#vm_vm_runincontext_code_contextifiedsandbox_options" rel="nofollow noreferrer"><code>vm.runInContext</code></a> method. It implements the watchdog timer internally, and is able to gracefully stop the script execution exactly when we request. This situation is perfectly fine. Let’s call it a “<strong>soft reset</strong>.”</p>
<p>However, in some cases and some kinds of workload (e.g. running a heavy native function like <code>JSON.parse</code>, or some types of infinite loops), this timer doesn’t fire, it cannot stop the script immediately. In this case we allow the script to spin for 1000ms (not 500ms!), and if even this time is not enough to finish, then we force restart the entire runtime process. It’s a “<strong>hard reset</strong>.” And when this happens often, or even every tick for some player (if he has some code inflicting that every tick), it’s starting to have serious impact on overall performance, since many user scripts are being reset constantly at this node.</p>
<p>We cannot avoid this due to Node.js architecture (if you have any idea how this can be done, please share). This is why we decided to penalize users for such behavior a little bit, and encourage them to investigate their own code in order to prevent such hard resets in our system.</p>
<p>In order to clarify this further, we have now changed the error message a bit. When you reach your CPU limit and it causes a <strong>soft reset</strong>, you will get this message as usual:</p>
</div>
<div id="wmd-preview-section-25" class="wmd-preview-section preview-content">
<pre class="prettyprint"><code class=" hljs oxygene">Script execution <span class="hljs-keyword">has</span> been terminated: CPU limit reached</code></pre>
<p>This is OK, no consequences for you, you can do that every tick safely.</p>
<p>But when you cause a runtime <strong>hard reset</strong> it will be like this:</p>
</div>
<div id="wmd-preview-section-44" class="wmd-preview-section preview-content">
<pre class="prettyprint"><code class=" hljs livecodeserver">Script execution has been terminated <span class="hljs-operator">with</span> <span class="hljs-operator">a</span> hard reset: CPU limit reached</code></pre>
<p>After this, you will be penalized for some ticks with this message:</p>
</div>
<div id="wmd-preview-section-45" class="wmd-preview-section preview-content">
<pre class="prettyprint"><code class=" hljs applescript">Your <span class="hljs-keyword">script</span> <span class="hljs-keyword">is</span> temporary blocked due <span class="hljs-keyword">to</span> a hard reset inflicted <span class="hljs-keyword">to</span> <span class="hljs-keyword">the</span> runtime process. Please <span class="hljs-keyword">try</span> <span class="hljs-keyword">to</span> change your code <span class="hljs-keyword">in</span> order <span class="hljs-keyword">to</span> prevent causing hard <span class="hljs-keyword">timeout</span> resets.</code></pre>
<p>All these changes are now pushed (but not deployed yet) to private servers also, see <a href="https://github.com/screeps/driver/commit/f30fde2c036d0a9545ae6d8c441b962788635830" rel="nofollow noreferrer">this commit</a>.</p>
</div>]]></description><link>http://screeps.com/forum/post/1567</link><guid isPermaLink="true">http://screeps.com/forum/post/1567</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>So this could have happened due to a very long running GC (seems to be the root cause, as I haven't had a single one after this one).</p>
<p>I already hard-limit my own scripts when bucket the bucket is empty (for whatever reason).</p>
<p>"Stopping" my own script is smarter because it only takes 30 CPU, meaning 270 CPU goes back to the bucket,</p>
<p> </p>
<p>Thanks a lot for the clarification.</p>
<p>It looks logical to kill off and hold off the process for 5 ticks, else the user could create while(true) loops to hog the server every tick.</p>
<p>My suggestion would be to check if the script of the player is doing this on regular basis, if it does block it off like you did before. Not after 1 tick of something locking up.</p>
<p> </p>]]></description><link>http://screeps.com/forum/post/1568</link><guid isPermaLink="true">http://screeps.com/forum/post/1568</guid><dc:creator><![CDATA[Dissi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<blockquote>
<p>So this could have happened due to a very long running GC (seems to be the root cause, as I haven’t had a single one after this one).</p>
</blockquote>
<p>GC is unlikely to run for 500-1000ms actually, it is usually less than 200ms.</p>
<blockquote>
<p>My suggestion would be to check if the script of the player is doing this on regular basis, if it does block it off like you did before. Not after 1 tick of something locking up.</p>
</blockquote>
<p>Yes, it is the next step we’re going to implement later.</p>]]></description><link>http://screeps.com/forum/post/1569</link><guid isPermaLink="true">http://screeps.com/forum/post/1569</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>&gt; We cannot avoid this due to Node.js architecture (if you have any idea how this can be done, please share). This is why we decided to penalize users for such behavior a little bit, and encourage them to investigate their own code in order to prevent such hard resets in our system.</p>
<p> </p>
<p>I'm currently researching this. It might be possible with an extension, but that might degrade performance even more. <span><strong>Penalizing players</strong></span> who have <span><strong>infinite loops</strong></span> is, in my eyes, a better solution. If 10 people on the same node do the same thing you will have tick times of over 10 seconds, we can't have that! If I find anything I'll report back in a support ticket.</p>
<p> </p>
<p>&gt; GC is unlikely to run for 500-1000ms actually, it is usually less than 200ms.</p>
<p>This lines up with my findings as well, most hits add 2~20 CPU (80% of the GC's), the larger ones seem to be ranging from 80~150 CPU (19-ish% of the GC's). Luckily, we get a bucket for this!</p>
<p>As far as I know I don't have any infinite loops anywhere in my code and am suspecting a perfect storm of different events (high JSON parsing costs + gc + json serialize + shitton of creep actions). It has only happened once in a few million ticks, nothing to worry about, it was just confusing as I never saw it before. </p>
<p> </p>
<p>&gt; Yes, it is the next step we’re going to implement later.</p>
<p>Awsome!</p>]]></description><link>http://screeps.com/forum/post/1570</link><guid isPermaLink="true">http://screeps.com/forum/post/1570</guid><dc:creator><![CDATA[Dissi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>This makes a lot of sense to me, and to be honest I wouldn't have an issue if you lowered the hard reset timeout down to something like 600ms, especially if it means tick speed might increase as a result.</p>
<p>I definitely appreciate the explanation and improved documentation around this, as it really helps understand the issue. I'd like to suggest you also update the page describing the game loop so new players are likely to see this information sooner.</p>]]></description><link>http://screeps.com/forum/post/1571</link><guid isPermaLink="true">http://screeps.com/forum/post/1571</guid><dc:creator><![CDATA[tedivm]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>Sometimes this happens as well:</p>
<p><img src="https://s3.amazonaws.com/forum-static.screeps.com/88d6207d-3b37-4675-8d6b-c26a996057c4.png">This is presented when something happened during some method (60 CPU action somewhere causing the 500 limit to be exceeded):</p>
<p>How much is 1 CPU nowadays? Is it still 0.5 ms? If so, 600 ms seems reasonable.</p>]]></description><link>http://screeps.com/forum/post/1572</link><guid isPermaLink="true">http://screeps.com/forum/post/1572</guid><dc:creator><![CDATA[Dissi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>Is there a way to include the call stack in the timeout message? </p>]]></description><link>http://screeps.com/forum/post/1573</link><guid isPermaLink="true">http://screeps.com/forum/post/1573</guid><dc:creator><![CDATA[bonzaiferroni]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<blockquote>
<p>I wouldn’t have an issue if you lowered the hard reset timeout down to something like 600ms, especially if it means tick speed might increase as a result.</p>
</blockquote>
<p>600ms (500+100) might be not enough for some GC runs.</p>
<blockquote>
<p>How much is 1 CPU nowadays? Is it still 0.5 ms?</p>
</blockquote>
<p>1 CPU is always equal to 1 ms.</p>
<blockquote>
<p>Is there a way to include the call stack in the timeout message?</p>
</blockquote>
<p>Unfortunately, no, there is no way to determine at what line the underlying script has been interrupted exactly.</p>]]></description><link>http://screeps.com/forum/post/1574</link><guid isPermaLink="true">http://screeps.com/forum/post/1574</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>According to my GC timings, a max hit I once had was 180something ms.</p>
<p>Based on this I'd suggest the hard limit being the max amount of CPU a user can use that tick + 180.</p>
<p>The new max will become <strong>680ms</strong> if your bucket is full</p>
<p>If a player has 10 CPU, and drained his bucket he should get a max of 190 CPU.</p>
<p> </p>
<p>Another suggestion would be to scale bucket usage per GCL (10 CPU can max use 20 CPU etc) but that's a whole different discussion, and has the same issues with GC.</p>]]></description><link>http://screeps.com/forum/post/1575</link><guid isPermaLink="true">http://screeps.com/forum/post/1575</guid><dc:creator><![CDATA[Dissi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>I've seen this quite a few times in the last days as well , even though my code is "supposed" to also stop when Game.cpu.getUsed is getting too close to Game.cpuLimit.</p>
<p>It's really hard to investigate those when you have a few a day (eg, it's not something easily reproducible) so, as bonzai mentioned it would be wonderfull to have a bit of a hint (dump or whatever).</p>]]></description><link>http://screeps.com/forum/post/1576</link><guid isPermaLink="true">http://screeps.com/forum/post/1576</guid><dc:creator><![CDATA[Finndibaen]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>I've just got a new one which i don't know what to do with</p>
<p> </p>
<table>
<tbody>
<tr>
<td>
<pre>Script execution has been terminated: Unknown system error</pre>
</td>
</tr>
</tbody>
</table>]]></description><link>http://screeps.com/forum/post/1577</link><guid isPermaLink="true">http://screeps.com/forum/post/1577</guid><dc:creator><![CDATA[Finndibaen]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>This happens when the server stops functioning for some reason. There is nothing you can do about that one.</p>]]></description><link>http://screeps.com/forum/post/1578</link><guid isPermaLink="true">http://screeps.com/forum/post/1578</guid><dc:creator><![CDATA[Dissi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>I'm getting this too.<br>I frequently go 5 CPU above limit when my creeps repath.<br>It's getting annoying</p>]]></description><link>http://screeps.com/forum/post/1579</link><guid isPermaLink="true">http://screeps.com/forum/post/1579</guid><dc:creator><![CDATA[starwar15432]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>The only loops I have are for in loops</p>]]></description><link>http://screeps.com/forum/post/1580</link><guid isPermaLink="true">http://screeps.com/forum/post/1580</guid><dc:creator><![CDATA[starwar15432]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>This is happening to me rather frequently (several times a day), and after some looking into it, it only appears to happen on ticks where I call Game.market.getAllOrders().</p>
<p>I've read elsewhere that this is a poorly-performing server-side function and as a result have set it up to only fire when 1) I don't have market data cached to a global, or 2) I am at max bucket and can afford the CPU hit to refresh the data.  However, it seems silly that calling this just once can hit the CPU limit, even if you cache it and don't call it for minutes at a time, and is making me reconsider using market at all. <img
      src="http://screeps.com/forum/plugins/nodebb-plugin-emoji/emoji/android/1f615.png?v=a1k070tfs06"
      class="not-responsive emoji emoji-android emoji--confused"
      title=":-/"
      alt="😕"
    /></p>]]></description><link>http://screeps.com/forum/post/1581</link><guid isPermaLink="true">http://screeps.com/forum/post/1581</guid><dc:creator><![CDATA[roncli]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/70">@roncli</a>, the market orders thing was actually fixed:</p>
<p><a href="http://support.screeps.com/hc/en-us/articles/212557785-Changelog-2016-09-30" rel="nofollow noreferrer">http://support.screeps.com/hc/en-us/articles/212557785-Changelog-2016-09-30</a></p>
<p> </p>
<p>I have received this notification about 7 times since 22'nd of Januari. It might be related to your code which might have an infinite loop in an edge case. </p>
<p> </p>
<p>also artem</p>
<p>Your script is temporary blocked due to a hard reset</p>
<p>Your script is temporar&gt;l&lt;y blocked due to a hard reset</p>]]></description><link>http://screeps.com/forum/post/1582</link><guid isPermaLink="true">http://screeps.com/forum/post/1582</guid><dc:creator><![CDATA[Dissi]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Clarification request on &quot;Cpu limit abusing&quot; on Invalid Date]]></title><description><![CDATA[<p>"temporarily" <img
      src="http://screeps.com/forum/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=a1k070tfs06"
      class="not-responsive emoji emoji-android emoji--wink"
      title=";)"
      alt="😉"
    /></p>
<p>If the CPU whole is greater than the sum of its CPU parts, then I could take it resource-by-resource... is that right, though?  I would figure grabbing the whole thing at once then grabbing it mineral by mineral would be faster.</p>]]></description><link>http://screeps.com/forum/post/1583</link><guid isPermaLink="true">http://screeps.com/forum/post/1583</guid><dc:creator><![CDATA[roncli]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>