Jump to content




org.luaj...lua_yield() part of Computercraft?(CC 1.58?) Tekkit (1.2.9f)


  • You cannot reply to this topic
2 replies to this topic

#1 derphorse

  • New Members
  • 1 posts

Posted 08 May 2015 - 06:51 PM

I am the server maintainer for a small Minecraft "network". We finally moved Tekkit to a dedicated server which allows me to optimize it.

JvisualVM shows this for CPU time:
Posted Image

Am I right in attributing the lua_yield() to CC?

Is there a best practice to lower the usage?(we have been going around and adding (longer)sleeps to certain programs like clocks)

Thank you for your time.

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 08 May 2015 - 08:39 PM

Why are you concerned about the CPU time when Total Time(CPU) is 0.000 ms?

#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 09 May 2015 - 07:42 AM

Yes, that lua_yield() thread will be related to ComputerCraft, and indeed, you want it active as much as possible - because when it's not active, that's when CC is actually using your processor!

View Postderphorse, on 08 May 2015 - 06:51 PM, said:

Is there a best practice to lower the usage?(we have been going around and adding (longer)sleeps to certain programs like clocks)

Pretty much that sort of thing, yeah... just make sure you're using the relevant event filter when you yield.

For example, a loop which uses this sort of construct:

while true do
  sleep(1)

  if rs.getInput("right") then
    print("Redstone on!")
  end
end

... will use more CPU time then:

while true do
  os.pullEvent("redstone")

  if rs.getInput("right") then
    print("Redstone on!")
  end
end

Another technique is to have systems turned off while they're not in use. This won't affect CPU usage much, but it'll save a little RAM. Scripts such as eg "elevator controllers" typically only need to be running when people are actively using them.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users