Skip to content

Commit 0db3259

Browse files
A lot of perf micro-optimisations (#20188)
* Refactors Investigate Log * Speedup character loading * Optimise SSinstancing * Removes both path images * Optimises SSdebugview * CRLF --> LF * Update config/example/config.toml
1 parent bf61975 commit 0db3259

File tree

25 files changed

+82
-148
lines changed

25 files changed

+82
-148
lines changed

code/__DEFINES/hud.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#define PLANT_WEED_HUD "21"// Weed level
2727
#define DIAG_TRACK_HUD "22"// Mech tracking beacon
2828
#define DIAG_AIRLOCK_HUD "23" // Airlock shock overlay
29-
#define DIAG_PATH_HUD "24"//Bot path indicators
29+
//#define DIAG_PATH_HUD "24"//Bot path indicators
3030
#define GLAND_HUD "25"//Gland indicators for abductors
3131

3232
//by default everything in the hud_list of an atom is an image

code/_globalvars/logging.dm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,3 @@ GLOBAL_PROTECT(OOClog)
4949

5050
GLOBAL_DATUM_INIT(logging, /datum/logging, new /datum/logging())
5151

52-
GLOBAL_LIST_INIT(investigate_log_subjects, list("notes", "watchlist", "hrefs"))

code/controllers/configuration/sections/system_configuration.dm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
var/list/topic_ip_ratelimit_bypass = list()
2323
/// Server instance ID
2424
var/instance_id = "paradise_main"
25+
/// Do we want to enable instancing stuff at all?
26+
var/enable_multi_instance_support = FALSE
2527
/// Server internal IP
2628
var/internal_ip = "127.0.0.1"
2729
/// Are we using an external handler for TOS
@@ -36,6 +38,7 @@
3638
CONFIG_LOAD_BOOL(shutdown_on_reboot, data["shutdown_on_reboot"])
3739
CONFIG_LOAD_BOOL(is_production, data["is_production"])
3840
CONFIG_LOAD_BOOL(external_tos_handler, data["external_tos_handler"])
41+
CONFIG_LOAD_BOOL(enable_multi_instance_support, data["enable_multi_instance_support"])
3942

4043
CONFIG_LOAD_STR(topic_key, data["communications_password"])
4144
CONFIG_LOAD_STR(medal_hub_address, data["medal_hub_address"])

code/controllers/subsystem/debugview.dm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ SUBSYSTEM_DEF(debugview)
77
var/list/client/processing = list()
88

99
/datum/controller/subsystem/debugview/fire(resumed)
10+
// Dont generate text if no one is there to look at it
11+
if(!length(processing))
12+
return
13+
1014
// Generate debug text
1115
var/list/entries = list()
1216
entries += "CPU: [round(world.cpu, 1)] | MCPU: [round(world.map_cpu, 1)] | FPS/TPS: [world.fps] | Clients: [length(GLOB.clients)] | BYOND: [world.byond_version].[world.byond_build]"

code/controllers/subsystem/instancing.dm

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ SUBSYSTEM_DEF(instancing)
1414
CRASH("SSinstancing was set to init before SSredis. Who broke it?")
1515

1616
// Dont even bother if we arent connected to redis or the DB
17-
if(!SSdbcore.IsConnected() || !SSredis.connected)
17+
if(!SSdbcore.IsConnected() || !SSredis.connected || !GLOB.configuration.system.enable_multi_instance_support)
1818
flags |= SS_NO_FIRE
1919
return ..()
2020

@@ -43,6 +43,10 @@ SUBSYSTEM_DEF(instancing)
4343
update_playercache()
4444

4545
/datum/controller/subsystem/instancing/proc/execute_command(source, command, list/arguments)
46+
// We aint enabled. Dont bother.
47+
if(!GLOB.configuration.system.enable_multi_instance_support)
48+
return
49+
4650
var/datum/server_command/SC = registered_commands[command]
4751
if(!SC)
4852
CRASH("Attempted to execute command with ID '[command]' from [source], but that command didnt exist!")
@@ -58,6 +62,10 @@ SUBSYSTEM_DEF(instancing)
5862
* Updates the player cache in the DB. Different from heartbeat so we can force invoke it on player operations
5963
*/
6064
/datum/controller/subsystem/instancing/proc/update_playercache(optional_ckey)
65+
// We aint enabled. Dont bother.
66+
if(!GLOB.configuration.system.enable_multi_instance_support)
67+
return
68+
6169
// You may be wondering, why the fuck is an "optional ckey" variable here
6270
// Well, this is invoked in client/New(), and needs to read from GLOB.clients
6371
// However, this proc sleeps, and if you sleep during client/New() once the client is in GLOB.clients, stuff breaks bad
@@ -111,6 +119,10 @@ SUBSYSTEM_DEF(instancing)
111119
* This is called during world/New() instead of on initialize so it can be done *instantly*
112120
*/
113121
/datum/controller/subsystem/instancing/proc/seed_data()
122+
// We aint enabled. Dont bother.
123+
if(!GLOB.configuration.system.enable_multi_instance_support)
124+
return
125+
114126
// We need to seed a lot of keys, so lets just use a key-value-pair-map to do this easily
115127
var/list/kvp_map = list()
116128
kvp_map["server_name"] = GLOB.configuration.general.server_name // Name of the server
@@ -145,6 +157,10 @@ SUBSYSTEM_DEF(instancing)
145157
* ckey - The ckey to check if they are logged into another server
146158
*/
147159
/datum/controller/subsystem/instancing/proc/check_player(ckey)
160+
// We aint enabled. Dont bother.
161+
if(!GLOB.configuration.system.enable_multi_instance_support)
162+
return
163+
148164
// Please see above rant on L127
149165
var/datum/db_query/dbq1 = SSdbcore.NewQuery({"
150166
SELECT server_id, key_value FROM instance_data_cache WHERE server_id IN

code/game/data_huds.dm

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@
4949
hud_icons = list(DIAG_HUD, DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_MECH_HUD, DIAG_BOT_HUD, DIAG_TRACK_HUD, DIAG_AIRLOCK_HUD)
5050

5151
/datum/atom_hud/data/diagnostic/advanced
52-
hud_icons = list(DIAG_HUD, DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_MECH_HUD, DIAG_BOT_HUD, DIAG_TRACK_HUD, DIAG_AIRLOCK_HUD, DIAG_PATH_HUD)
53-
54-
/datum/atom_hud/data/bot_path
55-
hud_icons = list(DIAG_PATH_HUD)
52+
hud_icons = list(DIAG_HUD, DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_MECH_HUD, DIAG_BOT_HUD, DIAG_TRACK_HUD, DIAG_AIRLOCK_HUD)
5653

5754
/datum/atom_hud/abductor
5855
hud_icons = list(GLAND_HUD)

code/game/machinery/tcomms/_base.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ GLOBAL_LIST_EMPTY(tcomms_machines)
149149
*/
150150
/obj/machinery/tcomms/proc/log_action(user, msg, adminmsg = FALSE)
151151
log_game("NTTC: [key_name(user)] [msg]")
152-
log_investigate("[key_name(user)] [msg]", "nttc")
152+
investigate_log("[key_name(user)] [msg]", "nttc")
153153
if(adminmsg)
154154
message_admins("[key_name_admin(user)] [msg]")
155155
/**

code/game/world.dm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ GLOBAL_DATUM(test_runner, /datum/test_runner)
5858

5959
GLOB.timezoneOffset = text2num(time2text(0, "hh")) * 36000
6060

61-
investigate_reset()
62-
6361
update_status()
6462

6563
GLOB.space_manager.initialize() //Before the MC starts up
Lines changed: 23 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,31 @@
1-
//By Carnwennan
1+
// Atom investigate stuff
2+
// All of this is stored in a global list because its faster than file IO and we arent ram constrained like TG -aa07
3+
GLOBAL_LIST_EMPTY(investigate_log_wrapper)
4+
GLOBAL_PROTECT(investigate_log_wrapper)
25

3-
//This system was made as an alternative to all the in-game lists and variables used to log stuff in-game.
4-
//lists and variables are great. However, they have several major flaws:
5-
//Firstly, they use memory. TGstation has one of the highest memory usage of all the ss13 branches.
6-
//Secondly, they are usually stored in an object. This means that they aren't centralised. It also means that
7-
//the data is lost when the object is deleted! This is especially annoying for things like the singulo engine!
8-
#define INVESTIGATE_DIR "data/investigate/"
6+
/atom/proc/investigate_log(message, subject)
7+
if(!message || !subject)
8+
return
99

10-
//SYSTEM
11-
/proc/investigate_subject2file(subject)
12-
return wrap_file("[INVESTIGATE_DIR][subject].html")
10+
if(!(subject in GLOB.investigate_log_wrapper))
11+
GLOB.investigate_log_wrapper[subject] = list()
1312

14-
/proc/investigate_reset()
15-
if(fdel(INVESTIGATE_DIR)) return 1
16-
return 0
17-
18-
/atom/proc/investigate_log(message, subject)
19-
if(!message) return
20-
var/F = investigate_subject2file(subject)
21-
if(!F) return
22-
GLOB.investigate_log_subjects |= subject
23-
F << "<small>[time_stamp()] \ref[src] [ADMIN_COORDJMP(src)] </small> || [src] [message]<br>"
24-
25-
/proc/log_investigate(message, subject)
26-
if(!message) return
27-
var/F = investigate_subject2file(subject)
28-
if(!F) return
29-
GLOB.investigate_log_subjects |= subject
30-
F << "<small>[time_stamp()] || [message]<br>"
13+
GLOB.investigate_log_wrapper[subject] += "<small>[time_stamp()] [UID()] [ADMIN_COORDJMP(src)] </small> || [src] [message]"
3114

3215
//ADMINVERBS
33-
/client/proc/investigate_show( subject in GLOB.investigate_log_subjects )
34-
set name = "Investigate"
16+
/client/proc/investigate_show(subject in GLOB.investigate_log_wrapper)
17+
set name = "Investigate Round Objects"
3518
set category = "Admin"
19+
3620
if(!check_rights(R_ADMIN))
3721
return
38-
switch(subject)
39-
if("notes")
40-
show_note()
41-
42-
if("watchlist")
43-
watchlist_show()
44-
45-
if("hrefs") //persistant logs and stuff
46-
if(GLOB.configuration.logging.href_logging)
47-
if(GLOB.world_href_log)
48-
src << browse(file(GLOB.world_href_log), "window=investigate[subject];size=800x300")
49-
else
50-
to_chat(src, "<font color='red'>Error: admin_investigate: No href logfile found.</font>")
51-
return
52-
else
53-
to_chat(src, "<font color='red'>Error: admin_investigate: Href Logging is not on.</font>")
54-
return
55-
56-
else //general one-round-only stuff
57-
var/F = investigate_subject2file(subject)
58-
if(!F)
59-
to_chat(src, "<font color='red'>Error: admin_investigate: [INVESTIGATE_DIR][subject] is an invalid path or cannot be accessed.</font>")
60-
return
61-
src << browse(F,"window=investigate[subject];size=800x300")
22+
23+
// Should never happen
24+
if(!(subject in GLOB.investigate_log_wrapper))
25+
return
26+
27+
var/list/entries = GLOB.investigate_log_wrapper[subject]
28+
29+
var/datum/browser/B = new(usr, "investigatelog", "Investigate ([subject])", 800, 400)
30+
B.set_content(entries.Join("<br>"))
31+
B.open()

code/modules/admin/admin_verbs.dm

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ GLOBAL_LIST_INIT(admin_verbs_admin, list(
6969
/client/proc/ccbdb_lookup_ckey,
7070
/client/proc/view_instances,
7171
/client/proc/start_vote,
72-
/client/proc/ping_all_admins
72+
/client/proc/ping_all_admins,
73+
/client/proc/show_watchlist
7374
))
7475
GLOBAL_LIST_INIT(admin_verbs_ban, list(
7576
/client/proc/ban_panel,
@@ -996,3 +997,12 @@ GLOBAL_LIST_INIT(admin_verbs_maintainer, list(
996997

997998
log_admin("[key_name(usr)] has [advanced_admin_interaction ? "activated" : "deactivated"] their advanced admin interaction.")
998999
message_admins("[key_name_admin(usr)] has [advanced_admin_interaction ? "activated" : "deactivated"] their advanced admin interaction.")
1000+
1001+
/client/proc/show_watchlist()
1002+
set name = "Show Watchlist"
1003+
set category = "Admin"
1004+
1005+
if(!check_rights(R_ADMIN))
1006+
return
1007+
1008+
watchlist_show()

code/modules/atmospherics/machinery/components/binary_devices/pump.dm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,21 @@ Thus, the two variables affect pump operation are set in New():
3535
/obj/machinery/atmospherics/binary/pump/CtrlClick(mob/living/user)
3636
if(can_use_shortcut(user))
3737
toggle(user)
38+
investigate_log("was turned [on ? "on" : "off"] by [key_name(user)]", "atmos")
3839
return ..()
3940

4041
/obj/machinery/atmospherics/binary/pump/AICtrlClick(mob/living/silicon/user)
4142
toggle(user)
43+
investigate_log("was turned [on ? "on" : "off"] by [key_name(user)]", "atmos")
4244

4345
/obj/machinery/atmospherics/binary/pump/AltClick(mob/living/user)
4446
if(can_use_shortcut(user))
4547
set_max(user)
48+
investigate_log("was set to [target_pressure] kPa by [key_name(user)]", "atmos")
4649

4750
/obj/machinery/atmospherics/binary/pump/AIAltClick(mob/living/silicon/user)
4851
set_max(user)
52+
investigate_log("was set to [target_pressure] kPa by [key_name(user)]", "atmos")
4953

5054
/obj/machinery/atmospherics/binary/pump/on
5155
icon_state = "map_on"

code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,21 @@ Thus, the two variables affect pump operation are set in New():
3232
/obj/machinery/atmospherics/binary/volume_pump/CtrlClick(mob/living/user)
3333
if(can_use_shortcut(user))
3434
toggle(user)
35+
investigate_log("was turned [on ? "on" : "off"] by [key_name(user)]", "atmos")
3536
return ..()
3637

3738
/obj/machinery/atmospherics/binary/volume_pump/AICtrlClick(mob/living/silicon/user)
3839
toggle(user)
40+
investigate_log("was turned [on ? "on" : "off"] by [key_name(user)]", "atmos")
3941

4042
/obj/machinery/atmospherics/binary/volume_pump/AltClick(mob/living/user)
4143
if(can_use_shortcut(user))
4244
set_max(user)
45+
investigate_log("was set to [target_pressure] kPa by [key_name(user)]", "atmos")
4346

4447
/obj/machinery/atmospherics/binary/volume_pump/AIAltClick(mob/living/silicon/user)
4548
set_max(user)
49+
investigate_log("was set to [target_pressure] kPa by [key_name(user)]", "atmos")
4650

4751
/obj/machinery/atmospherics/binary/volume_pump/on
4852
on = TRUE

code/modules/atmospherics/machinery/components/trinary_devices/filter.dm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,21 @@
3838
/obj/machinery/atmospherics/trinary/filter/CtrlClick(mob/living/user)
3939
if(can_use_shortcut(user))
4040
toggle(user)
41+
investigate_log("was turned [on ? "on" : "off"] by [key_name(user)]", "atmos")
4142
return ..()
4243

4344
/obj/machinery/atmospherics/trinary/filter/AICtrlClick(mob/living/silicon/user)
4445
toggle(user)
46+
investigate_log("was turned [on ? "on" : "off"] by [key_name(user)]", "atmos")
4547

4648
/obj/machinery/atmospherics/trinary/filter/AltClick(mob/living/user)
4749
if(can_use_shortcut(user))
4850
set_max(user)
51+
investigate_log("was set to [target_pressure] kPa by [key_name(user)]", "atmos")
4952

5053
/obj/machinery/atmospherics/trinary/filter/AIAltClick(mob/living/silicon/user)
5154
set_max(user)
55+
investigate_log("was set to [target_pressure] kPa by [key_name(user)]", "atmos")
5256

5357
/obj/machinery/atmospherics/trinary/filter/flipped
5458
icon_state = "mmap"

code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@
1919
/obj/machinery/atmospherics/trinary/mixer/CtrlClick(mob/living/user)
2020
if(can_use_shortcut(user))
2121
toggle(user)
22+
investigate_log("was turned [on ? "on" : "off"] by [key_name(user)]", "atmos")
2223
return ..()
2324

2425
/obj/machinery/atmospherics/trinary/mixer/AICtrlClick(mob/living/silicon/user)
2526
toggle(user)
27+
investigate_log("was turned [on ? "on" : "off"] by [key_name(user)]", "atmos")
2628

2729
/obj/machinery/atmospherics/trinary/mixer/AltClick(mob/living/user)
2830
if(can_use_shortcut(user))
2931
set_max(user)
32+
investigate_log("was set to [target_pressure] kPa by [key_name(user)]", "atmos")
3033

3134
/obj/machinery/atmospherics/trinary/mixer/AIAltClick(mob/living/silicon/user)
3235
set_max(user)
36+
investigate_log("was set to [target_pressure] kPa by [key_name(user)]", "atmos")
3337

3438
/obj/machinery/atmospherics/trinary/mixer/flipped
3539
icon_state = "mmap"

code/modules/client/preference/character.dm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103

104104
// Fuckery to prevent null characters
105105
/datum/character_save/New()
106-
randomise()
107106
real_name = random_name(gender, species)
108107

109108
/datum/character_save/proc/save(client/C)

0 commit comments

Comments
 (0)