143 posts
Location
still looking....
Posted 22 March 2015 - 08:25 PM
Hi,
while experimenting with modems and such, I came across a limit of messages per second that could be received by the modem. The computer would freeze up. Is this a limitation on per channel basis? or is this server-wide or is it per computer?
Thanks,
355 posts
Location
Germany
Posted 22 March 2015 - 08:55 PM
Where did you came accross such limit? In the mods config file?
143 posts
Location
still looking....
Posted 22 March 2015 - 09:18 PM
Where did you came accross such limit? In the mods config file?
In multiple servers
871 posts
Posted 22 March 2015 - 10:43 PM
modem messages are recieved as events. The only way to pull an event is by yielding, usually by calling os.pullEvent or os.pullEventRaw. Any yield will actually pause until at least the next tick, whether there was an event already or not. So, if you're ignoring all events except for modem messages, the limit would be 20 messages/second received and processed by one computer, which is the rate of minecraft ticks, 20 per second. There is no limit on how fast you can send events, though, so watch out, or you can create problems for yourself (And in extreme cases, your server!) if you're sending faster than that. However, I'm fairly certain that rednet changes that, if the raw modem messages received are rednet messages, they get translated and a rednet event is queued, which means for rednet messages, the limit may well drop to 10 a second.
7083 posts
Location
Tasmania (AU)
Posted 22 March 2015 - 11:02 PM
In very rare cases, modem messages will not appear in the target's event queue for no apparent reason. Or at least, this was true quite a few CC versions ago - I've not tried the same rednet-intensive scripts for a while, but when I do, I build in code to deal with "missing messages" (eg "if not received within X amount of time, request a resend", that sort of thing).
Really I can't properly comment on what might be going on in the OP's case without seeing the code involved.
Any yield will actually pause until at least the next tick, whether there was an event already or not.
Actually no, though it's true that any
timer you set will take at least a tick to resolve. I suspect that you're attributing the time it takes for
the other systems in your world to run their code to being a general yielding delay, but if you test with a single computer in a new world you'll find it's really pretty much instant.
143 posts
Location
still looking....
Posted 23 March 2015 - 12:53 AM
modem messages are recieved as events. The only way to pull an event is by yielding, usually by calling os.pullEvent or os.pullEventRaw. Any yield will actually pause until at least the next tick, whether there was an event already or not. So, if you're ignoring all events except for modem messages, the limit would be 20 messages/second received and processed by one computer, which is the rate of minecraft ticks, 20 per second. There is no limit on how fast you can send events, though, so watch out, or you can create problems for yourself (And in extreme cases, your server!) if you're sending faster than that. However, I'm fairly certain that rednet changes that, if the raw modem messages received are rednet messages, they get translated and a rednet event is queued, which means for rednet messages, the limit may well drop to 10 a second.
This is exactly what I was looking for, thank you! I had the problem when I sent more than 20/s and the computer just queued them up. Thank you for the explanation.
Edit: Would it be possible to have more than 20/s or no?
Edited on 22 March 2015 - 11:53 PM
871 posts
Posted 23 March 2015 - 12:01 PM
i thought it was a limit, but bombbloke thinks not, id have to test and see and am not at a compiter with cc to test it on atm.
7083 posts
Location
Tasmania (AU)
Posted 23 March 2015 - 12:02 PM
Spoiler
do
local modem = peripheral.find("modem", function(side, object) object.side = side return true end)
rednet.open(modem.side)
end
rednet.host("RednetSpeedTest", tostring(os.getComputerID()))
print("Searching for buddy...")
local buddy
repeat
local testers = {rednet.lookup("RednetSpeedTest")}
for i = 1, #testers do if testers[i] ~= os.getComputerID() then
buddy = testers[i]
break
end end
until buddy
print("Buddy found, commencing spam...")
local curX, curY = term.getCursorPos()
local lastTime, messages = os.clock(), 0
while true do
local sender, message = rednet.receive("RednetSpeedTest", 1)
if message then
messages = messages + 1
local thisTime = os.clock() - lastTime
if thisTime > 0 then
term.setCursorPos(curX, curY)
term.clearLine()
term.write("Got "..messages.." messages in "..thisTime.."s.")
lastTime = os.clock()
messages = 0
end
end
rednet.send(buddy, "RednetSpeedTest", "RednetSpeedTest")
end
If you're still having trouble working out how to get your
own code working after that,
post a link to it.
Edited on 23 March 2015 - 11:02 AM
143 posts
Location
still looking....
Posted 23 March 2015 - 09:17 PM
Spoiler
do
local modem = peripheral.find("modem", function(side, object) object.side = side return true end)
rednet.open(modem.side)
end
rednet.host("RednetSpeedTest", tostring(os.getComputerID()))
print("Searching for buddy...")
local buddy
repeat
local testers = {rednet.lookup("RednetSpeedTest")}
for i = 1, #testers do if testers[i] ~= os.getComputerID() then
buddy = testers[i]
break
end end
until buddy
print("Buddy found, commencing spam...")
local curX, curY = term.getCursorPos()
local lastTime, messages = os.clock(), 0
while true do
local sender, message = rednet.receive("RednetSpeedTest", 1)
if message then
messages = messages + 1
local thisTime = os.clock() - lastTime
if thisTime > 0 then
term.setCursorPos(curX, curY)
term.clearLine()
term.write("Got "..messages.." messages in "..thisTime.."s.")
lastTime = os.clock()
messages = 0
end
end
rednet.send(buddy, "RednetSpeedTest", "RednetSpeedTest")
end
If you're still having trouble working out how to get your
own code working after that,
post a link to it.
Thanks for the code :)/>
I tested it out and I am getting 1 message per .2s
Apparently you can do 5 messages / sec then?
7083 posts
Location
Tasmania (AU)
Posted 23 March 2015 - 11:30 PM
*facepalm*
Apparently either your Minecraft system is dead slow, or - rather more likely - the other systems in your world are slowing things down. Bear in mind that each ComputerCraft device can only run code while the others are yielding.
"I" can do somewhere over a thousand messages a second with that script running on a couple of computers in a new world.
How far into this thread do you think we'll get before you establish your actual problem…?
143 posts
Location
still looking....
Posted 24 March 2015 - 01:58 AM
*facepalm*
Apparently either your Minecraft system is dead slow, or - rather more likely - the other systems in your world are slowing things down. Bear in mind that each ComputerCraft device can only run code while the others are yielding.
"I" can do somewhere over a thousand messages a second with that script running on a couple of computers in a new world.
How far into this thread do you think we'll get before you establish your actual problem…?
There is no actual problem, I just was seeing if there was a modem message per second limit on CC. On your test, were you using wired or wireless?
7083 posts
Location
Tasmania (AU)
Posted 24 March 2015 - 03:13 AM
Wireless, for all the difference it makes.
See, there's no definite cap on the "rate limit". Modem messages simply tack stuff onto the end of the event queue, and you can pull stuff out of there pretty much instantly - bearing in mind that doing so involves yielding, which gives all the other systems on your server time to execute their code before you get control again, which can potentially slow you down - but that's merely a "processor power" vs "workload" thing.