ufwelove.blogg.se

Screeps memory
Screeps memory













screeps memory

The require cache itself is tied to the global cache and gets cleared at the same time, although there are some circumstances where the require cache will get cleared (fully or partially) while the global cache does not.įrom a performance standpoint the fact that the require and global caches clear at once means that global resets are particularly expensive events. This reduces the load on the server and your script as it prevents the various javascript modules from having to be compiled every tick. Require CacheĮvery time require is called the results are cached. For cases where results may change and data gets invalidated meta data- such as a TTL or version identifier- will have to be stored alongside the results to facilitate that. These limitions make the global object ideal for certain types of caching, such as when the result of a function is always going to be the same or if it doesn't matter when "stale" data is used. Placing large amounts of data into the global cache may cause garbage collector to be invoked more frequently and consume more CPU.The global object can not be considered persistent storage. The global object gets reset fairly regular, meaning all of the data will regularly disappear.This is most commonly used to require modules- // executed on new global var mod = require ( 'mod' ) Additionally it allows you to define expensive one-time-run code in the outer scope. The game loop architecture allows you to define a "loop" function which gets run each tick. JSON.parse is run on the Memory string each tick it is accessed, which is more expensive the more data that is stored.įor these reasons it makes sense to limit what is placed in Memory.

screeps memory screeps memory

  • Space in Memory is limited to 2048kb of space.
  • There are two major drawbacks with Memory This is the only option for true persistance- anything stored in Memory is going to stay there until removed, so if a value is extremely expensive or must be saved this is the place to put it. The most common place to store cached data is in Memory. As an example caching the results of a pathfinding operation will let creeps reuse that optimal path even if visibility is lost to room along that path, which in turn provides both improved performance and resiliency. Caching also has a secondary benefit that can be exploited, in that it allows functions to return results even if they shouldn't be able to.

    screeps memory

    Caching is an extremely important element in performance optimization, and Screeps provides it's own unique opportunities and challenges when it comes to cache.Ĭaching is, at it's core, a simple concept- by saving the results of expensive code future calls are less expensive. Screeps is a performance centric game- the better your performance the more you can accomplish in each tick.















    Screeps memory