Skip to content

Commit aea826f

Browse files
author
Guy Bedford
authored
feat: Add support for vcpu ms hostcall (#950)
1 parent ed28972 commit aea826f

File tree

18 files changed

+123
-205
lines changed

18 files changed

+123
-205
lines changed

.github/actions/cache-crates/action.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

.github/actions/compute-sdk-test/action.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/actions/install-rust/README.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/actions/install-rust/action.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/dependabot.yml

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ updates:
1515
- "*"
1616
open-pull-requests-limit: 1
1717

18-
- package-ecosystem: "cargo"
19-
directory: "/runtime/js-compute-runtime/rust-url"
20-
schedule:
21-
interval: "daily"
22-
groups:
23-
cargo:
24-
patterns:
25-
- "*"
26-
open-pull-requests-limit: 1
27-
2818

2919
- package-ecosystem: "npm"
3020
directory: "/integration-tests/js-compute"
@@ -34,38 +24,4 @@ updates:
3424
npm:
3525
patterns:
3626
- "*"
37-
open-pull-requests-limit: 1
38-
39-
40-
- package-ecosystem: "npm"
41-
directory: ".github/actions/compute-sdk-test"
42-
schedule:
43-
interval: "daily"
44-
groups:
45-
npm:
46-
patterns:
47-
- "*"
48-
open-pull-requests-limit: 1
49-
50-
51-
- package-ecosystem: "npm"
52-
directory: ".github/actions/github-release"
53-
schedule:
54-
interval: "daily"
55-
groups:
56-
npm:
57-
patterns:
58-
- "*"
59-
open-pull-requests-limit: 1
60-
61-
62-
- package-ecosystem: "npm"
63-
directory: "/sdk/js-compute"
64-
schedule:
65-
interval: "daily"
66-
groups:
67-
npm:
68-
patterns:
69-
- "*"
70-
open-pull-requests-limit: 1
71-
27+
open-pull-requests-limit: 1

.github/workflows/main.yml

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ defaults:
77
run:
88
shell: bash
99
env:
10-
viceroy_version: 0.10.0
11-
wasm-tools_version: 1.0.28
12-
fastly-cli_version: 10.8.10
10+
# Note: when updated, also update version in ensure_cargo_installs
11+
viceroy_version: 0.12.0
12+
# Note: when updated, also update version in ensure_cargo_installs
13+
wasm-tools_version: 1.216.0
14+
fastly-cli_version: 10.13.3
1315

1416
jobs:
1517
check-changelog:
@@ -40,10 +42,10 @@ jobs:
4042
matrix:
4143
include:
4244
- crate: viceroy
43-
version: 0.10.0 # Note: workflow-level env vars can't be used in matrix definitions
45+
version: 0.12.0 # Note: workflow-level env vars can't be used in matrix definitions
4446
options: ""
4547
- crate: wasm-tools
46-
version: 1.0.28 # Note: workflow-level env vars can't be used in matrix definitions
48+
version: 1.216.0 # Note: workflow-level env vars can't be used in matrix definitions
4749
options: ""
4850
runs-on: ubuntu-latest
4951
steps:
@@ -54,8 +56,7 @@ jobs:
5456
path: "/home/runner/.cargo/bin/${{ matrix.crate }}"
5557
key: crate-cache-${{ matrix.crate }}-${{ matrix.version }}
5658
- name: Install ${{ matrix.crate }} ${{ matrix.version }}
57-
run: cargo install ${{ matrix.crate }} ${{ matrix.options }} --version ${{ matrix.version }}
58-
if: steps.cache-crate.outputs.cache-hit != 'true'
59+
run: cargo install ${{ matrix.crate }} ${{ matrix.options }} --version ${{ matrix.version }} --force
5960

6061
shellcheck:
6162
env:
@@ -134,6 +135,7 @@ jobs:
134135

135136
build:
136137
name: Build
138+
needs: [ensure_cargo_installs]
137139
runs-on: ubuntu-latest
138140
strategy:
139141
matrix:
@@ -212,13 +214,6 @@ jobs:
212214
path: "/home/runner/.cargo/bin/wasm-tools"
213215
key: crate-cache-wasm-tools-${{ env.wasm-tools_version }}
214216

215-
- name: "Check wasm-tools has been restored"
216-
if: steps.wasm-tools.outputs.cache-hit != 'true'
217-
run: |
218-
echo "wasm-tools was not restored from the cache"
219-
echo "bailing out from the build early"
220-
exit 1
221-
222217
- run: npm install
223218

224219
- name: Build WPT runtime
@@ -243,7 +238,7 @@ jobs:
243238
matrix:
244239
platform: [viceroy, compute]
245240
profile: [debug, release, weval]
246-
needs: [build]
241+
needs: [build, ensure_cargo_installs]
247242
steps:
248243
- name: Checkout fastly/js-compute-runtime
249244
uses: actions/checkout@v3
@@ -275,10 +270,6 @@ jobs:
275270
path: "/home/runner/.cargo/bin/wasm-tools"
276271
key: crate-cache-wasm-tools-${{ env.wasm-tools_version }}
277272

278-
- name: "Check caches have been restored"
279-
if: steps.wasm-tools.outputs.cache-hit != 'true' || matrix.platform == 'viceory' && steps.viceroy.outputs.cache-hit != 'true'
280-
run: echo "Unable to restore from the cache, bailing." && exit 1
281-
282273
- name: Download Engine
283274
uses: actions/download-artifact@v3
284275
with:

.vscode/c_cpp_properties.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
{
44
"name": "sm-wasi",
55
"includePath": [
6-
"${workspaceFolder}/runtime/spidermonkey/debug/include",
7-
"${workspaceFolder}/runtime/spidermonkey/release/include",
6+
"${workspaceFolder}/runtime/StarlingMonkey/include",
7+
"${workspaceFolder}/runtime/StarlingMonkey/builtins/web",
8+
"${workspaceFolder}/runtime/fastly/build-debug/",
89
"/opt/wasi-sdk/share/wasi-sysroot/include/",
9-
"${workspaceFolder}/runtime/js-compute-runtime",
10-
"${workspaceFolder}/runtime/js-compute-runtime/build/openssl-3.0.7/include",
11-
"${workspaceFolder}/runtime/js-compute-runtime/third_party/fmt/include"
10+
"${workspaceFolder}/runtime/fastly/host-api"
1211
],
1312
"defines": [
1413
"__wasi__"
@@ -23,7 +22,7 @@
2322
"forcedInclude": [
2423
"${workspaceFolder}/.vscode/vscode-preinclude.h"
2524
],
26-
"compileCommands": "${workspaceFolder}/runtime/js-compute-runtime/compile_commands.json"
25+
"compileCommands": "${workspaceFolder}/runtime/fastly/build-debug/compile_commands.json"
2726
}
2827
],
2928
"version": 4

integration-tests/js-compute/fixtures/app/src/assertions-throwing.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ export function assert(actual, expected, code) {
5454
}
5555
}
5656

