mirror of https://github.com/dsrw/enu.git
Voxel task throttling (wip)
This commit is contained in:
parent
0ce22b4395
commit
5b304e9697
|
@ -275,7 +275,7 @@ proc worker_thread(params: (ZenContext, GameState)) {.gcsafe.} =
|
|||
elif NeedsRestart.added:
|
||||
running = false
|
||||
|
||||
const max_time = (1.0 / 30.0).seconds
|
||||
const max_time = (1.0 / 120.0).seconds
|
||||
const min_time = (1.0 / 120.0).seconds
|
||||
const auto_save_interval = 30.seconds
|
||||
const backup_interval = 15.minutes
|
||||
|
@ -311,7 +311,7 @@ proc worker_thread(params: (ZenContext, GameState)) {.gcsafe.} =
|
|||
|
||||
var batched: HashSet[Unit]
|
||||
|
||||
while Zen.thread_ctx.pressure < 0.9 and to_process.len > 0 and
|
||||
while Zen.thread_ctx.pressure < 0.9 and to_process.len > 0 and state.voxel_tasks <= 10 and
|
||||
get_mono_time() < timeout:
|
||||
|
||||
let units = to_process
|
||||
|
@ -356,7 +356,7 @@ proc worker_thread(params: (ZenContext, GameState)) {.gcsafe.} =
|
|||
except Exception:
|
||||
discard
|
||||
|
||||
proc launch_worker*(ctx: ZenContext, state: GameState): Thread[tuple[
|
||||
proc launch_worker*(ctx: ZenContext, state: GameState): system.Thread[tuple[
|
||||
ctx: ZenContext, state: GameState]] =
|
||||
worker_lock.acquire
|
||||
result.create_thread(worker_thread, (ctx, state))
|
||||
|
|
|
@ -4,7 +4,8 @@ from dotenv import nil
|
|||
import godotapi / [input, input_event, gd_os, node, scene_tree, packed_scene,
|
||||
sprite, control, viewport, viewport_texture, performance, label, theme,
|
||||
dynamic_font, resource_loader, main_loop, project_settings, input_map,
|
||||
input_event_action, input_event_key, global_constants, scroll_container]
|
||||
input_event_action, input_event_key, global_constants, scroll_container,
|
||||
voxel_server]
|
||||
|
||||
import core, types, globals, controllers, models / [serializers, units, colors]
|
||||
|
||||
|
@ -64,8 +65,10 @@ vram: {vram}
|
|||
units: {unit_count}
|
||||
zen objects: {Zen.thread_ctx.len}
|
||||
level: {state.level_name}
|
||||
{get_stats()}
|
||||
|
||||
"""
|
||||
state.voxel_tasks = parse_int($get_stats()["tasks"].as_dictionary["main_thread"])
|
||||
|
||||
if time > self.rescale_at:
|
||||
self.rescale_at = MonoTime.high
|
||||
|
|
|
@ -135,6 +135,7 @@ proc init*(_: type GameState): GameState =
|
|||
level_name_value: ~("", id = "level_name"),
|
||||
queued_action_value: ~("", flags),
|
||||
status_message_value: ~("", flags),
|
||||
voxel_tasks_value: ~(0, flags)
|
||||
)
|
||||
result = self
|
||||
self.open_unit_value.changes:
|
||||
|
|
|
@ -67,6 +67,7 @@ type
|
|||
worker_ctx_name*: string
|
||||
level_name_value*: ZenValue[string]
|
||||
status_message_value*: ZenValue[string]
|
||||
voxel_tasks_value*: ZenValue[int]
|
||||
|
||||
Model* = ref object of RootObj
|
||||
id*: string
|
||||
|
|
Loading…
Reference in New Issue