Wire: Radios have high cpu usage

Created on 8 Feb 2019  路  5Comments  路  Source: wiremod/wire

If you have a bunch of radios (one way) with the max amount of inputs, and wire it to a button (any value, tried with 899999995002880) and start spamming it, the server will start to slow down.

A person came onto the server that I was playing on, and we've experience some server crashes. Looking at logs we saw this:
LUA | 0 lua/entities/gmod_wire_radio.lua:122: ShowOutput | 1 lua/wire/server/radiolib.lua:49: Radio_SendData | 2 lua/entities/gmod_wire_radio.lua:81: ? | 3 [C]:-1: xpcall | 4 lua/wire/server/wirelib.lua:58: TriggerInput | 5 lua/wire/server/wirelib.lua:530: Wire_TriggerOutput END:maxdepth STACK:29: <UserData>, '(Channel 0) Transmit 1:9.8596108894622e+30 2:9.8596108894622e+30 3:9.8596108894622e+30 4:9.8596108894622e+30 5:9.8596108894622e+30 6:9.8596108894622e+30 7:9.8596108894622e+30 8:9.8596108894622e+30 9:9.8596108894622e+30 10:9.8596108894622e+30 11:9.8596108894622e+30 12:9.8596108894622e+30 13:9.8596108894622e+30 14:9.8596108894622e+30 15:9.8596108894622e+30 16:9.8596108894622e+30 17:9.8596108894622e+30 18:9.8596108894622e+30 19:9.8596108894622e+30 20:9.8596108894622e+30 21:9.8596108894622e+30 22:9.8596108894622e+30 23:9.8596108894622e+30 24:9.8596108894622e+30 25:9.8596108894622e+30 26:9.8596108894622e+30 27:9.8596108894622e+30 28:9.8596108894622e+30 29:9.8596108894622e+30 30:9.8596108894622e+30 31:9.8596108894622e+30 32:9.8596108894622e+30 Receive 1:9.5708088510014e+30 2:9.5708088510014e+30 3:9.5708088510014e+30 4:9.5708088510014e+30 5:9.5708088510014e+30 6:9.5708088510014e+30 7:9.5708088510014e+30 8:9.5708088510014e+30 9:9.5708088510014e+30 10:9.5708088510014e+30 11:9.5708088510014e+30 12:9.5708088510014e+30 13:9.5708088510014e+30 14:9.5708088510014e+30 15:9.5708088510014e+30 16:9.5708088510014e+30', LN17, LN32, LN1, LN17, '(Channel 0) Transmit 1:9.8596108894622e+30 2:9.8596108894622e+30 3:9.8596108894622e+30 4:9.8596108894622e+30 5:9.8596108894622e+30 6:9.8596108894622e+30 7:9.8596108894622e+30 8:9.8596108894622e+30 9:9.8596108894622e+30 10:9.8596108894622e+30 11:9.8596108894622e+30 12:9.8596108894622e+30 13:9.8596108894622e+30 14:9.8596108894622e+30 15:9.8596108894622e+30 16:9.8596108894622e+30 17:9.8596108894622e+30 18:9.8596108894622e+30 19:9.8596108894622e+30 20:9.8596108894622e+30 21:9.8596108894622e+30 22:9.8596108894622e+30 23:9.8596108894622e+30 24:9.8596108894622e+30 25:9.8596108894622e+30 26:9.8596108894622e+30 27:9.8596108894622e+30 28:9.8596108894622e+30 29:9.8596108894622e+30 30:9.8596108894622e+30 31:9.8596108894622e+30 32:9.8596108894622e+30
9.8596108894622e+30 mustve been the value they selected to use. Maybe clamp it to 2^31-1 or limit amount of radios people can spawn? This is also the contraption they used:
contraption

Bug Enhancement

Most helpful comment

Inputs can be triggered about 10 times per frame and with 100 inputs connected sequentially (so it builds a big stack) it adds up I guess. That code needs refactoring though, for sure.

All 5 comments

I solved it on my server years ago by just lower sbox_maxradios or whatever it is. Basically it's just TriggerInput spam.

Why would any amount of trigger input spam cause the server to lag (unless it's wired into an infinite loop?)

I checked the code and while the radio is one of the oldest untouched pieces of code in all of wire, it doesn't seem to be that bad

Inputs can be triggered about 10 times per frame and with 100 inputs connected sequentially (so it builds a big stack) it adds up I guess. That code needs refactoring though, for sure.

recon. needs refactoring.

Looks like the problem is they can have 32 inputs/ouputs running through an inefficient radio library ~7 times per radio per frame.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adosikas picture adosikas  路  5Comments

CaptainPRICE picture CaptainPRICE  路  6Comments

ghost picture ghost  路  9Comments

CaptainPRICE picture CaptainPRICE  路  4Comments

Anticept picture Anticept  路  5Comments