Repository navigation
Conversation
Signed-off-by: Andrea Luzzardi <[email protected]>
Closed
This was referenced Apr 20, 2022
Closed
gerhard
pushed a commit
that referenced
this pull request
Sep 18, 2023
Initial version of the SDK --------- Signed-off-by: Jean-Christophe Sirot <[email protected]>
gerhard
added a commit
that referenced
this pull request
Sep 18, 2023
* Initial commit Signed-off-by: Jean-Christophe Sirot <[email protected]> * Initial version (#1) Initial version of the SDK --------- Signed-off-by: Jean-Christophe Sirot <[email protected]> * Clean up build process & better samples (#2) * build: clean up build update pom.xml dependency management remove unused dependencies remove unused import * build: Add maven exec plugin to run the code samples from the CLI * build: support dependency caching in github action (#3) * fix: add missing sample in the sample code demo app (#4) * feat(log): add debug log when response is contains errors. (#5) Set the log level to debug in integration tests * fix: support macos arm64 architure by cli downloader (#7) * fix: client hangs on close (#8) fix(connection): refactoring of the engine connection package Move CLIRunner and ConnectParams to a dedicated class file Replace JSON-B by JSON-P to deserialize the connection parameters Move the Dagger CLI process execution to the CLI runner (Single-responsibility principle) Fix process hanging when connection to the engine failed Improve code style Add some tests for Connection class --------- Signed-off-by: Jean-Christophe Sirot <[email protected]> * build(workflow): enable build on linux and macos (#9) macos is limited to PR builds So far windows VM does not support Linux containers Signed-off-by: Jean-Christophe Sirot <[email protected]> * build: package jar with dependencies and upload artifacts in github (#11) package jar with dependencies and upload artifact in github upload artifact only on push to main update README.md --------- Signed-off-by: Jean-Christophe Sirot <[email protected]> * Move all files into sdk/java subdir So that this can be imported into dagger/dagger repository Signed-off-by: Gerhard Lazu <[email protected]> * sdk(java): Add experimental warning to README Signed-off-by: Gerhard Lazu <[email protected]> * sdk(java): Rename LICENSE But keep as is, same as we did for other experimental SDKs. Signed-off-by: Gerhard Lazu <[email protected]> * chore: Add /sdk/java to CODEOWNERS Signed-off-by: Gerhard Lazu <[email protected]> * build: rename package name from 'org.chelonix.dagger.*' to 'io.dagger.*' Signed-off-by: Jean-Christophe Sirot <[email protected]> * build(codegen): add introspection query in the codegen plugin resources and use it when schema is not available. Inject the CLI version in the code at build time Signed-off-by: Jean-Christophe Sirot <[email protected]> * build: add linter plugin and lint current code Signed-off-by: Jean-Christophe Sirot <[email protected]> * build: set development version to 1.0.0-SNAPSHOT. Add "release" profile dedicated to deployment Signed-off-by: Jean-Christophe Sirot <[email protected]> * fix: correctly return the dagger CLI path in codegen plugin and fix some log messages Signed-off-by: Jean-Christophe Sirot <[email protected]> * build: Add schema for 0.6.4 Signed-off-by: Jean-Christophe Sirot <[email protected]> * fix: fix coding style for linter Signed-off-by: Jean-Christophe Sirot <[email protected]> * build: fix maven versions plugin groupId Signed-off-by: Jean-Christophe Sirot <[email protected]> * ci: add java sdk CI - add initial build worflow in internal/mage/sdk/java.go - add test & lint actions in github action worflow Signed-off-by: Jean-Christophe Sirot <[email protected]> * fix: replace deprecated API calls in tests - Container.fs -> Container.rootfs - Container.exec -> Container.withExec Signed-off-by: Jean-Christophe Sirot <[email protected]> * fix: Add a static 'from' method to instanciate a Scalar from a String literal Signed-off-by: Jean-Christophe Sirot <[email protected]> * fix(doc): fix javadoc for field parameters in generated code Signed-off-by: Jean-Christophe Sirot <[email protected]> * fix: Fix NPE when CLI download fails and log error Signed-off-by: Jean-Christophe Sirot <[email protected]> * fix(codegen): clarify codegen plugin parameters and Dagger version in generated code Separate CLI and SDK version Use either a previously generated schema or a query a locally installed dagger CLI update the CI to generate the schema matching the used dagger CLI Signed-off-by: Jean-Christophe Sirot <[email protected]> * fix(codegen): fix sdk:java:generate goal Now the generate goal will query the dagger CLI to generate the API JSON schema and write a file A new dagger-codegen:generateSchema plugin goal has been added to the dagger-codegen maven plugin (with some code refactoring between both goals) to generate the schema. The generate schema is copied to plugin resources dir /schemas according to the engine version declared in the pom.xml file afterwards. The schema file naming has been simplifying (removing the 'v' prefix) and the existing files have been renamed accordingly Signed-off-by: Jean-Christophe Sirot <[email protected]> * feat(codegen): add schema for dagger engine 0.8.3 and 0.8.4 Signed-off-by: Jean-Christophe Sirot <[email protected]> * doc(codegen): document how to bump engine dependency Signed-off-by: Jean-Christophe Sirot <[email protected]> * Remove redundant return & go fmt Signed-off-by: Gerhard Lazu <[email protected]> * Make Java SDK workflow standalone, same as the Elixir one Leverage the re-usable _hack_make workflow. Signed-off-by: Gerhard Lazu <[email protected]> * Use same Apache 2.0 license as all other SDKs Engine & CLI use the same Apache 2.0 license. Signed-off-by: Jean-Christophe Sirot <[email protected]> --------- Signed-off-by: Jean-Christophe Sirot <[email protected]> Signed-off-by: Jean-Christophe Sirot <[email protected]> Signed-off-by: Gerhard Lazu <[email protected]> Signed-off-by: Jean-Christophe Sirot <[email protected]> Co-authored-by: Jean-Christophe Sirot <[email protected]> Co-authored-by: Jean-Christophe Sirot <[email protected]> Co-authored-by: Daniel Lavoie <[email protected]>
1 of 2 tasks
tiborvass
referenced
this pull request
in tiborvass/dagger
Mar 25, 2025
in the spirit of "be liberal in what you accept" - some models might interpret Container#1 as Container #1 Signed-off-by: Alex Suraci <[email protected]>
tiborvass
referenced
this pull request
in tiborvass/dagger
Mar 25, 2025
in the spirit of "be liberal in what you accept" - some models might interpret Container#1 as Container #1 Signed-off-by: Alex Suraci <[email protected]>
vito
added a commit
that referenced
this pull request
Mar 26, 2025
* force opt-in multi-object for testing one of my tests actually benefits from _undo, so let's just keep them all enabled, as this was more out of an abundance of caution Signed-off-by: Alex Suraci <[email protected]> * add evals module + test suite usage: dagger run go test Signed-off-by: Alex Suraci <[email protected]> * beef up default system prompt * do a bit of world-building * clarify immutability/state interaction * nudge it towards using tools to explore before giving up * suggest setting a variable at the end * make system prompt consistent across all models * always apply system prompt (previously OpenAI was excepted) * allow being overridden (previously Gemini didn't) Signed-off-by: Alex Suraci <[email protected]> * support running evals across models Signed-off-by: Alex Suraci <[email protected]> * DNM: add debugging Signed-off-by: Alex Suraci <[email protected]> * switch to _select_varname, list their tools * don't need _objects if we just add a tool for each var * listing tools ahead of time helps Gemini realize it needs to select tools Signed-off-by: Alex Suraci <[email protected]> * don't expand object prompt vars Signed-off-by: Alex Suraci <[email protected]> * add test-all script Signed-off-by: Alex Suraci <[email protected]> * strict builtins Signed-off-by: Alex Suraci <[email protected]> * experiment: strict schemas saw some guessing, don't want none of that Signed-off-by: Alex Suraci <[email protected]> * Revert "experiment: strict schemas" This reverts commit 63f4266. Signed-off-by: Alex Suraci <[email protected]> * wip: bots prompting bots Signed-off-by: Alex Suraci <[email protected]> * better LLM.history formatting Signed-off-by: Alex Suraci <[email protected]> * support setting a system prompt Signed-off-by: Alex Suraci <[email protected]> * Llm -> LLM, multiple attempts Signed-off-by: Alex Suraci <[email protected]> * simplify error responses Signed-off-by: Alex Suraci <[email protected]> * more liberal object lookup, helpful error response Signed-off-by: Alex Suraci <[email protected]> * reveal errored tool calls due to bad args Signed-off-by: Alex Suraci <[email protected]> * add Llm.attempt kind of silly implementation, but gets the job done Signed-off-by: Alex Suraci <[email protected]> * evals: run N attempts Signed-off-by: Alex Suraci <[email protected]> * evals: tweaks for direct calling Signed-off-by: Alex Suraci <[email protected]> * adopt new system prompt Signed-off-by: Alex Suraci <[email protected]> * handle $ var arg prefix Signed-off-by: Alex Suraci <[email protected]> * Llm.history: clean up format * tool calls were showing up as user prompts * indicate errored tools * tweak emoji usage ("laptop" doesn't read as "tool" to me) Signed-off-by: Alex Suraci <[email protected]> * core: add ToolFunc helper otherwise the selecting of arg values and typecasting is a little panic-prone Signed-off-by: Alex Suraci <[email protected]> * fixup _save arg Signed-off-by: Alex Suraci <[email protected]> * fix workspace construction Signed-off-by: Alex Suraci <[email protected]> * checkpoint: Gemini passing 19/20 evals * https://v3.dagger.cloud/dagger/traces/0194a2fd0e94f8226705da24bcf24ab6 * https://v3.dagger.cloud/dagger/traces/8fbf316db60f1fd6dfef1b53933b2904 Signed-off-by: Alex Suraci <[email protected]> * include token usage in history Signed-off-by: Alex Suraci <[email protected]> * refine model, new system prompt * always use structured responses * return {"using":"Foo#123","variable":"foo"} for Objects so LLM knows not to make redundant _use or _saveAs calls * replace _rewind with _use(id) now that we have LLM friendly IDs; _rewind seemed to get it stuck in loops now and then * don't expose 'id' field tool - the LLM always knows them without needing it * enforce that LLM env vars are Objects, don't overload it with String * not 100% sure about this but trying it out, it might make sense to generalize and allow an LLM to return _any_ type, but that gets weird with Arrays. basically: why is String special? * only prompt vars expand in prompts, the rest are left as-is so the LLM can assume they're LLM env vars instead * avoid dumping binary strings * cut long strings off at 8k Signed-off-by: Alex Suraci <[email protected]> * checkpoint: per-type selection instead of per-var * consistently use our new IDs (Container#foo) everywhere * theoretically the LLM doesn't need a concept of variables anymore, they're practically just prompt vars implicitly pre-installed in the environment, and the LLM discovers the rest from there Signed-off-by: Alex Suraci <[email protected]> * bbb/workspace: better span mechanics use Reveal on attempt span instead, which works much better anyway Signed-off-by: Alex Suraci <[email protected]> * bbb/workspace: make object IDs more prominent Signed-off-by: Alex Suraci <[email protected]> * iterate * also add a cache buster (+ Go build caching) for better deoms Signed-off-by: Alex Suraci <[email protected]> * fix cryptic function call/response LLM API errors when an LLM tried to call an unknown tool, we silently ignored it; now we error early Signed-off-by: Alex Suraci <[email protected]> * telemetry: convert Foo#1 to the actual Call arg makes `_select_Container` look much nicer Signed-off-by: Alex Suraci <[email protected]> * llm: more rigorous tool schemas * support input objects (e.g. BuildArg) and enums * error on any unsupported types so we can figure em all out * configure pattern for ID args, make explicit in description for LLMs that don't support them (Gemini) Signed-off-by: Alex Suraci <[email protected]> * nudge LLM along if it forgets to select first also, clean up a bunch of tools that I _think_ we no longer need at all. even _saveAs never provided much use since you can't predict what name it will use. doubling down on this streamlined functional approach until proven wrong. Signed-off-by: Alex Suraci <[email protected]> * clean up failed get call responses showing hashes is no longer useful Signed-off-by: Alex Suraci <[email protected]> * llm(google): avoid panic with no prompt Signed-off-by: Alex Suraci <[email protected]> * update README, regen prompts * remove tool lists from final report, too large Signed-off-by: Alex Suraci <[email protected]> * make telemetry resilient to call conversion errors Signed-off-by: Alex Suraci <[email protected]> * dagql(Int): support conversion from float64 we can't always enable json.Number ahead of time Signed-off-by: Alex Suraci <[email protected]> * llm: support traversing arrays * the telemetry is broken, but it seems to work * also switch from select_Foo to selectFoo, it just looks better Signed-off-by: Alex Suraci <[email protected]> * simplify Evaluate signature it calls it repeatedly now which is redundant, and ends up caching anyway Signed-off-by: Alex Suraci <[email protected]> * bump dagger to v0.17.1 Signed-off-by: Alex Suraci <[email protected]> * llm: only enable default prompt + tools list for Gemini We don't want to rely on a system prompt too much, because we won't have that luxury when embedded as an MCP server. So, let's treat this as a requirement as Gemini only for now, and gradually enable it as needed. Signed-off-by: Alex Suraci <[email protected]> * expose LLM.tokenUsage Signed-off-by: Alex Suraci <[email protected]> * smaller system prompt, fancy evals test pattern This prompt passed 20/20 times! I guess just tell it it's an expert and it loses its imposter syndrome? Signed-off-by: Alex Suraci <[email protected]> * string limit: 8k => 80k Signed-off-by: Alex Suraci <[email protected]> * accept number-only ID args in the spirit of "be liberal in what you accept" - some models might interpret Container#1 as Container #1 Signed-off-by: Alex Suraci <[email protected]> * LLMEnv: cleanup Signed-off-by: Alex Suraci <[email protected]> * properly implement selectFoo(id: "1") compatibility Signed-off-by: Alex Suraci <[email protected]> * regen SDKs + docs Signed-off-by: Alex Suraci <[email protected]> * rm botsbuildingbots moving to my own repo, too experimental Signed-off-by: Alex Suraci <[email protected]> * rm debugging when we bring this back, maybe let's do otel instead? Signed-off-by: Alex Suraci <[email protected]> * fix lints Signed-off-by: Alex Suraci <[email protected]> * fix nil LLM promptVars Signed-off-by: Alex Suraci <[email protected]> * update fixtures Signed-off-by: Alex Suraci <[email protected]> * fix selecting tool object results Signed-off-by: Alex Suraci <[email protected]> * fix OpenAI tool call ID + result inversion Signed-off-by: Alex Suraci <[email protected]> * LLM/TestAPILimit: just send multiple prompts model behavior seems to vary wildly at the moment - it's pretty hesitant to follow instructions, but that seems like a problem independent from the goal of this test Signed-off-by: Alex Suraci <[email protected]> * fix prompt vars not expanding Signed-off-by: Alex Suraci <[email protected]> * llm(env): add currentSelection dummy tool Explanation in comment. Without this tool gpt-4o reliably refuses to operate on the current state. The problem goes away by the mere presence of this tool, without even calling it. Signed-off-by: Alex Suraci <[email protected]> * llm: hint model when we're leaving a state so that it knows it can swap back to it, even if it was never told its ID currentState ALMOST helps with this, but not really, since it doesn't go into message history Signed-off-by: Alex Suraci <[email protected]> * appease linter Signed-off-by: Alex Suraci <[email protected]> * update fixtures Signed-off-by: Alex Suraci <[email protected]> * support dynamic variable discovery For when you can't/don't want to reference them directly in your prompt. Tested with GPT-4o and Claude 3.7 sonnet, but Gemini has trouble. Signed-off-by: Alex Suraci <[email protected]> * llm: always provide tool hints seems like more models need this than don't Signed-off-by: Alex Suraci <[email protected]> * llm: reword available bindings dont want the model to think these are the ONLY possible inputs Signed-off-by: Alex Suraci <[email protected]> * allow variables passed to ID args this is supported, and some models try it Signed-off-by: Alex Suraci <[email protected]> --------- Signed-off-by: Alex Suraci <[email protected]>
shykes
added a commit
that referenced
this pull request
Feb 26, 2026
Document contagious nullability (the #1 source of dang type errors), fix patterns (null coalescing, flow-sensitive checks, guard-early), and null narrowing limitations in both SKILL.md and language.md. Co-Authored-By: Claude Opus 4.6 <[email protected]>
shykes
added a commit
that referenced
this pull request
Mar 5, 2026
Document contagious nullability (the #1 source of dang type errors), fix patterns (null coalescing, flow-sensitive checks, guard-early), and null narrowing limitations in both SKILL.md and language.md. Co-Authored-By: Claude Opus 4.6 <[email protected]>
shykes
added a commit
that referenced
this pull request
Mar 5, 2026
Document contagious nullability (the #1 source of dang type errors), fix patterns (null coalescing, flow-sensitive checks, guard-early), and null narrowing limitations in both SKILL.md and language.md. Co-Authored-By: Claude Opus 4.6 <[email protected]>
shykes
added a commit
that referenced
this pull request
Mar 5, 2026
Document contagious nullability (the #1 source of dang type errors), fix patterns (null coalescing, flow-sensitive checks, guard-early), and null narrowing limitations in both SKILL.md and language.md. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Solomon Hykes <[email protected]>
shykes
added a commit
that referenced
this pull request
Mar 5, 2026
Document contagious nullability (the #1 source of dang type errors), fix patterns (null coalescing, flow-sensitive checks, guard-early), and null narrowing limitations in both SKILL.md and language.md. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Solomon Hykes <[email protected]>
sipsma
added a commit
that referenced
this pull request
Jun 16, 2026
…analyzer (#13393) * wcprof: experimental wall-clock profiler + counterfactual bottleneck analyzer Adds an experimental, cheap wall-clock profiling system (wcprof) for the engine plus an offline analyzer that finds latency bottlenecks by counterfactual simulation. Built to systematically catch the class of problem that CPU/memory profiles can't see: serial wall-clock taxes like the ~300ms un-pooled CNI netns setup that used to run before every container start while nothing else made progress. Why not OTel ============ The existing telemetry path is unsuitable for this both in cost and in shape: AroundFunc proto-encodes the full call DAG per span, every span is written to per-client SQLite databases (fanned out to all parent clients), and repeated/cache-hit calls are deliberately suppressed via ShouldEmitTelemetry, so most calls never appear at all. Spans also only give a tree + timestamps; they can't say *why* an op was idle mid-flight. Design ====== The engine is unusually well-shaped for this: since evaluation became dagql-native, every cross-operation blocking relationship flows through a handful of choke points we own (dagql singleflight, lazy-eval waiters, service starts, cache-volume locks, exec completion channels, the nested-client boundary). That means the true waits-for graph can be *recorded* at the choke points rather than inferred from span nesting. The recipe digest is already computed for every call for cache lookup, so op identity is free. wcprof records three fixed-size event types into sharded in-memory buffers with interned strings (~72B/event, default cap ~4M events, disabled = one atomic load per hook site): - ops: timed intervals with kind (call, call_exec, lazy, exec, exec_phase, service_start, session_phase, internal), class (e.g. Container.withExec, exec.setupNetwork), instance ident (recipe digest / exec id), structural parent (via context), outcome (hit/executed/joined/do_not_cache/...), and a work-type tag separating engine overhead from user work (container process runtime) and external I/O. - waits: exact blocked-on intervals (who waited on which op or named resource, why, from when to when), recorded by the waiter at the choke point itself. - links: non-blocking correlations, most importantly exec op <-> nested client ID so module-function calls back into the API stitch under the exec that hosts them. Hook points in this commit: - dagql getOrInitCall: one call op per caller (cache hits and DoNotCache included -- deliberately recording what OTel suppresses), one shared call_exec op per resolver execution (waiters record singleflight join edges against it), and a publish op for result publication cost. - dagql evaluateOne: lazy ops classed by the call that *created* the lazy value (cost attribution) with wait edges from the triggering/joining ops (blocking attribution) -- the two views stay separate. - engineutil executor: per-exec op + named phase ops (setupNetwork, setupRootfs, ..., runContainer), plus an exec.containerStart vs exec.processRun split so engine overhead and user process time are distinguishable. - core container exec: cache-volume lock waits, prepareMounts / applyOutputs phases. - core services: service_start ops with waiter join edges (start singleflight + health checks). - engine server serveQuery: per-query session phases (attachables wait, workspace load, module load, schema build, query root). Plumbing: hidden `dagger --profile` flag -> ClientMetadata.Profile -> engine-global recorder (also `_DAGGER_WCPROF=1`); dump+flush endpoint at GET /debug/wcprof/dump alongside the other engine debug endpoints. The dump is a JSON header line (string table, open ops for hang visibility) followed by one JSON event per line. Analyzer (cmd/wcprof-analyze, engine/wcprof/wcanalyze) ====================================================== Reconstructs the op graph (parents, waits, nested-client re-parenting), computes self-time (duration minus waits minus child intervals), then runs a replay-based discrete-event simulation of the recorded schedule under counterfactual hypotheses: "class X's self-time scaled by f" for f in {0, 0.5, 0.9}, assuming unlimited resources (never CPU-bound, v1 simplification). Classes are ranked by how much end-to-end makespan each would actually save -- which handles critical-path shifts, singleflight dedup (shared work counted once), and dependency chains, unlike naive "total time per class" tables. Also reports per-class stats with outcome histograms and duplicate-execution detection, an end-of-workload blocking chain, dead-air gaps (uninstrumented blocking), and drift diagnostics. How it worked in practice ========================= Testbed: `dagger call engine-dev container sync`, cold cache, profiled via the dev engine (hack/dev). ~223s wall, ~169k ops, ~25MB dump, zero dropped events, ~36s to analyze. The simulated baseline makespan is checked against the actual makespan as a fidelity metric, and that check earned its keep: it caught three real replay-model bugs during bring-up, found via the included diagnostics (DriftOrigins, ExplainFinish, fallback-anchor counters): 1. Frame mixing: normalizing the first root's sim time to 0 while ops reached through cross-tree wait targets anchored at original timestamps inflated makespan +53%. The simulation now stays entirely in the original trace's time frame. 2. Ident-based exec waits can resolve to the wrong exec when call digests are shared across execs; removed in favor of the exec op being a context-child plus the replay's implicit-join rule, which models the dependency exactly. (Waits that ended before their target's recorded end -- abandoned/canceled -- are also no longer treated as joins.) 3. Fallback anchoring at recorded start times silently re-pinned chains to original times whenever an op's finish was needed while its parent was mid-replay, collapsing counterfactual propagation (processRun x0 "saved" 55ms instead of 41.7s). Fallbacks now anchor at parent sim start + recorded offset. After those fixes the baseline drift is -0.0% on every run measured (smoke, two full builds, two synthetic chains). Results on the testbed: the go build itself (exec.processRun, user work) dominates at ~42-69s recoverable; the top engine-actionable class is Host.directory (filesync) at ~4s; HTTPState._resolve has 207s of total self-time but correctly ranks as a non-bottleneck (parallel to the build) -- exactly the total-time != bottleneck discrimination this is for. One real finding already: exec.setupNetwork has p50 125us but p95 1.52s (44-55s total across ~230 execs) -- a netns-pool exhaustion tail, the same class as the original CNI problem. Validation (known-answer test) ============================== A file-gated injection aid (/tmp/wcprof-inject-netns-delay-ms inside the engine container, only consulted while profiling) injects an artificial delay in setupNetwork. On a strictly serial 10-exec chain with 300ms injected: the analyzer ranked exec_phase:exec.setupNetwork #1 and predicted save@0 = 3.32s; disarming the injection and re-running measured the chain section shrink from 3.57s to 0.46s (actual recovery 3.11s, prediction within ~7%, which also covers the organic tail it zeroes). With the injection disarmed the class dropped out of the rankings entirely -- no false positive. On the engine-dev build the same injection predicted only ~2.4s saved despite ~48s wall growth: execs there start in parallel with the build/download chains, so per-exec start taxes mostly don't serialize in that workload (and cross-run wall comparisons are polluted by network variance -- validate within-run via the sim, or on serial synthetic chains). Known v1 limitations (deliberate) ================================= - recorder is engine-global (any profiled client enables it); per-session scoping is future work - lock waits are modeled as fixed delays (no release->acquire causality) - unlimited-resources assumption; parallel self-time includes mutex contention and scheduler queueing (e.g. egraphMu pressure shows up as dagql.publishResult self-time -- itself a useful signal) - leaf I/O internals (git fetch, image pull, filesync) are not yet sub-instrumented; they appear as self-time of their calling op, and the unexplained-self-time/dead-air reports are the guide for where to hook next Usage ===== ./hack/dev ./hack/with-dev ./bin/dagger --profile call engine-dev container sync curl -s http://localhost:6060/debug/wcprof/dump > /tmp/wcprof.dump go run ./cmd/wcprof-analyze /tmp/wcprof.dump Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Erik Sipsma <[email protected]> * wcprof: compile replay program once, parallelize what-ifs, merge multi-drain dumps The analyzer choked on a full TestModule profile (9.8M events, 9.68M ops, 1125 roots): the replay rebuilt and re-sorted every op's action list on every one of ~600 what-if simulations with map-based memos, projecting to hours. The per-op timeline is factor-independent, so it is now compiled once per graph into flat arrays (dense int32 op indices, pre-sorted action streams with the join/fixed/abandoned wait classification baked in), each simulation is a pure slice-based DP over that program, and the (class, factor) simulations run in parallel (bounded at 8 workers to cap per-sim state memory). Results are unchanged (known-answer fixtures plus a regression check against a previous dump: identical drift, cycle and fallback-anchor counts). engine-dev build dump (191k events): 36s -> 1.2s TestModule dump set (9.8M events): killed at 37min -> 74s, 16GB peak Also adds multi-dump merging (wcanalyze.LoadMulti + variadic args in wcprof-analyze): long runs are drained periodically via the dump endpoint to stay under the recorder's event cap, and the drains merge losslessly because the string table only grows, op IDs are unique, the epoch is fixed, and the drop counter is cumulative. The TestModule run needed this: 9.8M events vs the 4M default cap, zero drops with 40s drains. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Erik Sipsma <[email protected]> * wcprof: session-scoped recording + runtime global toggle Pre-merge cleanup of how profiling is enabled, replacing the original "any --profile client stickily enables the engine-global recorder forever" prototype behavior with two explicit scopes: - Engine-global: enabled at startup via the (hidden) --wcprof engine flag or _DAGGER_WCPROF=1, and toggleable at runtime through a new debug endpoint: POST "on"/"off" (or any boolean) to /debug/wcprof/enabled; GET reports state. Disabling stops global recording but keeps the recorder and buffered events dumpable, lets sessions that opted in keep recording, and lets in-flight recorded ops finish. Re-enabling reuses the same recorder, so dumps from before/after merge cleanly (same epoch). - Per-session: a client connecting with ClientMetadata.Profile (the hidden --profile CLI flag) records only its own session's work. The flag is latched onto the daggerSession, which nested module/SDK clients share, so their work is included. serveQuery marks request contexts via wcprof.ContextWithProfiling; hooks record iff a recorder exists AND (global mode is on, OR the context carries the mark or a recorded parent op ID). The mark survives context.WithoutCancel, so lazy evaluations, execs, and service starts inherit it. Known degradation: a profiled call that singleflight-joins an unprofiled session's in-flight execution records an unresolved wait (modeled by the analyzer as a fixed delay); cross-session joins are effectively nonexistent today, so this is acceptable. Also: - Remove the netns delay-injection validation aid from setupNetwork; it served its purpose validating the analyzer and should not merge. - Disabled-path overhead audit: every hook is a single atomic load + nil check when profiling was never enabled; the one allocation found on that path (the "cachelock:"+key concat per cache-volume lock) is now gated behind wcprof.Enabled(ctx). Once a recorder exists, unprofiled work pays the atomic load plus two ctx.Value walks (~100ns/hook); zero impact for engines that never enable profiling. Validated on a rebuilt dev engine: fresh engine reports off and dump returns 503; an unprofiled session leaves the recorder absent; a --profile session records (26k events) while the next unprofiled session adds exactly 0; POST on/off flips recording for unprofiled sessions (26k events vs 0) with the buffer still dumpable after off; invalid POST bodies return 400. A --profile `dagger call` that loads workspace toolchain modules produced a 149k-event dump in which nested SDK clients are fully captured (single stitched root, simulated baseline drift -0.0%). Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Erik Sipsma <[email protected]> --------- Signed-off-by: Erik Sipsma <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
Merged
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.
No description provided.