[WIP] Enhance MTLN performance by optimizing bundle processing and reducing…#401
Draft
lmdiazangulo wants to merge 11 commits intodevfrom
Draft
[WIP] Enhance MTLN performance by optimizing bundle processing and reducing…#401lmdiazangulo wants to merge 11 commits intodevfrom
lmdiazangulo wants to merge 11 commits intodevfrom
Conversation
… unnecessary computations Co-authored-by: Copilot <copilot@github.com>
Use ngspice's built-in 'save none' mode to prevent unbounded accumulation of plot vector history during time-stepping. In shared-library mode, ngspice's plotAddRealValue() checks a 'savenone' flag (set when 'save none' is in the saves list). When true it resets v_length=0 before each write, keeping only the latest data point instead of appending. vlength2delta() also returns 1, so the underlying allocation never grows beyond a single slot. Call 'save none' after circ() loads the circuit description so that ft_curckt is non-NULL. The savenone flag then persists for the entire simulation (it is never reset to FALSE), fixing the linear memory growth that occurred on every resume() call. updateNodes() reads values(ubound(values,1)) which still returns the correct latest value with a length-1 vector. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Three changes to eliminate step-count-proportional RSS growth: 1. ngspice control.c (submodule): Free the struct control chain after each top-level command execution in cp_evloop(). Every call to ngSpice_Command() previously accumulated a new struct control node with a wl_copy() of the parsed command that was never freed. With N alter calls per step this produced ~4 KB/step growth. 2. circuit.F90: Add 'set history = 1' after 'save none' to limit ngspice command history to 1 entry. Without this, the first 10000 commands (cp_maxhistlength default) accumulate before freeing. 3. probes.F90 / mtln_solver.F90 / observation.F90: Pre-allocate only a single frame buffer for MTLN observation probes instead of N frames (one per timestep). The single slot is overwritten each step; results are written to output at observation time. Result: RSS is now constant across step counts (50, 500, 5000 steps all show ~145 MB with the debug binary, vs. +22 MB growth before). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… unnecessary computations