57+
export { assert as strictEqual }
58+
59+
export function ok(truthy, code) {
60+
if (!truthy) {
61+
fail(
62+
`Expected ${code ? ' ' + code : ''}to be truthy - Found \`${JSON.stringify(prettyPrintSymbol(truthy))}\``,
63+
);
64+
}
65+
}
66+
5767
export async function assertResolves(func) {
5868
try {
5969
await func();
@@ -124,6 +134,8 @@ export function assertDoesNotThrow(func) {
124134
}
125135
}
126136

137+
export { deepEqual as deepStrictEqual }
138+
127139
export function deepEqual(a, b) {
128140
var aKeys;
129141
var bKeys;

integration-tests/js-compute/fixtures/app/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import "./request-method.js";
4444
import "./response-json.js";
4545
import "./response-redirect.js";
4646
import "./response.js";
47+
import "./runtime.js";
4748
import "./secret-store.js";
4849
import "./server.js";
4950
import "./tee.js";
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {
2+
pass,
3+
ok,
4+
strictEqual
5+
} from "./assertions-throwing.js";
6+
import { routes } from "./routes.js";
7+
import { vCpuTime } from "fastly:runtime";
8+
9+
routes.set("/runtime/get-vcpu-ms", () => {
10+
const cpuTime = vCpuTime();
11+
strictEqual(typeof cpuTime, 'number');
12+
ok(cpuTime > 0);
13+
ok(cpuTime < 3000);
14+
const arr = [];
15+
for (let i = 0; i < 10_000; i++) {
16+
arr.push(i);
17+
}
18+
const cpuTime2 = vCpuTime();
19+
ok(cpuTime2 > cpuTime);
20+
ok(cpuTime2 - cpuTime > 1);
21+
ok(cpuTime2 - cpuTime < 3000);
22+
return pass('ok');
23+
});

0 commit comments

Comments
 (0)