M12.3: publish and recover durable exact populations
Foundation / checks (ecs) (push) Successful in 2m41s
Foundation / checks (tsan) (push) Failing after 18m12s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 20m41s
Foundation / checks (postgres) (push) Canceled after 20m43s
Foundation / checks (checks) (push) Canceled after 20m49s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (client) (push) Failing after 17m4s
Foundation / postgres-tools (push) Canceled after 0s

This commit is contained in:
dingo
2026-10-17 17:10:17 -04:00
parent d5d10a0cc7
commit 627411983f
35 changed files with 2637 additions and 102 deletions
+44 -4
View File
@@ -113,6 +113,7 @@ struct Options {
std::uint64_t objects_reserve_mib{1024};
server_app::SessionOptions session;
server_app::M10Options m10;
bool cellular_populations{};
struct PrimitiveSessionOptions {
std::string listen, certificate, key, issuer, environment;
[[nodiscard]] bool any() const noexcept {
@@ -273,6 +274,8 @@ std::optional<Options> parse(int argc, char** argv) {
o.m10.life_routes.emplace_back(value);
else if (flag == "--m10-load-governor" && (value == "on" || value == "off"))
o.m10.load_governor = value == "on";
else if (flag == "--cellular-populations" && (value == "on" || value == "off"))
o.cellular_populations = value == "on";
else if (flag == "--primitive-listen")
o.primitive_session.listen = value;
else if (flag == "--primitive-cert")
@@ -304,6 +307,8 @@ std::optional<Options> parse(int argc, char** argv) {
o.pg.port.empty() || o.pg.database.empty() || o.pg.user.empty() || o.objects.empty() ||
o.host.build == persistence::Sha256Digest{})
return std::nullopt;
if (o.cellular_populations && o.profile != "cellular")
return std::nullopt;
// Rehearsal controls exist only for the synthetic driver (clones, drills).
if ((o.synthetic_until != 0 || o.accelerate != 1) && !o.synthetic)
return std::nullopt;
@@ -898,7 +903,7 @@ int serve_primitive(Options& o) {
#ifdef EVO_SERVER_M10
int serve_cellular(Options& o) {
auto objects = persistence::FilesystemObjectStore::open(
o.objects, o.host.key, server::max_cellular_lives_bytes, nullptr,
o.objects, o.host.key, server::max_cellular_population_bytes, nullptr,
o.objects_reserve_mib * 1024 * 1024);
if (!objects) {
std::puts("error objects");
@@ -906,7 +911,9 @@ int serve_cellular(Options& o) {
}
const auto pg = o.pg;
auto made = server::CellularRegionHost::create(
{o.host.key, o.host.frame, o.host.lease, o.host.build, o.host.retained_builds},
{o.host.key, o.host.frame, o.host.lease, o.host.build, o.host.retained_builds,
o.cellular_populations ? std::optional{server::CellularTierPolicy{true, 1200, 1800}}
: std::nullopt},
[pg] { return persistence::Postgres::connect(pg, 2s); }, std::move(*objects));
if (!made) {
std::puts("error config");
@@ -1060,6 +1067,17 @@ int serve_cellular(Options& o) {
held_births.push_back(birth);
}
const bool birth_waiting = !held_births.empty();
const bool want_population =
o.cellular_populations && state &&
state->rules_version() == server::cellular_lives_foraging_rules && !player_present &&
!birth_waiting && host.queued_mutations().empty() &&
std::ranges::any_of(state->lives(), [](const auto& life) {
return life.account == server::LifeAccount{};
});
if (status.ready && state && want_population != host.population_mode()) {
[[maybe_unused]] const auto changed = host.set_population_mode(want_population);
state = host.state();
}
const bool needed = state && (player_present || birth_waiting ||
server::cellular_unattended_tick_needed(*state));
const auto monotonic_us = [] {
@@ -1076,7 +1094,29 @@ int serve_cellular(Options& o) {
return finish(4);
}
if (status.ready && state && needed) {
if (paced->due && state->tick() != UINT64_MAX) {
if (host.population_mode()) {
// Collect one second of due time before an unattended publication.
// Overload services at most 64 fixed steps per bounded batch. Debt
// remains visible and is consumed only by a confirmed head.
if (paced->due && paced->debt >= 20) {
const auto& head = host.committed()->head;
const server::CellularBatchHeader header{
o.host.key.world,
o.host.key.region,
o.host.frame,
head.commit,
head.digest,
head.end_tick,
head.end_tick + std::min<std::uint64_t>(paced->debt, 64)};
const auto inputs = server::unattended_population_inputs(*state, header);
const auto end = header.end_tick;
if (inputs) {
[[maybe_unused]] const auto published = host.publish(*inputs);
}
if (!host.state() || host.state()->tick() < end)
schedule.defer(monotonic_us());
}
} else if (paced->due && state->tick() != UINT64_MAX) {
const auto tick = state->tick() + 1;
std::vector<server::CellularLifeIntent> baseline;
baseline.reserve(state->lives().size());
@@ -1201,7 +1241,7 @@ int main(int argc, char** argv) {
"[--m10-handoff-key F [--m10-neighbour "
"REGION=X0,Y0,X1,Y1=HOST:PORT=NAME=PUBFILE]...] "
"[--life-route REGION=HOST:PORT=TLS_NAME ...] "
"[--m10-load-governor on|off]]\\n",
"[--m10-load-governor on|off]] [--cellular-populations on|off]\\n",
stderr);
return 2;
}