I was passing custom names to make sure, that the name generation is not responsible for the long execution time.
Posts made by MarkusF
-
RE: StructureSpawn.createCreep creates high cpu-load
-
StructureSpawn.createCreep creates high cpu-load
I currently have ~180 creeps, and every successful call to StructureSpawn.createCreep() takes about 12 cpu to execute.
I pass a name when calling it and the canCreateCreep() call within createCreep() takes about 0.1 cpu.to execute
-
RE: StructureLab.runReaction(...) throws exception
I can only guess, that my script accidently puts a catalyzed resource into one of the input labs.
But you should change the ingredient check from, to handle this, too.
if (!C.REACTIONS[lab1.mineralType][lab2.mineralType] || this.mineralType && this.mineralType != C.REACTIONS[lab1.mineralType][lab2.mineralType]) {
return C.ERR_INVALID_ARGS;
}to
if (!C.REACTIONS[lab1.mineralType] || !C.REACTIONS[lab1.mineralType][lab2.mineralType] || this.mineralType && this.mineralType != C.REACTIONS[lab1.mineralType][lab2.mineralType]) {
return C.ERR_INVALID_ARGS;
} -
RE: Unusual high used-cpu values right at the start of the loop
GarbaceCollection makes sense.
As I said, now it settled down a lot. My intuition tells me, that it's worse, the more people are online in the slack-channel. Maybe the more people are working on their scripts and regularly commit them to screeps, the harder the garbage collection hits. However, I don't have any statistics for this, just my intuition.
But as long as I have an explanation for what it could have been, I'm quite fine with it.
-
StructureLab.runReaction(...) throws exception
Today, some of my StuctureLabs threw exceptions upon calling runReaction(). I've not been able to figure out the cause of this, but it seemed to me, that maybe something isn't beeing caught in runReaction() and throws an exception instead of returning an ERR_* constant.
The exception had been thrown at
TypeError: Cannot read property 'X' of undefined
at StructureLab.runReaction (/opt/engine/dist/game/structures.js:407:43) -
RE: Unusual high used-cpu values right at the start of the loop
@tedvim: It's 350kb now, but yes, there are many small objects.I've made the mistake to use quite long property names, even in memory, maybe I should have avoided that.
But about the high peak values: Now it has settled down a lot, and high values appear very rarely. But few hours after posting this topic, nearly every fourth tick started at about 20cpu (without a script restart in the last 20 ticks)
-
Unusual high used-cpu values right at the start of the loop
I get some straneg and high used CPU values right at the start of my script. To check it, my main loop looks like this:
module.exports.loop = function () {
if (!Memory['colony'].active) {
console.log('CPU:' + Game.cpu.getUsed() +' Bucket: ' + Game.cpu.bucket);
return;
}
}
So I'm only accessing memory once, print the getUsed value and return. Even though, the values are not constant at all.
When I do a manual JSON.parse(MemoryRaw.get()), I can see, that the deserialization takes about 5CPU, which is about the same as my scripts base cpu load.So two questions: Is 5 CPU an ok value for deserialization of 400kb memory? Few days ago, it was at 0.5 cpu for one day Not sure, which of those two values has been the wrong one.
And then there are those spikes of up to 28CPU. (The script did not restart. If code outside of module.exports.loop would have been executed, this would have resultet in separate console.log. The last time this happened was more than 20 ticks before i captured the following output.
Remember, that my loop returns immediately after the console.log, so there has been no changes to memory for the duration of that printout.