Game.maps.describeExits() takes an obscenely large amount of cpu


  • Culture

    The script I used is below- you can one line it on the console if you want. This shows the function Game.map.describeExists, which is currently listed as low cost, taking 156 cpu. This is a bit of an outlier, but when I was benchmarking it yesterday it was taking 7 to 11 cpu per call pretty consistently.

     

    var start = Game.cpu.getUsed();

    Game.map.describeExits('E34N31');

    var end = Game.cpu.getUsed();

    console.log(end - start)

     

    156.110706



  • That is... interesting.


    I have two scouts constantly running around using that command. I just tried it. With both scouts doing this, one reported CPU costs as you expect, but the other is reporting what you say, 7-11, sometimes as high as 20.

    Oh man, I've spent the last week optimizing my worker code because of my CPU Spikes. But I just watched my CPU spikes happening exactly with my scouts using this command and getting CPU of 20+. Thank you so much, you've discovered my CPU hog. 



  • I see the same thing.  I had originally had my own implementation because I hadn't noticed the existence of Game.map.describeExits.  When I removed mine and switched to the official version, I saw it show up in my profiler reports with an alarmingly high value for something that's labeled as "Low" cost in the API docs.



  • I'm noticing the same thing. I've been wondering what was eating my CPU, and my lone scout uses up around 20 CPU every time Game.map.describeExits ist called.

    Considering it's documented with LOW CPU usage I'm guessing something's broken here 😉


  • Dev Team

    Could you please check if it consumes CPU only on the first method invocation within the tick, or the following calls also consume the same amount of CPU?



  • It does seem to get better: 

    for (var i=0;i<5;i++){var start = Game.cpu.getUsed();Game.map.describeExits('E50S46');var end = Game.cpu.getUsed();console.log(end - start);}
     
     
    9.147943000000005
     
    0.015506999999999493
     
    0.006104000000000553
     
    0.004482000000002984
     
    0.004599000000006015

  • Dev Team

    We've just deployed a hotfix addressing this, please try again and check if it's back to normal now.



  • Looks good, taking between 0.002 and 0.2 CPU each call, even on the first call.