experimental caching performance tweaks (#3364)

Changes the asset cache's on-connect cache to use a ticking subsystem instead of sleeps and timers to slowly send assets to clients.
This commit is contained in:
Lohikar
2017-09-02 13:35:03 -05:00
committed by Erki
parent 08dcdba926
commit e1f84a756e
3 changed files with 53 additions and 21 deletions
+3 -14
View File
@@ -25,7 +25,7 @@ You can set verify to TRUE if you want send() to sleep until the client has the
//This proc sends the asset to the client, but only if it needs it.
//This proc blocks(sleeps) unless verify is set to false
/proc/send_asset(var/client/client, var/asset_name, var/verify = TRUE)
/proc/send_asset(client/client, asset_name, verify = TRUE)
if(!istype(client))
if(ismob(client))
var/mob/M = client
@@ -72,7 +72,7 @@ You can set verify to TRUE if you want send() to sleep until the client has the
return 1
//This proc blocks(sleeps) unless verify is set to false
/proc/send_asset_list(var/client/client, var/list/asset_list, var/verify = TRUE)
/proc/send_asset_list(client/client, list/asset_list, verify = TRUE)
if(!istype(client))
if(ismob(client))
var/mob/M = client
@@ -122,20 +122,9 @@ You can set verify to TRUE if you want send() to sleep until the client has the
return 1
//This proc will download the files without clogging up the browse() queue, used for passively sending files on connection start.
//The proc calls procs that sleep for long times.
/proc/getFilesSlow(var/client/client, var/list/files, var/register_asset = TRUE)
for(var/file in files)
if (!client)
break
if (register_asset)
register_asset(file,files[file])
send_asset(client,file)
sleep(0) //queuing calls like this too quickly can cause issues in some client versions
//This proc "registers" an asset, it adds it to the cache for further use, you cannot touch it from this point on or you'll fuck things up.
//if it's an icon or something be careful, you'll have to copy it before further use.
/proc/register_asset(var/asset_name, var/asset)
/proc/register_asset(asset_name, asset)
SSassets.cache[asset_name] = asset
//These datums are used to populate the asset cache, the proc "register()" does this.
+2 -3
View File
@@ -380,6 +380,7 @@
admins -= src
directory -= ckey
clients -= src
SSassets.handle_disconnect(src)
return ..()
@@ -491,9 +492,7 @@
//send resources to the client. It's here in its own proc so we can move it around easiliy if need be
/client/proc/send_resources()
spawn (10) //removing this spawn causes all clients to not get verbs.
//Precache the client with all other assets slowly, so as to not block other browse() calls
getFilesSlow(src, SSassets.cache, register_asset = FALSE)
SSassets.handle_connect(src)
/mob/proc/MayRespawn()
return 0