[codex] Optimize dynamic organ lifecycle refresh - #212
Conversation
|
Current status: the first runtime-performance tranche is complete. Profiling confirmed that XPalm follows the short, single-cadence path: the model application plan stays fixed, and only organs and their runtime state are added. The largest avoidable cost was therefore not model scheduling, but repeated lifecycle refresh work. In particular, the runtime eagerly materialized complete nested This branch now constructs On warm, like-for-like runs, the exact The focused validation is green, including the 747-test unified API suite, the 644-test API stabilization suite, lifecycle, hard-call, previous-timestep, bound- My proposed next step is to compile an internal, canonical object/status construction recipe from the fixed application plan. A newly emitted organ could then build its |
Dynamic-organ performance updateI completed another optimization pass and created local checkpoint Results
What changed
Correctness and validation
The next experiment is intentionally more invasive: construct a newborn organ's complete canonical status in one materialization through an internal pending-status overlay, instead of applying separate output and input phases. I will keep the public API unchanged and benchmark it independently before deciding whether to retain it. |
Performance update since the previous commentSix additional commits have been pushed since checkpoint
The overall design remains the same: the application plan is fixed, while only object-dependent targets and status are extended at lifecycle barriers. There is still no public API change. Current performance and correctness
Validation and merge statusThe local test-environment limitation mentioned in the previous comment has been resolved. The complete
The PR is mergeable and targets If the remaining CI jobs complete successfully, I consider this performance tranche ready to merge into |
Summary
This PR reduces the lifecycle-refresh overhead introduced by dynamic organ creation on the
multi-plantsruntime path. It keeps the compiled model plan and public API unchanged while updating only the object-dependent runtime structures that actually change.Problem
The 4,160-day XPalm reference simulation currently takes about 14.5 seconds on the exact
multi-plantsbase, even though all models use the same cadence and the model application plan is fixed. Profiling showed that a large share of the runtime was spent refreshing runtime structures after organs were added.The main avoidable cost was eager construction of complete nested
Manyhard-call execution targets at every lifecycle barrier. XPalm only executes the call for the newly created object in this path, but the runtime still materialized 61,592 nested targets that were never used. Other object-dependent carriers, previous-timestep views, distributed-output destinations, and call-owner batches were also being rebuilt more broadly than needed.Changes
Manyhard-call targets while keepingOneandOptionalOnetargets eager and concretely typed.Manyinput carriers, previous-timestep views, distributed-output destinations and streams, and hard-call owner/batch structures when objects are only added.Statusvalues that are immediately replaced. This avoids 686 redundant rewrites in the XPalm reference while preserving reference identity, conversions, callbacks, diagnostics, and error behavior.There is no public API change.
User impact and benchmarks
Warm, like-for-like runs on the same machine:
multi-plantsbase: about 14.50 s wall time / 18.94 s process CPU.The optimized XPalm run remains bit-for-bit identical to the exact base for the retained benchmark outputs:
1e47d0a88fc5742ad24b6a4fbbaa6006b047fcc56eaa4f54f468bb8b60c66b6cThe older PlantSimEngine v0.14.1 / XPalm v0.6.1 reference was around 4.41 s, but its scientific outputs differ, so that number is included only as historical context rather than a direct performance comparison.
PlantBiophysics was also checked over 8,760 steps and 113,880 output rows. The base and this branch produce the same digest (
a8aad9a50aab94588d68d4e2b9b919821af7b239ed2d94c78c069c5b04c0a377), with no material timing or allocation regression.Validation
Manybehavior: 68 / 68git diff --checkpasses.The complete
test/runtests.jlsuite was not run: the Kaimon test project currently cannot start becauseMonteCarloMeasurementsis declared as a direct test dependency but is absent from the test manifest, while the root-project runner does not provideAqua. The focused suites above were run with their required imports in fresh Julia sessions.