I'm also using the "my first world" base project for testing, with some extra turf fields and types, also made the map 100x100.
Saving takes around ~10 seconds which is fine. But then loading the map takes about ~10 minutes, and makes the whole thing hang. By selectively disabling loading specific things from the save, I noticed that loading turfs was the big bottleneck here.
Here's the code loading the turfs for reference:
//Turf are special and gotta be created differently
/proc/DeserializeTurf(var/database/db, var/database/query/q, var/instanceid, var/list/rowdata = null, var/recursive_counter)
var/start = world.timeofday
//Skip if cached
if(saved_instances[instanceid])
return saved_instances[instanceid]
if(isnull(rowdata))
q.Add("SELECT * FROM [TABLE_INSTANCES] WHERE `[TBL_FIELD_ID]` = '[instanceid]';")
q.Execute(db)
CheckQueryErrors(q)
if(q.NextRow())
rowdata = q.GetRowData()
if(!length(rowdata))
world.log << "Missing data for saved turf '[instanceid]'"
return null
//Get our area
var/turf/T
var/area/myloc = rowdata[TBL_FIELD_LOC]
if(!isnull(myloc))
myloc = DeserializeInstance(db, q, myloc, null, recursive_counter)
//Get our position
var/turfty = text2path(rowdata[TBL_FIELD_TYPE])
var/x = text2num(rowdata["x"])
var/y = text2num(rowdata["y"])
var/z = text2num(rowdata["z"])
//del(locate(x,y,z))
var/turf/oldturf = locate(x,y,z)
if(oldturf.loc)
var/area/A = oldturf.loc
A.contents.Remove(oldturf)
//turfs_to_delete += oldturf
T = new turfty(locate(x,y,z))
//Add us to our area
if(istype(myloc))
myloc.contents.Add(T)
T.deserialize(db,instanceid)
saved_instances[instanceid] = T
//world << "Turf \ref[T]:area([T.loc]):([T.x], [T.y], [T.z])"
//world << "##T \ref[T] loaded in [(world.timeofday - start) / 10] -- RECURSION [recursive_counter]"
SSTATS.total_time_turfs += (world.timeofday - start)
return saved_instances[instanceid]
I was wondering if there was anything to be done to make loading turfs from a save faster? Seems like having to overwrite existing turfs and create a new turf is really slow done this way, but I can't find much info on a faster way to do it?