Repository navigation
Conversation
Each session builds, validates, serialises and sends its Bokeh document on the loop that serves every other session and /liveness. - Draw shank outlines, bank lines and labels with one renderer per style. A 4-shank document drops from 33 renderers and 485 models to 9 and 269. - Limit tap and box-select tools to the electrode and survey-bar renderers, so a tap on a shared outline renderer can't dim the other outlines. - Send numeric electrode columns as arrays, compute their geometry with NumPy, and skip Bokeh's per-cell check of that fixed-shape source. - Reuse the cached data URI for tool icons instead of re-encoding six PNGs. Assisted-by: ClaudeCode:claude-opus-5-5
`panel serve` runs the app per session on the loop that serves every session and /liveness. Serve a placeholder at once, build the GUI on one worker thread once the page connects, and swap it in on the loop under the document lock. Nothing on the worker touches a document: ?cfg= is read in create_app, and destroy hooks are registered on the loop, so ChannelmapGUI.__init__ no longer registers its own. A tab closed while queued skips the build, and one closed mid-build has its GUI cleaned up. Any build or swap failure shows the existing alert and is reported. Drop validate(False) from create_electrode_data: it toggles a process-global flag, and on_probe_type_change on the loop can overlap the worker's build, which could leave property validation off for the whole server. This costs about 41 ms per electrode source. Assisted-by: ClaudeCode:claude-opus-5-5
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #95 +/- ##
======================================
Coverage ? 86.86%
======================================
Files ? 21
Lines ? 3463
Branches ? 0
======================================
Hits ? 3008
Misses ? 455
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
🤖 AI text below 🤖
Stacks on #93, which has not merged. Until it does, this diff includes #93. Review only the top commit,
eb8d7e4. It has no textual conflict with #92 (checked withgit merge-tree), and #92's tests pass on the merged tree.Summary
panel serveruns the app per session on the loop that serves every session and/liveness. This moves GUI construction to a worker. The attach and serialisation stay on the loop, so the stall is smaller, not gone.With no session (scripts, tests),
create_appstill builds inline.What the design had to fix:
validate(False)is removed. It saves and restores a process-global flag: enter A, enter B, exit A, exit B leaves validation off for the whole server (reproduced against Bokeh 3.7.3). One worker doesn't prevent this, becauseon_probe_type_changebuilds the same source on the loop. The cost is about 41 ms per electrode source (7 -> 48 ms). That runs on the worker for session builds and on the loop only for a probe switch.pn.state.curdocin a worker is whichever session the loop is serving. A profile of a real build shows the worker only reads its own session's request (Panel's?theme=lookup) and createsColumnDataChangedEventhints withdocument=None.ChannelmapGUI.__init__no longer registers its cleanup, and?cfg=is read on the loop.state._onloadwould leak sessions that never load. It is aWeakKeyDictionarywhose value reaches its own key, so_release_dead_session_viewsnow pops the entry.report_error(context="session startup", notify_user=False).Evidence
Local
panel serve, 2 fresh servers per variant, 8 sessions each, range across the two runs,PIXELMAP_STALL_WARN_S=5. Contended means the server and 7 busy loops are pinned to CPU 0./livenessper session, median/liveness/livenessDocker,
-m 4500m --memory-swap 4500m, median of 5 rounds. Each cell is 2b6ce90 -> this PR. Rounds 3–5 alternated which image ran first.--cpus=8--cpus=0.25/livenessper session, medianResults that don't favour this PR:
rsync, a Python process at 100%) ran during the Docker rounds, so the max rows and watchdog counts are noisy. In the noisiest round, 2, this PR was worse than base at both CPU limits, with a median of 1.79 s against 0.62 s at 8 CPUs.Memory doesn't return to its starting level after close on either image. In rounds 3–5, every session in the logs was cleaned up on both.
Browser (Chromium, real server). The plot canvas matches 2b6ce90 pixel for pixel after page load, tap, box select, QuadBase switch and
?cfg=, both locally and in the Docker image.?cfg=link restored 20/384 electrodes.local=Truepage also loaded.Tests. 1040 passed, 1 xfailed;
ruffis clean. New coverage is intests/test_session_off_loop.pyandtests/test_session_leak.py. It covers overlapping builds, no document access from the worker, closing while queued or mid-build, sessions that never load, failed builds and swaps, bad or empty?cfg=, and building without a session.Merge Danger
Door: two-way. It is one commit to revert, with no data or format changes.
Blast Radius: sessions
Every visitor's page load goes through this path.
curl /app) now costs a placeholder and builds no GUI.ChannelmapGUI()constructed directly in someone's own served app no longer registers_cleanup_session;create_appdoes that now._release_dead_session_viewsnow also touches the privatestate._onload, so a Panel upgrade could break it.Not verified:
NUM_PROCSabove 1Assisted-by: ClaudeCode:claude-opus-5-5