Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http.fetch issue #24

Closed
BuckarooBanzay opened this issue Jul 12, 2022 · 2 comments
Closed

http.fetch issue #24

BuckarooBanzay opened this issue Jul 12, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@BuckarooBanzay
Copy link
Member

BuckarooBanzay commented Jul 12, 2022

root@akheron:/data/pandorabox.io/data/minetest# tail -f debug.txt | grep -i mapserver
2022-07-12 18:55:17: WARNING[Server]: [mapserver-bridge] post took 1818357 us
2022-07-12 18:55:21: WARNING[Server]: [mapserver-bridge] post took 1880952 us
2022-07-12 18:55:28: WARNING[Server]: [mapserver-bridge] post took 1806007 us
2022-07-12 18:55:35: WARNING[Server]: [mapserver-bridge] post took 2084787 us
2022-07-12 18:55:37: WARNING[Server]: [mapserver-bridge] post took 1786854 us
2022-07-12 18:55:46: WARNING[Server]: [mapserver-bridge] post took 1983264 us
2022-07-12 18:55:53: WARNING[Server]: [mapserver-bridge] post took 2209469 us
/lua local x = minetest.get_us_time(); local a = {}; mapserver.bridge.add_players(a); print("xxx:" .. #minetest.write_json(a) .. " us:" .. minetest.get_us_time() - x);
/lua local x = minetest.get_us_time(); local a = {}; mapserver.bridge.add_advtrains(a); print("xxx:" .. #minetest.write_json(a) .. " us:" .. minetest.get_us_time() - x);
minetest_1             | xxx:72071 us:30518
minetest_1             | xxx:72045 us:28952
minetest_1             | xxx:2218 us:936

Relevant code:

local t0 = minetest.get_us_time()
-- data to send to mapserver
local data = {}
mapserver.bridge.add_players(data)
mapserver.bridge.add_defaults(data)
if has_advtrains then
-- send trains if 'advtrains' mod installed
mapserver.bridge.add_advtrains(data)
end
if has_locator then
-- send locator beacons
mapserver.bridge.add_locators(data)
end
local json = minetest.write_json(data)
--print(json)--XXX
local t1 = minetest.get_us_time()
local process_time = t1 - t0
if process_time > 50000 then
minetest.log("warning", "[mapserver-bridge] processing took " .. process_time .. " us")
end
local size = string.len(json)
if size > 256000 then
minetest.log("warning", "[mapserver-bridge] json-size is " .. size .. " bytes")
end
http.fetch({
url = url .. "/api/minetest",
extra_headers = { "Content-Type: application/json", "Authorization: " .. key },
timeout = 5,
post_data = json
}, function(res)
local t2 = minetest.get_us_time()
local post_time = t2 - t1
if post_time > 1000000 then -- warn if over a second
minetest.log("warning", "[mapserver-bridge] post took " .. post_time .. " us")
end
if has_monitoring then
metric_post_size.inc(size)
metric_processing_post_time.inc(process_time)
metric_post_time.inc(post_time)
end
-- TODO: error-handling
minetest.after(mapserver.send_interval, send_stats)
end)

@BuckarooBanzay BuckarooBanzay added the bug Something isn't working label Jul 12, 2022
@S-S-X
Copy link
Contributor

S-S-X commented Jul 17, 2022

Remember with priority 2 QoS can also delay request processing if there's many other requests with same or higher priority in queue.
If request ends up in queue then it will be delayed at least until next globalstep, immediate processing happens only if there's enough space in current monitored queue. For priority 2 default limit is 80% of max parallel requests (or curl_parallel_limit * 0.8).

@BuckarooBanzay
Copy link
Member Author

ugh, this was a http-fetch issue but in another mod 🤦 minetest-go/mtui_mod@7ed88c7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants