Difference between revisions of "CPU"

From Screeps Wiki
Jump to navigation Jump to search
m
Line 17: Line 17:
 
Each API method on the [http://support.screeps.com/hc/en-us/articles/203084991-API-Reference API Reference] page lists CPU usage of the method ranging from ''const'' to ''High''. ''const'' methods always require .2 CPU because they directly modify the game world.
 
Each API method on the [http://support.screeps.com/hc/en-us/articles/203084991-API-Reference API Reference] page lists CPU usage of the method ranging from ''const'' to ''High''. ''const'' methods always require .2 CPU because they directly modify the game world.
 
It is generally suggested to avoid making repeated calls to methods with High CPU usage. Many employ [[caching]] as a mechanism to avoid this.
 
It is generally suggested to avoid making repeated calls to methods with High CPU usage. Many employ [[caching]] as a mechanism to avoid this.
  +
  +
== Managing CPU ==
  +
{{Stub}}
  +
  +
=== External Resources ===
  +
{{Stub}}
  +
  +
https://github.com/bonzaiferroni/screepswiki/wiki/%23cpu-clinic-faq
  +
  +
https://screeps.slack.com/messages/cpu-clinic
  +
  +
https://screeps.slack.com/messages/10-cpu-club

Revision as of 08:09, 2 December 2016

In Screeps, every operation requires a certain amount of processing power to be completed. Every player has a limit of how much CPU (measured in milliseconds of thread usage) that can be used in a single tick.

Limits

The limit of CPU time depends on multiple factors. A player with a subscription starts with 30 CPU. This is then increased by 10 for every Global Controller Level that the player has. Players who have purchased the Steam version, but who do not pay for a subscription, have 10 CPU regardless of their GCL.

Bucket

For every tick that the limit of CPU is not consumed, the remainder is stored into a bucket. A bucket has a total capacity of 10,000 CPU. Every tick that usage exceeds the CPU limit, it is removed from the bucket. If the bucket reaches 0, and CPU usage is above limits, script execution halts. You may never use more than 500 CPU out of a bucket in a single tick.

Buckets are commonly used to combine multiple, heavier calculations to run intermittently over one or several ticks. This allows for a low average of CPU usage, with spikes to perform calculations that are then stored.

API CPU Usage

Each API method on the API Reference page lists CPU usage of the method ranging from const to High. const methods always require .2 CPU because they directly modify the game world. It is generally suggested to avoid making repeated calls to methods with High CPU usage. Many employ caching as a mechanism to avoid this.

Managing CPU

This article is a stub. You can help Screeps Wiki by editing to add more information.

External Resources

This article is a stub. You can help Screeps Wiki by editing to add more information.

https://github.com/bonzaiferroni/screepswiki/wiki/%23cpu-clinic-faq

https://screeps.slack.com/messages/cpu-clinic

https://screeps.slack.com/messages/10-cpu-club