How do remotes send data?

To optimize bandwidth efficiency, I want to know exactly how remotes send data. As in, I want to know how packets are sent for specific variants.

Example: Does sending an Instance over the network only send a memory address or something similar? Is sending an Instance more optimal than sending a string?

How are tables sent? In a binary format? What does that look like in terms of bandwidth?

Does Roblox automatically use string interning for remotes if it can to save on bandwidth?

Etc etc etc.

5 Likes

It sends an object reference, yes. If the instance only exists on one network node and not the other, the reference would become nil on the side where it does not exist.

I am not aware of how the other implementation details you are asking about work, but considering remotes tend to reduce mixed tables to arrays, I assume it has an intermediary step where it is put to JSON or JSON-like format.

1 Like

Thank you for this specific detail, at least, should make for some nice small optimizations. Would still love to see the exacts on how this stuff works.

Expanding on this, Instance references are sent in the form of a 32 bit integer identifier which the client and server share.
(At least someone mentioned it being in an old post regarding the same thing.)

2 Likes

Expanding on this, Roblox sends now the scope (client or server) for instances that haven’t been “cached”.

1 Like

To give you a rough idea of what a packet would look like for a few examples without going into too much detail:

Event:FireEvent(1.5, Workspace, true)
  • ~13 bytes for header
  • 8 bytes for double value (Roblox may optimize this to 4 bytes, not sure)
  • 5 bytes for Workspace instance (4 bytes for the instance identifier + some extra information)
  • 1 byte for bool value (don’t know why they use a whole byte)
local value1 = "String1"
local value2 = "String2"
Event:FireEvent(Enum.CameraType.Fixed, value1, value2, value1, Vector3.new(1, 2, 3))
  • ~13 bytes for header
  • 3-6 bytes for enum
  • 1 byte (if cached) or 5 + string.len(value1) bytes
  • 1 byte (if cached) or 5 + string.len(value2) bytes
  • 1 byte (definitely cached because we just sent it)
  • 12 bytes (vectors consist of 3 float values for x, y, and z)

Anyways, you shouldn’t worry about things like this. That’s Roblox’s job. Assume most things are optimized (like the string caching) and only the minimum amount needed is sent.

8 Likes