[k2] introduce component structure and confdata multishot component skeleton - #1671
Open
apolyakov wants to merge 11 commits into
Open
[k2] introduce component structure and confdata multishot component skeleton#1671apolyakov wants to merge 11 commits into
apolyakov wants to merge 11 commits into
Conversation
Prepare runtime-light for multiple component entry points: the kphp component's sources (runtime-light.cpp and state/) move to components/kphp/, making room for sibling components (e.g. confdata). Includes are updated accordingly; .gitignore's bare "kphp" pattern is anchored to the repo root so it no longer hides the new directory.
Common runtime code no longer depends on the concrete kphp InstanceState: state accessors (kphp::coro::instance_state::get, io_scheduler::get, AllocatorState::get, ErrorHandlingState, RuntimeContext::get, contextual_tags::try_get) are resolved via link-time bindings implemented in components/kphp/bindings/bindings.cpp. CoroutineInstanceState is moved into kphp::coro as instance_state, io_scheduler receives it via its constructor, and async_backtrace reaches the stack root through the binding instead of the concrete state layout.
Introduce components/confdata/: a standalone C++ component image that mirrors the kphp component structure (state/, bindings/, entry points) and links the common runtime-light machinery (coroutine scheduler, script allocator, streams, logging) via the per-component bindings introduced earlier. The dummy instance accepts a stream, drains the request and closes it; k2_describe() is hand-written with the "confdata" image name. The k2-confdata.so image is produced by cmake with the same link recipe the compiler uses for k2 images, and confdata headers are excluded from the merged runtime headers.
Every *::get / *::try_get / *::get_mutable definition (and PhpScriptMutableGlobals::current) now lives in components/kphp/bindings/bindings.cpp, so common runtime-light code no longer includes components/kphp/state headers from its .cpp files and stays fully agnostic of where the state actually lives. The 22 state .cpp files that contained nothing but accessors are removed; file-system-state.cpp keeps its constructor and php-script-globals.cpp keeps its logic. Direct InstanceState accesses in http and job-worker init code now go through PhpScriptMutableGlobals::current(). Another component can adopt a runtime-light .cpp incrementally by adding the corresponding binding to its own bindings.cpp.
This reverts commit ee03e3f.
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.
Restructure the K2 runtime to support multiple component images:
runtime-light/components/kphp/*::get/*::try_get/*::get_mutable) are resolved via link-time bindings in each component'sbindings/bindings.cpp, keeping common code agnostic of where the state actually livescomponents/confdata/: a standalone C++ component image (k2-confdata.so) mirroring the kphp component structure — own state, bindings, entry points, hand-writtenk2_describe(). The dummy instance accepts a stream, drains the request and closes it; a trivial warmup entry point is in place