Repository navigation
Conversation
# Conflicts: # rust/README.md # rust/crates/psychoscript/src/runtime.rs # rust/crates/psychoscript/tests/value_depth.rs
…say native compute holds the polling thread
# Conflicts: # rust/crates/psychoscript/src/runtime.rs
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.
What
Runtimecheap toCloneandSend + Sync + 'static. Clones share anArc<Setup>, and the builder methods useArc::make_mut.Programowns aRuntimeclone instead of borrowing&'a Runtime, soProgramand its futures are'static.Program<'a>becomesProgram: code that names the lifetime drops it.Runtime::offload(bool),trueby default. Withoffload(false), a run driven as a future (execute_async,run_async,run_resumable_async) never spawns or moves to a worker thread: every compute stretch runs on the polling thread.rust/README.mdunder "Only Rust has" and "Design -> Threading".Why
A single-threaded UI embedder such as the OpenCode Rust client keeps each plugin's running future in a struct. A borrowed
Program<'a>makes that struct self-referential. The client also needs plugin compute to stay on the UI thread, so that its thread-CPU monitoring counts the plugin's time there, with no hop to a worker and no scheduler of its own.Upstream
Rebased onto
origin/dev(dec90d1; tipe24937e). Resolved a 1-line adjacency conflict inrust/README.mdwith #153'slocalebullet; nothing was superseded by merged upstream work.Compared with open PRs #157 (
880f23f) and #139 (74c0392), which add a persistentSession(Runtime::session/session_with) and zero-copyHostCtx/HostFunction::direct:Sessionis a synchronous, thread-affine (!Send + !Syncin feat(rust): persistent Session and zero-copy HostCtx API #157) persistent VM driven by discretecall_fninvocations, withoutProgramfutures, async host calls across suspension points, or snapshot suspend/resume.Send + 'staticProgrammodel (used by embedders that drive a long-lived program via async host calls and futures) and adds cloneableRuntime, owned'staticProgram, andRuntime::offload(false). Neither feat(rust): persistent Session and zero-copy HostCtx API #157 nor perf(rust): persistent Session, zero-copy direct host API, VM hot paths, and optional ICU locale #139 touchesprogram.rs, makesRuntimecloneable, removes the lifetime onProgram<'a>, or addsoffload(false).rust/crates/psychoscript/src/runtime.rsis touched by both (clean 3-way merge against feat(rust): persistent Session and zero-copy HostCtx API #157; feat(rust): persistent Session and zero-copy HostCtx API #157/perf(rust): persistent Session, zero-copy direct host API, VM hot paths, and optional ICU locale #139 addsession/session_withbesideprogram, andSession::startreads setup throughrt.setup(), so there is no semantic conflict).Tests
rust/crates/psychoscript/tests/offload.rs:runtime_clones_and_program_is_staticoffload_false_keeps_compute_on_the_calling_thread: a fixed compute loop finishes in one poll and advances the calling thread'sThreadClock.cargo fmt --all --check,cargo clippy --locked -p psychoscript -p psychoscript-bench --all-targets -- -D warnings,cargo clippy --locked -p psychoscript-mobile --no-default-features --features locale --all-targets -- -D warnings, andcargo test --locked -p psychoscript --lib --test offload --test snapshot --test streaming --test value_depth --test hostile --test host --test host_recording --test globals --test boundary --test program_lines --test gc --test map_compaction --test number_locale(146 passed, 0 failed) pass.