[MIRROR] Startup Time Optimization (#10940)

Co-authored-by: ShadowLarkens <shadowlarkens@gmail.com>
Co-authored-by: Cameron Lennox <killer65311@gmail.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-05-24 18:44:27 -07:00
committed by GitHub
parent 51d87471f7
commit 7f4da4eb22
13 changed files with 60 additions and 24 deletions

View File

@@ -56,6 +56,28 @@
#endif #endif
return (AIR_BLOCKED*!CanZASPass(other, FALSE))|(ZONE_BLOCKED*!CanZASPass(other, TRUE)) return (AIR_BLOCKED*!CanZASPass(other, FALSE))|(ZONE_BLOCKED*!CanZASPass(other, TRUE))
/turf/proc/self_airblock()
if(blocks_air & AIR_BLOCKED)
return BLOCKED
if(blocks_air & ZONE_BLOCKED)
return ZONE_BLOCKED
var/result = 0
for(var/atom/movable/M as anything in contents)
switch(M.can_atmos_pass)
if(ATMOS_PASS_YES)
continue
if(ATMOS_PASS_NO)
return BLOCKED
if(ATMOS_PASS_DENSITY)
if(M.density)
return BLOCKED
if(ATMOS_PASS_PROC)
result |= M.c_airblock(src)
if(result == BLOCKED) return BLOCKED
return result
/turf/c_airblock(turf/other) /turf/c_airblock(turf/other)
#ifdef ZASDBG #ifdef ZASDBG
ASSERT(isturf(other)) ASSERT(isturf(other))

View File

@@ -55,7 +55,7 @@
return return
if(direction == "N/A") if(direction == "N/A")
if(!(T.c_airblock(T) & AIR_BLOCKED)) if(!(T.self_airblock() & AIR_BLOCKED))
to_chat(mob, "The turf can pass air! :D") to_chat(mob, "The turf can pass air! :D")
else else
to_chat(mob, "No air passage :x") to_chat(mob, "No air passage :x")

View File

@@ -11,7 +11,7 @@
vis_contents -= graphic_remove vis_contents -= graphic_remove
/turf/proc/update_air_properties() /turf/proc/update_air_properties()
var/block = c_airblock(src) var/block = self_airblock()
if(block & AIR_BLOCKED) if(block & AIR_BLOCKED)
//dbg(blocked) //dbg(blocked)
return 1 return 1
@@ -139,8 +139,7 @@
c_copy_air() c_copy_air()
zone = null //Easier than iterating through the list at the zone. zone = null //Easier than iterating through the list at the zone.
var/s_block // CHOMPEdit var/s_block = self_airblock()
ATMOS_CANPASS_TURF(s_block, src, src)
if(s_block & AIR_BLOCKED) if(s_block & AIR_BLOCKED)
#ifdef ZASDBG #ifdef ZASDBG
if(verbose) to_world("Self-blocked.") if(verbose) to_world("Self-blocked.")

View File

@@ -7,8 +7,10 @@
// This allows us to get the real details of everything lagging at server start. // This allows us to get the real details of everything lagging at server start.
// world.Profile(PROFILE_START) // world.Profile(PROFILE_START)
#if defined(ENABLE_BYOND_TRACY) #if defined(ENABLE_BYOND_TRACY)
var/tracy_init = call_ext("prof.dll", "init")() // Setup Tracy integration var/tracy_init = LIBCALL("prof.dll", "init")() // Setup Tracy integration
if(tracy_init != "0") if(length(tracy_init) != 0 && tracy_init[1] == ".") // it returned the output file
to_world_log("TRACY Enabled, streaming to [tracy_init].")
else if(tracy_init != "0")
CRASH("Tracy init error: [tracy_init]") CRASH("Tracy init error: [tracy_init]")
#endif #endif
// After that, the debugger is initialized. // After that, the debugger is initialized.

View File

@@ -219,7 +219,7 @@ Total Unsimulated Turfs: [world.maxx*world.maxy*world.maxz - simulated_turf_coun
var/turf/T = currentrun[currentrun.len] var/turf/T = currentrun[currentrun.len]
currentrun.len-- currentrun.len--
//check if the turf is self-zone-blocked //check if the turf is self-zone-blocked
if(T.c_airblock(T) & ZONE_BLOCKED) if(T.self_airblock() & ZONE_BLOCKED)
selfblock_deferred += T selfblock_deferred += T
if(MC_TICK_CHECK) if(MC_TICK_CHECK)
return return

View File

@@ -43,7 +43,7 @@
/turf/simulated/floor/LateInitialize() /turf/simulated/floor/LateInitialize()
. = ..() . = ..()
update_icon(1) update_icon()
/turf/simulated/floor/proc/swap_decals() /turf/simulated/floor/proc/swap_decals()
var/current_decals = decals var/current_decals = decals

View File

@@ -178,7 +178,6 @@ var/list/mining_overlay_cache = list()
update_general() update_general()
/turf/simulated/mineral/proc/update_general() /turf/simulated/mineral/proc/update_general()
update_icon(1)
recalculate_directional_opacity() recalculate_directional_opacity()
if(ticker && ticker.current_state == GAME_STATE_PLAYING) if(ticker && ticker.current_state == GAME_STATE_PLAYING)
reconsider_lights() reconsider_lights()
@@ -212,7 +211,7 @@ var/list/mining_overlay_cache = list()
make_ore() make_ore()
if(prob(20)) if(prob(20))
overlay_detail = "asteroid[rand(0,9)]" overlay_detail = "asteroid[rand(0,9)]"
update_icon(1) update_icon(!mapload)
if(density && mineral) if(density && mineral)
. = INITIALIZE_HINT_LATELOAD . = INITIALIZE_HINT_LATELOAD
if(random_icon) if(random_icon)
@@ -223,8 +222,7 @@ var/list/mining_overlay_cache = list()
if(density && mineral) if(density && mineral)
MineralSpread() MineralSpread()
/turf/simulated/mineral/update_icon(var/update_neighbors) /turf/simulated/mineral/update_icon(var/update_neighbors, ignore_list)
cut_overlays() cut_overlays()
//We are a wall (why does this system work like this??) //We are a wall (why does this system work like this??)
@@ -240,7 +238,7 @@ var/list/mining_overlay_cache = list()
//Apply overlays if we should have borders //Apply overlays if we should have borders
for(var/direction in GLOB.cardinal) for(var/direction in GLOB.cardinal)
var/turf/T = get_step(src,direction) var/turf/T = get_step(src,direction)
if(istype(T) && !T.density) if(T && !T.density)
add_overlay(get_cached_border(rock_side_icon_state,direction,icon,rock_side_icon_state)) add_overlay(get_cached_border(rock_side_icon_state,direction,icon,rock_side_icon_state))
if(archaeo_overlay) if(archaeo_overlay)
@@ -260,13 +258,12 @@ var/list/mining_overlay_cache = list()
//Apply overlays if there's space //Apply overlays if there's space
for(var/direction in GLOB.cardinal) for(var/direction in GLOB.cardinal)
if(istype(get_step(src, direction), /turf/space) && !istype(get_step(src, direction), /turf/space/cracked_asteroid)) var/turf/T = get_step(src, direction)
if(istype(T, /turf/space) && !istype(T, /turf/space/cracked_asteroid))
add_overlay(get_cached_border("asteroid_edge",direction,icon,"asteroid_edges", 0)) add_overlay(get_cached_border("asteroid_edge",direction,icon,"asteroid_edges", 0))
//Or any time //Or any time
else else
var/turf/T = get_step(src, direction) if(T?.density)
if(istype(T) && T.density)
add_overlay(get_cached_border(rock_side_icon_state,direction,rock_icon_path,rock_side_icon_state)) add_overlay(get_cached_border(rock_side_icon_state,direction,rock_icon_path,rock_side_icon_state))
if(overlay_detail) if(overlay_detail)
@@ -274,12 +271,16 @@ var/list/mining_overlay_cache = list()
if(update_neighbors) if(update_neighbors)
for(var/direction in GLOB.alldirs) for(var/direction in GLOB.alldirs)
if(istype(get_step(src, direction), /turf/simulated/mineral)) var/turf/T = get_step(src, direction)
var/turf/simulated/mineral/M = get_step(src, direction) // don't double update during cave generation
M.update_icon() if(LAZYACCESS(ignore_list, T))
if(istype(get_step(src, direction), /turf/simulated/wall/solidrock)) continue
var/turf/simulated/wall/solidrock/M = get_step(src, direction)
M.update_icon() if(istype(T, /turf/simulated/mineral))
T.update_icon()
if(istype(T, /turf/simulated/wall/solidrock))
T.update_icon()
/turf/simulated/mineral/ex_act(severity) /turf/simulated/mineral/ex_act(severity)

View File

@@ -2,6 +2,7 @@
iterations = 5 iterations = 5
descriptor = "moon caves" descriptor = "moon caves"
var/list/ore_turfs = list() var/list/ore_turfs = list()
var/list/turfs_changed
var/make_cracked_turfs = TRUE var/make_cracked_turfs = TRUE
/datum/random_map/automata/cave_system/no_cracks /datum/random_map/automata/cave_system/no_cracks
@@ -68,6 +69,7 @@
new /obj/structure/mob_spawner/scanner/mining_animals(T) //CHOMP Add new /obj/structure/mob_spawner/scanner/mining_animals(T) //CHOMP Add
else else
T.make_wall() T.make_wall()
LAZYSET(turfs_changed, T, TRUE)
if(T.density && !T.ignore_oregen) if(T.density && !T.ignore_oregen)
if(map[current_cell] == DOOR_CHAR) if(map[current_cell] == DOOR_CHAR)
@@ -77,3 +79,11 @@
get_additional_spawns(map[current_cell],T,get_spawn_dir(x, y)) get_additional_spawns(map[current_cell],T,get_spawn_dir(x, y))
//VOREStation Edit End //VOREStation Edit End
return T return T
/datum/random_map/automata/cave_system/apply_to_map()
. = ..()
for(var/turf/simulated/mineral/T as anything in turfs_changed)
T.update_icon(1, turfs_changed)
LAZYCLEARLIST(turfs_changed)

Binary file not shown.

BIN
prof.dll

Binary file not shown.

Binary file not shown.

View File

@@ -20,6 +20,7 @@ const_format = "0.2.33"
eyre = "0.6.12" eyre = "0.6.12"
meowtonin = { git = "https://github.com/Absolucy/meowtonin.git" } meowtonin = { git = "https://github.com/Absolucy/meowtonin.git" }
rand = "0.8.5" rand = "0.8.5"
rayon = "1.10.0"
[build-dependencies] [build-dependencies]
bosion = "1.1.1" bosion = "1.1.1"

View File

@@ -1,5 +1,6 @@
use meowtonin::{value::ByondValue, ByondError, ByondResult}; use meowtonin::{value::ByondValue, ByondError, ByondResult};
use rand::{distributions::Bernoulli, prelude::Distribution}; use rand::{distributions::Bernoulli, prelude::Distribution};
use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};
const CELL_THRESHOLD: usize = 5; const CELL_THRESHOLD: usize = 5;
@@ -18,7 +19,7 @@ pub fn generate_automata(
let mut map = seed_map(limit_x, limit_y, initial_wall_cell)?; let mut map = seed_map(limit_x, limit_y, initial_wall_cell)?;
for _ in 1..iterations { for _ in 1..iterations {
map = map map = map
.iter() .par_iter()
.enumerate() .enumerate()
.map(|(i, _)| { .map(|(i, _)| {
let mut count = 0; let mut count = 0;