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
size_x = output["OTRS:IN20:571:Image:ArraySize0_RBV"]
size_y = output["OTRS:IN20:571:Image:ArraySize1_RBV"]
image = np.array(image).reshape((size_y, size_x))
image = np.array(image).reshape((size_x, size_y))
Copy link
Collaborator

@roussel-ryan roussel-ryan Dec 18, 2025

Choose a reason for hiding this comment

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

Please compare this to the calculations done in lcls-tools screen.image to make sure it is consistent. I believe it is reversed

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