ID:2699645
 
(See the best response by MrStonedOne.)
Problem description:

I am using dantom dbs database library to connect and make queries to my MySQL server but noticed that it takes considerable time to connection and execute queries. (about 1 cpu every connect call and 0.08 per query) which wouldn't be as big a deal if the world didn't stall until it finished.

Is there anyway to make these calls more efficient or have them run async without stalling the world? The whole point of me using a MySQL server is to have my saves connected between servers but it doesn't seem like using a MySQL hosted save system in a multiplayer setting is doable if the world stalls while each query executes
Hi there. I'm new to BYOND, so excuse me because I'm not 100% correct. I'm not sure how this works yet, but I've managed to do faux-async with spawn(-1)

obj
emptyTilledLand
icon = 'tilledDirt.dmi'
verb/plantPotato()
set src in view(0)
usr << "Planting potato"
// faux async, without this, the emptyTilledLand gets
// deleted without spawning a filledTilledLand
spawn(-1)
new/obj/filledTilledLand/potatoLand/potatoLandGrowing(usr.loc).plantPotatoInSoil()
del src
Best response
Is there anyway to make these calls more efficient or have them run async without stalling the world?

Not with the byond system.

/tg/ uses an external dll written in rust to provide this functionality, it supports both hard blocking (what byond does), soft blocking (like a sleep) and full non-blocking, (the command returns immediately and you have to use another command to check on progress and fetch the results)

https://github.com/tgstation/rust-g
In response to MrStonedOne
Hey I know this is a bit late but I started using rust-g and looked at tgstation as an example of how it's used but I'm a bit confused.

From what I see `rustg_sql_connect_pool` is not async. so is that just called once and then there's a constant connection open that's never closed? or are connections made using something else.

thanks
The connection is persistent. You'll want to remove it yourself using rustg_sql_disconnect_pool(handle).

Login to reply.