mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 00:09:18 +02:00
Add headless parallel eu7v2 scenario bake with streaming and PLCE placements
Enable --eu7v2-bake from the main binary: parallel module pool, bounded-RAM spool flush, streaming terrain triangles, flat include/model parsing, and eu7v2 emit/load with optional verify. Large placement .scm files emit lean PLCE records and bake referenced .inc modules separately for reuse. - CLI: --eu7v2-bake, --eu7v2-verify, --eu7v2-mem-limit-gb, --eu7v2-threads, --eu7v2-max-parse; wire max_threads through to the bake parser - eu7v2 v2 records: PLCE placements, runtime emitter/loader, batch verify - Parallel bake pool with session cache; drop heavy-serial parse gate in spool mode; parse concurrency matches thread count - Streaming terrain: batched parallel parse+bake, scan/bake pipeline, shape spool with persistent buffered I/O and flush-before-read - Parallel flat-file streaming for models/includes; pack/model spool for low-memory incremental flush - Optional 50 GB private-bytes guard during headless bake Braniewo_szeroki: 160 modules, verify PASS, ~34s bake (nmt100 ~17s vs ~190s serial baseline). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -32,6 +32,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <thread>
|
||||
|
||||
|
||||
@@ -62,7 +64,31 @@ bake_thread_count() {
|
||||
|
||||
auto const hardware { std::thread::hardware_concurrency() };
|
||||
|
||||
return hardware > 0 ? hardware : 1u;
|
||||
if( hardware == 0 ) {
|
||||
|
||||
return 1u;
|
||||
|
||||
}
|
||||
|
||||
int percent { Global.eu7_bake_cpu_percent };
|
||||
|
||||
if( percent < 1 ) { percent = 1; }
|
||||
|
||||
if( percent > 100 ) { percent = 100; }
|
||||
|
||||
unsigned const threads {
|
||||
|
||||
std::max( 1u,
|
||||
|
||||
static_cast<unsigned>( ( static_cast<unsigned long long>( hardware ) * percent + 50 ) / 100 ) ) };
|
||||
|
||||
WriteLog(
|
||||
|
||||
"EU7 bake: auto watki=" + std::to_string( threads ) +
|
||||
|
||||
" (" + std::to_string( percent ) + "% z " + std::to_string( hardware ) + " rdzeni logicznych)" );
|
||||
|
||||
return threads;
|
||||
|
||||
}
|
||||
|
||||
@@ -90,7 +116,27 @@ run_scenario_tree_bake(
|
||||
|
||||
std::string error;
|
||||
|
||||
if( false == bake_parser::bake_scenario_tree( text_root, bake_thread_count(), error ) ) {
|
||||
bool bake_ok { false };
|
||||
|
||||
if( Global.eu7v2_runtime ) {
|
||||
|
||||
auto const report {
|
||||
|
||||
bake_parser::bake_scenario_tree_eu7v2( text_root, bake_thread_count(), false ) };
|
||||
|
||||
bake_ok = report.baked;
|
||||
|
||||
error = report.error;
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
bake_ok = bake_parser::bake_scenario_tree( text_root, bake_thread_count(), error );
|
||||
|
||||
}
|
||||
|
||||
if( false == bake_ok ) {
|
||||
|
||||
if( probe_file( eu7_path ) ) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user