Skip to content

Conversation

@JJL772
Copy link
Member

@JJL772 JJL772 commented Nov 8, 2025

This is supposed to work around timeout issues seen when running Badger against Linac-Simulation-Server.

My understanding of the issue is:

  • Writes to any PV trigger a full re-evaluation of the model (on my system nc injector takes, ~6s)
  • While the model is being re-evaluated, the server becomes unresponsive
    • This leads to caput reporting a timeout when it tries to provide a readback of the new value
    • The epics interface in Badger may timeout because it only waits ~2 seconds while attempting to get a readback value
      • Additionally, the constant re-evaluating of the model on every single write will slow the optimization to a crawl

There are two ways to fix this:

  1. Go back to the previous implementation that would evaluate only on read (this would break PVA support and CA monitors)
  2. Implement some type of threading to prevent the server from becoming unresponsive.

I opted for option 2 just to avoid breaking PVA.

VIRT:BEAM:SIMULATE_TIMEOUT defines the window in which PVs can be batched before the simulation is re-run

VIRT:BEAM:SIMULATE will force the simulation to occur regardless of VIRT:BEAM:SIMULATE_TIMEOUT setting. This is mostly handy for working with the server from the command line.

With the timeout method, no changes are required to Badger-Resources

@JJL772 JJL772 force-pushed the pr-simulation-threading branch from 33e6cde to be3827c Compare November 18, 2025 21:44
@JJL772 JJL772 changed the title WIP: Simulation Threading Simulation Threading Nov 18, 2025
@JJL772 JJL772 force-pushed the pr-simulation-threading branch from d249782 to cab3d0a Compare November 20, 2025 00:03
@JJL772 JJL772 mentioned this pull request Dec 5, 2025
@roussel-ryan
Copy link
Collaborator

Looks fine to me, @nstelter-slac this is addressing your testing issues? @JJL772 what do you think RE ready to merge

Copy link
Collaborator

@phys-cgarnier phys-cgarnier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good to me. We should merge with @roussel-ryan 's approval

@roussel-ryan roussel-ryan merged commit cac5969 into main Jan 5, 2026
@JJL772 JJL772 deleted the pr-simulation-threading branch January 5, 2026 23:16
@JJL772
Copy link
Member Author

JJL772 commented Jan 5, 2026

Yup good to merge. Thanks guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants