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

Custom encode/decode parameters #43

Open
blobles-dev opened this issue Dec 31, 2024 · 0 comments
Open

Custom encode/decode parameters #43

blobles-dev opened this issue Dec 31, 2024 · 0 comments

Comments

@blobles-dev
Copy link

blobles-dev commented Dec 31, 2024

Issue: Encoding large data for networking causes thread locking

Scenario: I network a large table - express.send locks main thread for 0.3s~ (which is unacceptable for loading inventories on player join for example).

Proposed resolution:

I first solved this by chunking my table and then sending chunked gm_express (boo!) messages, which is a bit janky. If any of the messages fail, then the data can't be reconstructed. My current working resolution involved gutting a lot of the core addon removing encode/decode and sending a giant serialised encoded string (serialising/encoding was done in chunks over a timer to prevent threadlocking) sending my string via express.send takes 0.004s which is a massive improvement over the original 0.3s. I have not been able to implement the hashing functionality, but I don't utilise it anyway

Itd be useful if we could specify how the data is encoded or decoded so we can avoid these thread locks through various means - networking data fast is great, but if we're locking up the server thread to encode the data a lot of the use cases are moot.

My idea is essentially..

express.send("msg", data, function(enc)
-- encode data
return specialencode(enc)
end)

Of course, we would need to specify on the receiver how the data is decoded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant