What I meant by “costing you extra” is the size of the data sent. For example, consider the following:
reliableRemote:FireAllClients(workspace:GetServerTimeNow())
The above call takes 9 bytes (overhead) + 9 bytes (f64) = 18 bytes. If you make the same call using ByteNet, it will take 9 bytes + 12 bytes (size 9 buffer: 1 byte ID, 8 bytes f64) = 21 bytes. The bytes used to send a buffer vary based on its length; you can experiment using the following (in a module script):
local UnreliableRemoteEvent = PATH_TO_REMOTE
local BIG_STRING = string.rep("i", 905)
return function(...)
UnreliableRemoteEvent:FireAllClients(BIG_STRING, ...)
end
So the converted data in this case is slightly larger. The difference is negligible, but it’s there, and that was what I was trying to point out.
If you used a second unreliable event, you would not need to write a packet ID into your buffer.
You would also not need to write any more data about the total length of the serialized data (unlike ByteNet arrays and maps, which require 2 bytes to write the number of elements, or VLQ), as you would simply read the entire buffer.
Overall, as you said, these reductions are pretty negligible.
However, you still should be merging buffers when possible instead of sending them independently.
Merging buffers of the same structure is beneficial because Roblox sends extra bytes depending on the size of the buffer being sent, and these extra bytes are especially noticeable for smaller size buffers. Merging into one large buffer would cut down on this compared to sending several smaller buffers individually, as Roblox compresses large buffers when it can over the network by default (since compression works best on data with repeating structures, you’ll see some nice reductions most of the time).
Example:
-- 40 size 9 buffers merged into one
local x = buffer.create(9 * 40)
for i = 0, 39 do
local b = buffer.create(9)
buffer.writef64(b, 0, os.clock() + math.random(-1e5, 1e5))
buffer.writeu8(b, 8, math.random(0, 250))
buffer.copy(x, i * 9, b)
end
payloadSize(x) -- The module script function
-- Result: ~360 bytes (varies, but not by much)
-- 40 separate size 9 buffers
for i = 0, 39 do
local b = buffer.create(9)
buffer.writef64(b, 0, os.clock() + math.random(-1e5, 1e5))
buffer.writeu8(b, 8, math.random(0, 250))
payloadSize(b)
end
-- Result: 480 bytes (40 * 12 bytes each)