Recipes
View SourceOne section per kind of change: the files to open, the test that proves it, and the page to update. Use it after CONTRIBUTING.md, when you know what you want to change and need to know where. Every recipe ends with the required checks, which are not repeated here.
pick the recipe -> read what it names -> test that fails -> change
-> checks -> measure, if you claim speed -> record, document -> PRFind your recipe
- Runtime: an instruction or a proposal, an error value, an option, an application setting, memory or the page budget, the compiled tier, the dispatch path, the snapshot format, debug a trap.
- Components and WASI: a preview 1 syscall, a WASI 0.2 interface, a WASI 0.3 interface, a wasi-nn backend, a canonical or async built-in, an HTTP transport, an implementation behind a behaviour, debug a capability refusal.
- Workers: a language adapter, the worker kernel, debug a worker request, actors.
- Tests and fixtures: rebuild or verify a fixture, bump an upstream pin, debug a failing CI job.
- Project: a module, a page, a dependency, a new OTP release, a speed-up, a release.
Add an instruction or a proposal
Adding an instruction has the four stages and the files for each opcode space.
Add or change an error value
Read Failures are values at the guest
boundary
first. An error is a map with a class, a kind, a msg and a ctx, and
nothing a guest supplies may make a call raise.
- Pick the class from the stage that failed, as the specification suite
does:
malformed(it does not decode),invalid(it does not validate),link(it does not instantiate),trap(it failed while running) orexhaustion(it hit a limit). The class decides the constructor:wasm_error:malformed/3,wasm_error:invalid/3,wasm_error:link_error/3,wasm_error:trap/2orwasm_error:exhaustion/2. Each one throws and does not return. - Pick the kind. Callers match on it, so a new kind is a new case in their
code: reuse an existing kind when the failure means the same thing to a
caller. Search for the ones in use first, for example
grep -rn "link_error(" src. Trap kinds are thetrap_reason()type inwasm_error; add a new one there. - Write the kind as a literal atom in the source. A name or a code that comes
from the guest goes in
ctx, as a binary. - Set
msgto the specification's text when there is one, becausewasm_spec_runnercompares it with what the suite expects. For a trap or an exhaustion,wasm_errormakes the message from the kind: add a clause for the new kind beside the others. - Make sure the public entry point runs the work inside
wasm_error:capture/1orwasm_error:capture/2, and add where it happened withwasm_error:add_context/2. A key already inctxwins. - Write a case that matches
{error, #{class := C, kind := K}}and watch it fail on the code as it is, then runwasm_prop_SUITE:decode_is_totalfails if bad input now raises,decode_creates_no_atomsif it now makes an atom. - A worker error is a different type. Its kinds are a closed list,
wasm_worker_error:kinds/0, andwasm_adapter_conformancerefuses any other: add a new one there and to thekind()type inwasm_worker_error. - Name the new kind in the guide that describes the failure, so a caller knows to match on it.
Add an option
- Check it against the rule first: an option says what the embedder knows
(a limit, a timeout, isolation, whether to compile), never how the runtime
does it. A tactic that wins only sometimes is chosen from what the runtime
can observe, or recorded in
test/audit/ATTEMPTS.mdwith one default shipped. - A limit goes in
wasm_limitsand is checked inwasm; a worker option inwasm_script_worker, where a bad value is refused as{bad_option, Key, Why}. - Document it in Worker configuration or Hold modules and instances, with its default, and add its row to Configuration.
Add an application setting
An application setting is a key in the wasm application environment, and
it applies to the whole node. Most new settings should be something else.
Pick the kind of setting from what it says, as Options say what you know asks:
- a bound on what one instance's guest may use (work, memory, depth) is a limit: see Add an option;
- something the caller of one instance knows (compile it, link it, make it capturable) is an instantiate option;
- a worker's deadline, isolation or byte counts are worker options;
- something the whole node shares (a budget, a cache size, a directory) is an application setting.
A tactic, such as a cache shape or a chunk size, is none of these.
Read it where it is used, with
application:get_env(wasm, Key, Default), and keep the default in a-definebeside the read, aswasm_enginedoes forpage_limit. Theenvlist insrc/wasm.app.srcis empty: every default lives in the code that reads it.Decide when it is read. The module cache and the page budget read theirs when the application starts, so a change needs a restart; say so in its row.
Refuse a value that cannot mean what it says with an error value, as
wasm_snapshot_filerefuses a bad size ceiling withsnapshot_config_invalid.Add its row to Configuration, in the table for its area, with its default and the page that explains it. A setting that is not supported API goes under "Internal settings".
If a worker or the reaper reads it, add it to the list in
every_setting_is_documentedinwasm_worker_kernel_SUITE. That case fails until Worker configuration names it.
Change how memory or the page budget works
- Read the module docs of
wasm_memory,wasm_keeperandwasm_enginefirst: the keeper is the lifetime authority for anything two instances share, and every page is reserved before it is allocated. - Run the
wasm_resource_*,wasm_budget_SUITE,wasm_shared_pages_SUITEandwasm_paged_memory_SUITEsuites, andwasm_snapshot_SUITEif restored memories are involved. - Memory access is on the hot path: measure it with the
protocol, including
realbenchon QuickJS.
Change the compiled tier
- Policy (what compiles, and when) is in
wasm_jit; the code generator iswasm_core; resident code iswasm_code_slots; the disk cache iswasm_code_cache. Thepluginandscriptprofiles aredefaults/1inwasm. Compiled code built ahead of time is theahead of timesection ofwasm_jit(precompile/3,preload_unit/2), its file formatwasm_unit_file, and its slot claimwasm_code_slots:claim_slot/4; its tests arewasm_precompile_SUITE. - If generated code changes shape (what it reads, what a continuation
carries, which helper it calls), bump
ABIinwasm_jitin the same commit and say what an older artifact would do wrong. Compiled tier internals has the rule and the history. A bump also makes every unit file a user built{miss, abi}, so the changelog entry tells them to build their unit files again. - Gate cold compile time and generated code size as well as speed. A change that sped up calls once quadrupled compile time because no gate looked.
- Run
realbenchon QuickJS, five interleaved pairs, both orderings.
Change the interpreter's dispatch path
Anything in run/3, branch/3 or do_call/4 in wasm_exec. Three changes
there cost about 70% on QuickJS while the synthetic loop measured nothing. Run
realbench on QuickJS before you believe any other number; see
Measuring.
Change the snapshot format
A snapshot file carries two version numbers in its header, both defined in
wasm_snapshot_file. Nothing derives them, so you bump them by hand.
- Find which number your change moves in the table in Compiled tier
internals:
FORMAT, read withwasm_snapshot_file:format_version/0, when the file layout changes: its header or its sections;IMAGE_ABI, read withwasm_snapshot_file:image_abi/0, when the value representation in an image changes, or its set of parts.
- Bump it in the same commit as the change. A file written with another
number is refused with
snapshot_format_unknownorsnapshot_abi_mismatch, and a worker treats that as no image and captures a new one.IMAGE_ABIis also part of the keywasm_snapshot_storefiles an image under. - Test it in
wasm_snapshot_SUITE: an image you write must restore, and a damaged one must be refused as a value. The cases named..._is_refusedare the model. - Run
wasm_shared_pages_SUITE. Its casea_file_from_the_last_release_loadsreadstest/fixtures/snapshot/pager-0.8.0.img, which an older release wrote, and fails after a bump. That failure is what users will see: say in Upgrading that images saved by an older release are refused and captured again, and update the case and its fixture in the same commit. - Update When a file is refused if the reasons change.
Debug a trap
- Read the error value:
classsays which stage failed,kindis machine-readable,ctxsays where. - If the compiled tier is on, ask it:
wasm_jit:diagnostics/0for why recent compiles were refused or failed,wasm_jit:dump/1for an instance's generated code. - Rerun with a
fuellimit. Compiled code never runs under fuel, so the call is interpreted end to end: a trap that goes away is a generator bug. - Pin it with a case, in
wasm_trap_effects_SUITEif the trap leaves state behind.
Add a WASI preview 1 syscall
- Add its name to the
Fnslist inwasi_preview1:imports/2; that list is the import map. - Add a
handle/5clause inwasi_preview1. It returns{errno, E}, or{errno, E, State}when it changed the per-instance state; an exception becomesEIO, never a crash. - Put filesystem work in
wasi_fsand path resolution inwasi_path, so the sandbox checks stay in one place. Sockets go throughwasi_sock, and every address decision throughwasi_net. - Add a case to the
wasi_*suite for that area, and one for the refusal: a missing capability must answer an errno, not succeed. - Add it to "Which syscalls are implemented" in WASI preview 1.
Add a WASI 0.2 function or interface
- Find the interface's builder in
wasi_preview2(its module doc has a table), or add one returning a map keyed by{Interface, Field}.wasi:filesystemlives inwasi_p2_filesystemandwasi:socketsinwasi_p2_sockets; neither calls back intowasi_preview2, which would add a module cycle. - Build each function with
wasm_component:import_fun/2, giving its Canonical ABI signature;wasm_canonlifts and lowers the values. - Reuse the preview 1 internals (
wasi_fs,wasi_net) rather than writing a second sandbox. - Merge it into
command/1if a command component needs it. - Test it in the matching
wasm_wasi2_*suite, and update Components or WASI preview 1.
Write a wasi-nn backend
A backend is not part of this project: it lives in the application that has the inference engine. wasi-nn has the callbacks.
- Implement the
wasi_nnbehaviour. Answer{error, {Code, Message}}for every failure; a raise reaches the guest asruntime-errorwith no detail. - Bound the time
compute/2may take. The runtime does not. - Export
load/4only if the engine reads a model from bytes, and check each input withwasi_nn:check_tensor/1if the model has fixed shapes. - Free what a graph or a context holds in
close/1. It is called once for each, on the guest's drop or when the instance is destroyed. - To change the host side (the grant, the tensor bound, a function of the
interface), edit
wasi_nnand add a case towasm_wasi2_nn_SUITE. Its backends arewasi_nn_test_backend, shaped like a language model, andwasi_nn_classifier_backend, shaped like a tensor model, both undertest/support/. When the interface changes upstream, replace the WIT file undertest/fixtures/component/wasinn/wit/deps/nn/: the vector cases read the functions and the enums from it.
Add a WASI 0.3 interface
Read WASI 0.3 and "Where to add things" in Component internals first.
Put small, stateless functions in
wasi_preview3, beside itsclocksandrandombuilders. A larger interface gets a module of its own, besidewasi_p3_filesystem,wasi_p3_socketsandwasi_p3_http. Merge its map inwasi_preview3:command/1;wasi_preview3:snapshot_hooks/0then declares it too.Key every function
{<<"wasi:pkg/iface@0.3">>, Field}. A 0.3 import is looked up with@0.3and never matches a 0.2 key without a version: see Versioned imports.A call that waits is an async import:
{async_import, Sig, Fun}completes at once, and{async_import, Sig, Fun, {producer, PFun}}completes when the producer says it is done, aswait-fordoes inwasi_preview3. Data moves through streams and futures: The async ABI has the host's ends.Keep it in step with 0.2. The two hosts take one options map, which
wasi_preview3:command/1hands to both, so a 0.2 option must mean the same at 0.3. Check network access with the samenetworkgrant throughwasi_net, and mount files withwasi_preview2:command_mounts/1andwasi_fs, aswasi_p3_socketsandwasi_p3_filesystemdo.Test it with wasmtime's program for it, if there is one. Add a case for the program to
wasm_wasi3_p3_SUITE, asclocks_sleepis written, and put the program in a group ingroup/1andbaseline/0. Run your case before the change, here shown withclocks_sleep, and watch the program trap or exit non-zero:WASM_REQUIRE_WASMTIME_FIXTURES=1 \ rebar3 ct --suite=test/wasm_wasi3_p3_SUITE --case=clocks_sleepWithout the variable a missing program skips, and a skip is green. For a behaviour no program covers, write a component by hand, as
test/fixtures/component/wasi3keys/is, and test it inwasm_component_version_SUITE, which never skips.Add the interface to "What is there" in WASI 0.3.
Add a canonical or async built-in
A canonical built-in is a core function that the Canonical ABI defines, such
as stream.read or thread.yield. A component asks for one by its opcode in
its canon section.
- Decode it. Add a clause for its opcode to the
canonfunction inwasm_component_link, returning{canon_async, Name, Meta}, with the operands the built-in needs inMeta(an element type, a slot,async,cancellable). The linker binds every such item throughwasm_async:builtin/2, so the clause is the only linker change. Before it, a component that uses the opcode fails to link with kindunsupported_canon_builtin: that is your failing test. - Implement it. Add a clause for
Nameto the privatebuiltin_1function inwasm_async. It returnsfun(Ctx, Flats) -> {ok, Results} | {trap, Reason}.wasm_async:builtin/2wraps it, so it traps withcannot_leavewhile its instance runs areallocor apost-return. - Write a component that calls it, as text, under
test/fixtures/component/<name>/, and add it to the list inscripts/build-wat-component-fixtures.sh. Ifwasm-toolscannot encode the built-in yet, write a placeholder and rewrite its opcode, asscripts/forward-opcodes.escriptdoes for the forwards. The script also converts wasmtime's thread scripts, so it needs the wasmtime checkout thatscripts/build-wasmtime-p2.shmakes. - Add a case for each behaviour and each trap to
wasm_component_async_abi_SUITE(it reads theasyncabifixture), or towasm_component_forward_SUITEfor a forward. A thread built-in also runs wasmtime's own scripts inwasm_component_wast_SUITE. Every command there must pass; there is no baseline. - Say what it does in The async ABI.
Add an HTTP transport
Implement the wasi_http_transport behaviour, one request/2 callback, as
wasi_http_h1 and wasi_http_h2 do. A component gets it through the
http_transport option of wasi_preview2:command/1. Test it beside
wasm_wasi2_http_SUITE.
Replace an implementation behind a behaviour
Three parts of the runtime have more than one implementation. A new one must pass the same tests as the ones that exist, without a change to the code that calls it.
| boundary | what you write | what exists | the tests |
|---|---|---|---|
wasm_worker_adapter | a language for the worker kernel | wasm_javascript, wasm_python, wasm_lua, and the fake_*_adapter modules in test/support/ | wasm_adapter_conformance, run from a suite of yours: Add a language adapter |
wasi_http_transport | the outbound HTTP connection, one request/2 callback | wasi_http_h1, wasi_http_h2, and fake_http_transport in test/support/, which connects to nothing | wasm_wasi2_http_SUITE, and wasm_wasi2_https_SUITE, which uses the fake: Add an HTTP transport |
the wasi_fs backend | not a behaviour: both backends are in wasi_fs, and wasi_fs:backend/0 says which one runs | native, through wasi_file_nif, and fallback, pure Erlang through wasi_path | wasi_SUITE and wasi_nif_SUITE, on both backends, and wasi_durability_SUITE, which runs its sync cases once on each backend the build has |
If a new adapter needs a change in
wasm_script_worker, that is a kernel change: see Change the worker kernel.The two file backends must refuse the same escapes. To run the file suite on the fallback, build without the NIF, then build it again:
rm -f priv/wasi_file_nif.so CC=false rebar3 ct --suite=test/wasi_SUITE rebar3 compileA change to the C side is in The file NIF.
Debug a WASI capability refusal
A refusal is the host telling the guest it was not granted something. It is an answer to the guest, not an error to you: your call succeeds, and the guest sees an error code.
Find what the guest got:
host a path outside its grant an address outside its grant preview 1 ENOTCAPABLE(76)ENOTCAPABLE, orEBADFfor a descriptor that is not one of its sockets0.2 and 0.3 filesystem not-permitted0.2 and 0.3 sockets access-deniedwasi:http, 0.2 and 0.3HTTP-request-deniedENOTCAPABLEnever means the file is missing (ENOENT) or that the operating system said no (EACCES).Check what you granted. Without
dirs(preview 1) orpreopenandpreopens(0.2 and 0.3) there is no filesystem at all. Withoutnetornetworkthere is no network. Withrequire_native_fsset and no NIF, every directory is refused. A grant the runtime cannot read raises{bad_net_grant, Term}in your own process, when you build the imports.Ask the check itself. Every path decision is made in
wasi_pathand every address decision inwasi_net, so you can call them with no guest:{error, 76} = wasi_path:resolve("/srv/app/data", ~"../secret"), G = wasi_net:grant(#{connect => [{tcp, ~"10.0.0.0/8", {8000, 8099}}]}), true = wasi_net:allows(connect, {tcp, {10, 0, 0, 5}, 8080}, G), false = wasi_net:allows(connect, {tcp, {10, 0, 0, 5}, 22}, G).The 0.2 and 0.3 hosts make the same calls: files go through
wasi_fs, which resolves withwasi_pathor the NIF, and sockets and HTTP throughwasi_net.If you think a refusal is wrong, treat it as a sandbox bug: pin it with a case in
wasi_SUITEorwasi_net_escape_SUITEbefore you change anything. What the sandbox refuses and What the network grant refuses list the refusals that are on purpose.
Add a language adapter
- Implement the
wasm_worker_adapterbehaviour:artifact/1,requirements/2,prepare/3,decode/2,cleanup/1,capabilities/1,conformance_fixtures/1,classify/2, and optionallysnapshot_capability/1anddefaults/1. - If the guest speaks the shared request protocol, build on
wasm_script_v1as the shipped adapters do. - Write a suite that delegates to
wasm_adapter_conformanceand passes without changing the kernel. If the language needs a kernel change, that is Change the worker kernel. - Write the language's page next to JavaScript, and put any heap floor in Tuning.
Writing an adapter is the contract in full.
Change the worker kernel
The kernel is the part of wasm_script_worker that every adapter shares: the
worker, the guardian and the runner, the three processes of a request.
- Read Worker internals first. If the change
touches cleanup, read
test/audit/CLEANUP_STEWARD.mdtoo: it is the reviewed protocol the guardian, the steward and the reaper follow. - Find the code through the table in the module doc of
wasm_script_worker, which gives each process's entry and loop. Keep each process to its job: the worker never blocks, the guardian owns the deadline and the mounts, and only the runner touches the tenant's data. - Write the new case in
wasm_adapter_conformance, not in a suite, so that every adapter runs it. A case every adapter must pass goes in its base list; a case for a capability goes with that capability. - Run it through the fake adapters in
test/support/.wasm_worker_kernel_SUITEruns the kit againstfake_typed_adapter,fake_command_adapter, thescript_v1and reactor fakes, and it never skips. Watch the new case fail on the kernel as it is. - Run the real languages:
wasm_worker_lang_SUITE, with the reactors built as Get the fixtures for a run says. - If a request now leaves something behind, register it as a cleanup action
through the guardian, as "A cleanup step" in Worker
internals says, and run
wasm_cleanup_steward_SUITE. - Every request pays for the kernel. If you claim it costs nothing, time
the request with
bench/paths/phasing_adapter.erland follow the protocol.
Debug a worker request
- Follow the request through its processes in Worker internals: worker, guardian, runner.
wasm_script_worker:cleanup_requests/0lists the requests whose cleanup is still owned, with the guardian holding each.bench/paths/phasing_adapter.erlwraps a real adapter and times a request at each of its adapter boundaries.
Change how actors queue, send or restart
An actor is wasm_actor: one component instance in a gen_server, with a
bounded queue that senders reach without a message to the actor.
wasm_actor_registry only forgets an actor that died without cleaning up.
- Read Actors, which is what callers are promised, and the
module docs of
wasm_actorandwasm_actor_registry. - Keep the three rules a send depends on:
- The name comes last. An actor registers its name in
init/1after its row is in thewasm_actorstable, not throughgen_server's{local, Name}, which registers beforeinit/1runs. Otherwise a sender that finds a restarted actor's name is toldclosed. - Reserve, then check, then give back.
send/2adds one to the queue counter and only then compares it with the capacity; a send that lands past it subtracts its one again and answersfull. So senders racing for the last slot cannot both take it, and the counter never keeps a refused send. The actor subtracts one when it takes a message out, before the guest runs, which is why a full queue takes messages again as soon as the actor works through them, and why a handler can always post one message to itself. - A restarted registry watches every row again. The registry
monitors each actor so a killed one's row goes. The table belongs to
wasm_store, so it outlives a registry restart; the new registry scans it ininit/1, after its name is registered, so a watch request lost with the old one is for a row the scan finds.
- The name comes last. An actor registers its name in
- Add the case to
wasm_actor_SUITE. Its fixture istest/fixtures/component/actor/, rebuilt byscripts/build-wat-component-fixtures.sh; thenoteimport is how a case sees what the guest did. Plant the defect your case is for and watch the case fail before you keep it. A case about freed memory needs an owner that outlives the actor, because an exiting process frees its instance's pages whether or not the actor destroyed it. - A changed promise to callers changes
docs/actors.mdand the module doc together, and the changelog.
Rebuild or verify a fixture
Fixtures lists every family: its kind, its script, the suites that read it and how it is checked.
For a committed fixture, change its source beside it, run its script and commit both: see Rebuild a committed fixture. The snapshot modules come from
scripts/build-snapshot-fixtures.py, the hand-written components fromscripts/build-wat-component-fixtures.sh.For a language runtime, run its fetch or build script again, then check what you have:
scripts/verify-fixtures.shIt checks every file with a
.sha256intest/fixtures/lang/against its hash, and that the QuickJS and Lua reactors are present. CI's Integration job fails on a missing or mismatched file. A new fetched fixture is checked once its.sha256is there.Run the suites that read it. If a page needs it, declare it to
wasm_docs_SUITEwithWASM_DOCS_FIXTURES, as Testing shows.
Bump an upstream pin
Two scripts pin what CI fetches or builds: scripts/fetch-suites.sh names
one commit for each upstream test suite, and scripts/build-wasmtime-p2.sh
names wasmtime's tag in its tag= line. Both check a checkout you already
have against the pin: they move an unchanged one and stop on a changed one, so
changing the pin and running the script is enough. Then update the baselines
the suites keep; never move a suite out of
wasm_spec_manifest:core/0 to make a build pass. Bump an upstream
pin has the steps for each script.
Debug a failing CI job
Find the job in What CI runs: what it runs, what it needs and what skips there.
A job that is red in CI and green on your machine usually ran something your machine skipped. A skip is green, so check your log for skips: Know what skips lists them. Integration runs
wasm_docs_SUITEwithWASM_DOCS_STRICT=1, and "wasmtime programs" setsWASM_REQUIRE_WASMTIME_FIXTURES=1, so a missing fixture fails there.Run the job locally:
job run locally Compile rebar3 compile, then check thatpriv/wasi_file_nif.soexists: CI fails when the NIF falls backTests scripts/fetch-suites.sh,scripts/fetch-qjs-fixture.sh, thenrebar3 ct; for one shard,rebar3 ct --suite="$(scripts/ct-shard.escript 3 N)"Integration the fixtures in Get the fixtures for a run, then rebar3 ct --suite=test/wasm_worker_lang_SUITEand the strict run in Test the documentationwasmtime programs the commands under "One 0.3 program is slow" in What CI runs Lint, Xref, Dialyzer rebar3 lint,rebar3 xref,rebar3 dialyzerDocs rebar3 ex_doc, reading its output as belowNIF checks Run the check build and Run the NIF under a sanitizer NIF under ThreadSanitizer the emulator build in What each sanitizer will and will not find Locked dependencies scripts/audit-deps.shThe Docs job fails on any of these words in the output, because
rebar3 ex_docexits 0 whatever it warns about:rebar3 ex_doc 2>&1 | grep -E "warning:|error in doclet|An unknown error"Know what the caches hold. wasmtime's programs are cached on the hash of
scripts/build-wasmtime-p2.sh, and the build and the Dialyzer PLT on the OTP version and the hash ofrebar.lock. Nothing else makes CI build them again.
Add a module
- Decide its level in Architecture and add it to the
level listing; a call upward means a new cycle, which
wasm_architecture_SUITErefuses. - Open it with a
-moduledocsaying what it is. - Decide its status: internal, unless users are meant to call it.
- Give it a line in Where things are, in the table for its
directory, with that status, and add it to its area's row.
wasm_architecture_SUITEfails on a module the map does not name. - Add it to a group in the
ex_docsection ofrebar.configthat matches its status: a group whose name starts with "Internals: " for an internal module, or a user group such as "Embedding" or "Workers" for a supported one. A supported module also goes in the Supported API list of Start here.
Add a page
- Write it task-oriented: what it is and when you need it, then steps.
- Label every code block with its language; Erlang blocks are parsed and the modules they name must exist.
- Add it to the
ex_docextras and groups inrebar.config, and to a reading path of Start here if a reader needs it on the way.
Add or upgrade a dependency
The runtime depends on two packages: h1 (the Hex package erlang_h1) and
h2, the HTTP/1.1 and HTTP/2 stacks behind wasi:http. Both are maintained
by this project's author. Add a dependency only when the runtime cannot do
without it.
Change the requirement in
depsinrebar.config, then update the lock:rebar3 upgrade h2Commit
rebar.lockwith it. Every CI job keys its build cache on the hash ofrebar.lock, and the Dialyzer job its PLT, so the lock is what makes CI build again.Check the locked versions for known advisories and retired releases. The Audit workflow,
.github/workflows/audit.yml, runs the same script on every pull request and every Monday:scripts/audit-deps.shA test-only dependency, such as
properin thetestprofile, is not in the lock. Name it instead:scripts/audit-deps.sh proper 1.4.0.A new runtime dependency is also an OTP application: add it to
applicationsinsrc/wasm.app.src.Fix a bug in
h1orh2in that library, release it, and bump the requirement here. Do not work around it inwasi_http_h1orwasi_http_h2.Run
wasm_wasi2_http_SUITE,wasm_wasi2_https_SUITE,wasm_wasi2_http_limits_SUITEandwasm_wasi2_serve_SUITE, then the fullrebar3 ct.
Move to a new OTP release
- Change the version everywhere it is pinned, in one commit:
OTPin.github/workflows/ci.ymland.github/workflows/audit.yml, a major version such as'29';OTPin.github/workflows/tsan.yml, an exact release, because that job builds the emulator, and theOTP-29.1.2tag in The file NIF, which tells you to build the same one;- "Erlang/OTP 29 or later" in Getting started
and the comment above
OTPinci.yml, if the minimum moves.
- Run the required checks. The build cache and the Dialyzer PLT are keyed on the OTP version, so CI builds both again.
- Check the compiler defect in Values a multi-value let must not leave
unused.
an_unused_access_result_never_clobbers_a_used_oneinwasm_paged_memory_SUITEguards the waywasm_coreavoids it. Simplify that ordering only if the new release fixes the defect, and the case must still pass under both compile qualities. - Check
test/audit/UPSTREAM-OTP.md. Ifcompile:forms/2can now bound or link the process it compiles in,wasm_coremay no longer need to run the compiler in a process of its own, bound bywasm_lifetime:bind/1. Measure before you remove it. - Use only documented OTP APIs: an undocumented one is what a new release
changes without notice. On an upgrade, recheck the measured exceptions
wasm_architecture_SUITElists, since those are the calls it can break.
Claim a speed-up
Measuring: fix the gates first, measure, and add the result
to test/audit/PERF.md in the same commit. A dropped idea goes in
test/audit/ATTEMPTS.md.
Cut a release
- Review the documentation first. Add a section to
test/audit/DOCS_REVIEW.mdfor what merged since the last release, give it to the maintainer, and wait until they say which findings are fixed before the release. Nothing below starts before that. - Choose the version. A release that changes
ABIinwasm_jitis a minor release, even with nothing else new: every unit file a user built and ships is{miss, abi}until they build it again, so the release asks something of them. - On a
release-X.Y.Zbranch, rename## UnreleasedinCHANGELOG.mdand in Upgrading, check that the changelog's intro covers the whole release, bumpvsninsrc/wasm.app.src, and add upgrade notes to Upgrading if anything breaks. - Open a pull request; merge when CI is green.
- Tag
mainwith an annotatedX.Y.Ztag, and create the GitHub release with the changelog section as its notes. - The maintainer publishes to hex with
make publish.
Read this next
Testing, then Measuring if your change claims speed or memory.