Repository navigation
A per-context fill-reuse switch (ctx->fill_reuse) - #44
Merged
maurymarkowitz merged 1 commit intoNov 21, 2026
Merged
Conversation
OPENNEC_FILL_REUSE is read at every fill and the environment is process-wide, so an embedding that runs several solves at once (a server, a binding with the GIL released) cannot let one solve choose differently from another. ctx->fill_reuse is that choice: 0 (calloc's default) leaves it to OPENNEC_FILL_REUSE and then the build default exactly as before, 1 turns reuse on and -1 off for this context alone. Builds without OpenMP have no reuse path, so 1 is ignored there. onec never sets it, so its behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SKce1zVChRtJMQadEiWtJY
stevenmburns
added a commit
to stevenmburns/pyopennec
that referenced
this pull request
Nov 20, 2026
OpenNEC reads OPENNEC_FILL_REUSE at every fill, and the environment is process-wide, so a server with several solves in flight cannot let one request say no. The submodule moves to pyopennec-base-2.4.2 at c9cbff8, which adds OpenNEC's ctx->fill_reuse (sent upstream as maurymarkowitz/OpenNEC#44), and Structure takes fill_reuse=None|True|False into it: None leaves the environment and the build to decide as before. tests/test_fill_reuse.py proves it bitwise: with the environment pointing the other way, fill_reuse=False equals OPENNEC_FILL_REUSE=0's answer and True equals =1's, and on/off differ (reuse engaged), so the comparison can fail. 114 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SKce1zVChRtJMQadEiWtJY
stevenmburns
added a commit
to stevenmburns/pyopennec
that referenced
this pull request
Nov 21, 2026
OpenNEC reads OPENNEC_FILL_REUSE at every fill, and the environment is process-wide, so a server with several solves in flight cannot let one request say no. The submodule moves to pyopennec-base-2.4.2 at c9cbff8, which adds OpenNEC's ctx->fill_reuse (sent upstream as maurymarkowitz/OpenNEC#44), and Structure takes fill_reuse=None|True|False into it: None leaves the environment and the build to decide as before. tests/test_fill_reuse.py proves it bitwise: with the environment pointing the other way, fill_reuse=False equals OPENNEC_FILL_REUSE=0's answer and True equals =1's, and on/off differ (reuse engaged), so the comparison can fail. 114 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SKce1zVChRtJMQadEiWtJY
Owner
|
Excellent idea! Merging... |
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.
OPENNEC_FILL_REUSEis read at every fill, and the environment is process-wide. So a program that embeds OpenNEC and runs several solves at once, such as a server or a Python binding solving with the GIL released, can't let one solve turn reuse off while another keeps it on.This adds the choice to the context:
ctx->fill_reuse.0is calloc's default, so nothing changes unless a caller sets it: the environment variable decides, then the build default, exactly as now.1turns reuse on, and-1turns it off, for that context alone, whatever the environment says.1is ignored there.The change is three lines in
fill_wire_observersplus the field ininternals.h.Test.
fill_reuse_state.cgains two modes,ctx-onandctx-off.check_fill_reuse_sampling.pyruns each on thesmall_repeatedcase with the environment set the opposite way:ctx-offunderOPENNEC_FILL_REUSE=1must leave no reuse cache;ctx-onunderOPENNEC_FILL_REUSE=0must build one.On Linux, with OpenMP and OpenBLAS, all 9 sampling cases pass. With the
matrix.cchange backed out, both new modes fail, so the check can tell.Our use: pyopennec (Python bindings for OpenNEC) exposes it as
Structure(..., fill_reuse=None | True | False), so the antennaknobs server can give each request its own choice.Thanks for 2.4.2. Fill reuse is a big step.
🤖 Generated with Claude Code