{"action":"created","issue":{"url":"https://api.github.com/repos/minetest/minetest_game/issues/797","labels_url":"https://api.github.com/repos/minetest/minetest_game/issues/797/labels{/name}","comments_url":"https://api.github.com/repos/minetest/minetest_game/issues/797/comments","events_url":"https://api.github.com/repos/minetest/minetest_game/issues/797/events","html_url":"https://github.com/minetest/minetest_game/issues/797","id":127864235,"number":797,"title":"minetest.after is unreliable","user":{"login":"sofar","id":1880041,"avatar_url":"https://avatars.githubusercontent.com/u/1880041?v=3","gravatar_id":"","url":"https://api.github.com/users/sofar","html_url":"https://github.com/sofar","followers_url":"https://api.github.com/users/sofar/followers","following_url":"https://api.github.com/users/sofar/following{/other_user}","gists_url":"https://api.github.com/users/sofar/gists{/gist_id}","starred_url":"https://api.github.com/users/sofar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sofar/subscriptions","organizations_url":"https://api.github.com/users/sofar/orgs","repos_url":"https://api.github.com/users/sofar/repos","events_url":"https://api.github.com/users/sofar/events{/privacy}","received_events_url":"https://api.github.com/users/sofar/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-21T07:39:36Z","updated_at":"2016-01-30T19:26:49Z","closed_at":"2016-01-21T09:08:59Z","body":"Minetest.after is a trivial function that promises to schedule a function with a resolution of ~1 second. However, in my tests it shows that on a completely idle server, no mods, it fails to schedule even within 2-3 seconds of the requested interval.\r\n\r\nHow I measured:\r\n\r\n```\r\ndiff --git a/mods/default/init.lua b/mods/default/init.lua\r\nindex 6f1b148..2f86513 100644\r\n--- a/mods/default/init.lua\r\n+++ b/mods/default/init.lua\r\n@@ -46,3 +46,16 @@ dofile(minetest.get_modpath(\"default\")..\"/player.lua\")\r\n dofile(minetest.get_modpath(\"default\")..\"/trees.lua\")\r\n dofile(minetest.get_modpath(\"default\")..\"/aliases.lua\")\r\n dofile(minetest.get_modpath(\"default\")..\"/legacy.lua\")\r\n+\r\n+local lasttime = os.time()\r\n+local function timertest()\r\n+       local newtime = os.time()\r\n+       local diff = newtime - lasttime\r\n+       print(\"elapsed: \" .. diff)\r\n+       lasttime = os.time()\r\n+       local new = math.random(1,5)\r\n+       print(\"next: \" .. new)\r\n+       minetest.after(new, timertest)\r\n+end\r\n+\r\n+minetest.after(1, timertest)\r\n\r\n```\r\n\r\nThe measured data:\r\n```\r\nnext: 5 elapsed: 6\r\nnext: 4 elapsed: 6\r\nnext: 2 elapsed: 4\r\nnext: 5 elapsed: 7\r\nnext: 3 elapsed: 5\r\nnext: 5 elapsed: 8\r\nnext: 3 elapsed: 6\r\nnext: 1 elapsed: 5\r\nnext: 1 elapsed: 4\r\nnext: 3 elapsed: 6\r\nnext: 4 elapsed: 7\r\nnext: 5 elapsed: 9\r\nnext: 5 elapsed: 8\r\nnext: 4 elapsed: 7\r\nnext: 2 elapsed: 5\r\nnext: 3 elapsed: 6\r\nnext: 4 elapsed: 8\r\nnext: 5 elapsed: 8\r\n```\r\n\r\nIn not a single sample did the timer execute within 1 seconds of the requested timeout. In most cases, it was delayed by an additional 3 seconds, sometimes even 4 seconds.\r\n\r\nAs a timer function, I expect ```minetest.after()``` to correct for time lost in lag, and immediately expire all timers that are past due, and execute them. This is not happening."},"comment":{"url":"https://api.github.com/repos/minetest/minetest_game/issues/comments/177280880","html_url":"https://github.com/minetest/minetest_game/issues/797#issuecomment-177280880","issue_url":"https://api.github.com/repos/minetest/minetest_game/issues/797","id":177280880,"user":{"login":"0-afflatus","id":7130479,"avatar_url":"https://avatars.githubusercontent.com/u/7130479?v=3","gravatar_id":"","url":"https://api.github.com/users/0-afflatus","html_url":"https://github.com/0-afflatus","followers_url":"https://api.github.com/users/0-afflatus/followers","following_url":"https://api.github.com/users/0-afflatus/following{/other_user}","gists_url":"https://api.github.com/users/0-afflatus/gists{/gist_id}","starred_url":"https://api.github.com/users/0-afflatus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0-afflatus/subscriptions","organizations_url":"https://api.github.com/users/0-afflatus/orgs","repos_url":"https://api.github.com/users/0-afflatus/repos","events_url":"https://api.github.com/users/0-afflatus/events{/privacy}","received_events_url":"https://api.github.com/users/0-afflatus/received_events","type":"User","site_admin":false},"created_at":"2016-01-30T19:26:48Z","updated_at":"2016-01-30T19:26:48Z","body":"As opposed to mintetest.tomorrow() which would infinitely reschedule events into the unspecified future?\r\n\r\nlol sorry"}}