Skip to content

Commit

Permalink
Merge branch 'main' into wamr
Browse files Browse the repository at this point in the history
  • Loading branch information
xdoardo authored Jun 7, 2024
2 parents a25028f + 80435ac commit 6423ea9
Show file tree
Hide file tree
Showing 91 changed files with 1,998 additions and 492 deletions.
36 changes: 35 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ env:
MSRV: "1.74"
NEXTEST_PROFILE: "ci"
RUSTUP_WINDOWS_PATH_ADD_BIN: 1
WASI_SDK_VERSION: "22"

jobs:

setup:
name: Set up
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -144,6 +144,40 @@ jobs:
# run: |
# make test-js-core

test_wasix:
name: Test WASIX
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.MSRV }}
- name: Install Tools
run: |
sudo apt-get update
sudo apt-get install -y git llvm clang make lld curl
- name: Build wasix sysroot
run: |
cd ~
git clone --recurse-submodules https://github.com/wasix-org/wasix-libc
cd wasix-libc
./build32.sh
rm -rf /opt/wasix-sysroot
cp -r sysroot32 ~/wasix-sysroot
- name: Install wasi-sdk Tools
run: |
cd ~
curl -L "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{ env.WASI_SDK_VERSION }}/wasi-sdk-${{ env.WASI_SDK_VERSION }}.0-linux.tar.gz" -o wasi-sdk.tar.gz
tar -xzf wasi-sdk.tar.gz
cp -r wasi-sdk-${{ env.WASI_SDK_VERSION }}.0 ~/wasi-sdk
- name: Install wasm-opt
run: |
sudo apt-get install -y binaryen
- name: make test-wasix
run: |
WASI_SDK=~/wasi-sdk WASIX_SYSROOT=~/wasix-sysroot make test-wasix
test_wasm_build:
name: Test wasm build
runs-on: ubuntu-22.04
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ wasmer-config = { path = "./lib/config" }
wasmer-wasix = { path = "./lib/wasix" }

# Wasmer-owned crates
webc = { version = "6.0.0-alpha9", default-features = false, features = [
"package",
] }
webc = { version = "6.0.0-rc1", default-features = false, features = ["package"] }
edge-schema = { version = "=0.1.0" }
shared-buffer = "0.1.4"

Expand Down Expand Up @@ -208,6 +206,8 @@ opt-level = 3
opt-level = 3
[profile.dev.package.sha2]
opt-level = 3
[profile.dev.package.xxhash-rust]
opt-level = 3
[profile.dev.package.digest]
opt-level = 3

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,10 @@ test-wasi-fyi: build-wasmer
cd tests/wasi-fyi; \
./test.sh

test-wasix: build-wasmer
cd tests/wasix; \
./test.sh

test-integration-cli: build-wasmer build-capi package-capi-headless package distribution
cp ./dist/wasmer.tar.gz ./link.tar.gz
rustup target add wasm32-wasi
Expand Down
3 changes: 3 additions & 0 deletions benches/import_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub fn run_import_inner(store: &mut Store, n_fn: u32, compiler_name: &str, c: &m
}

fn run_import_functions_benchmarks_small(_c: &mut Criterion) {
#[allow(unused_variables)]
let size = 10;

#[cfg(feature = "llvm")]
Expand All @@ -78,6 +79,7 @@ fn run_import_functions_benchmarks_small(_c: &mut Criterion) {
}

fn run_import_functions_benchmarks_medium(_c: &mut Criterion) {
#[allow(unused_variables)]
let size = 100;

#[cfg(feature = "llvm")]
Expand All @@ -100,6 +102,7 @@ fn run_import_functions_benchmarks_medium(_c: &mut Criterion) {
}

fn run_import_functions_benchmarks_large(_c: &mut Criterion) {
#[allow(unused_variables)]
let size = 1000;
#[cfg(feature = "llvm")]
{
Expand Down
3 changes: 3 additions & 0 deletions docs/journal.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,6 @@ in line as the events are generated
Filters out a specific set of log events and drops the rest, this
capturer can be useful for restoring to a previous call point but
retaining the memory changes (e.g. WCGI runner).

## Improvements
https://codesandbox.io/blog/how-we-scale-our-microvm-infrastructure-using-low-latency-memory-decompression
78 changes: 54 additions & 24 deletions lib/backend-api/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type User implements Node & PackageOwner & Owner {
bio: String
location: String
websiteUrl: String
wasmerInternal: Boolean!

"""The ID of the object"""
id: ID!
Expand Down Expand Up @@ -199,6 +200,7 @@ type Namespace implements Node & PackageOwner & Owner {
websiteUrl: String
createdAt: DateTime!
updatedAt: DateTime!
wasmerInternal: Boolean!
maintainerInvites(offset: Int, before: String, after: String, first: Int, last: Int): NamespaceCollaboratorInviteConnection!
userSet(offset: Int, before: String, after: String, first: Int, last: Int): UserConnection!
globalName: String!
Expand Down Expand Up @@ -446,6 +448,7 @@ type PackageVersion implements Node & PackageReleaseInterface & PackageInstance
bindingsState: RegistryPackageVersionBindingsStateChoices!
nativeExecutablesState: RegistryPackageVersionNativeExecutablesStateChoices!
deployappversionSet(offset: Int, before: String, after: String, first: Int, last: Int): DeployAppVersionConnection!
packagewebcSet(offset: Int, before: String, after: String, first: Int, last: Int): PackageWebcConnection!
lastversionPackage(offset: Int, before: String, after: String, first: Int, last: Int): PackageConnection!
commands: [Command!]!
nativeexecutableSet(offset: Int, before: String, after: String, first: Int, last: Int): NativeExecutableConnection!
Expand Down Expand Up @@ -504,7 +507,9 @@ scalar JSONString
type WebcImage implements Node {
"""The ID of the object"""
id: ID!
version: WebcVersion

"""The version of the webc image, defaults to v2."""
version: WebcVersion!

""""""
fileSize: BigInt!
Expand Down Expand Up @@ -835,6 +840,26 @@ type AppVersionVolumeMountPath {
subpath: String!
}

type PackageWebcConnection {
"""Pagination data for this connection."""
pageInfo: PageInfo!

"""Contains the nodes in this connection."""
edges: [PackageWebcEdge]!

"""Total number of items in the connection."""
totalCount: Int
}

"""A Relay edge containing a `PackageWebc` and its cursor."""
type PackageWebcEdge {
"""The item at the end of the edge"""
node: PackageWebc

"""A cursor for use in pagination"""
cursor: String!
}

type Command {
command: String!
packageVersion: PackageVersion!
Expand Down Expand Up @@ -1227,26 +1252,6 @@ type AppTemplateCategory implements Node {
appTemplates(offset: Int, before: String, after: String, first: Int, last: Int): AppTemplateConnection!
}

type PackageWebcConnection {
"""Pagination data for this connection."""
pageInfo: PageInfo!

"""Contains the nodes in this connection."""
edges: [PackageWebcEdge]!

"""Total number of items in the connection."""
totalCount: Int
}

"""A Relay edge containing a `PackageWebc` and its cursor."""
type PackageWebcEdge {
"""The item at the end of the edge"""
node: PackageWebc

"""A cursor for use in pagination"""
cursor: String!
}

type Collection {
slug: String!
displayName: String!
Expand Down Expand Up @@ -2088,6 +2093,9 @@ type Log {

"""Log stream"""
stream: LogStream

"""ID of instance from which the log was generated"""
instanceId: String!
}

"""This is for backwards compatibility with the old PackageInstance type."""
Expand Down Expand Up @@ -2249,7 +2257,7 @@ type Query {
getAppByGlobalAlias(alias: String!): DeployApp
getDeployApps(sortBy: DeployAppsSortBy, updatedAfter: DateTime, offset: Int, before: String, after: String, first: Int, last: Int): DeployAppConnection!
getAppVersions(sortBy: DeployAppVersionsSortBy, updatedAfter: DateTime, offset: Int, before: String, after: String, first: Int, last: Int): DeployAppVersionConnection!
getAppTemplates(categorySlug: String, offset: Int, before: String, after: String, first: Int, last: Int): AppTemplateConnection
getAppTemplates(categorySlug: String, sortBy: AppTemplatesSortBy, offset: Int, before: String, after: String, first: Int, last: Int): AppTemplateConnection
getAppTemplate(slug: String!): AppTemplate
getAppTemplateCategories(offset: Int, before: String, after: String, first: Int, last: Int): AppTemplateCategoryConnection
viewer: User
Expand Down Expand Up @@ -2348,6 +2356,12 @@ enum DNSRecordsSortBy {
OLDEST
}

enum AppTemplatesSortBy {
NEWEST
OLDEST
POPULAR
}

type AppTemplateCategoryConnection {
"""Pagination data for this connection."""
pageInfo: PageInfo!
Expand Down Expand Up @@ -2788,6 +2802,9 @@ type Mutation {
generateDeployConfigToken(input: GenerateDeployConfigTokenInput!): GenerateDeployConfigTokenPayload
renameApp(input: RenameAppInput!): RenameAppPayload
renameAppAlias(input: RenameAppAliasInput!): RenameAppAliasPayload

"""Purges all cache for this app version"""
purgeCacheForAppVersion(input: PurgeCacheForAppVersionInput!): PurgeCacheForAppVersionPayload
requestAppTransfer(input: RequestAppTransferInput!): RequestAppTransferPayload
acceptAppTransferRequest(input: AcceptAppTransferRequestInput!): AcceptAppTransferRequestPayload
removeAppTransferRequest(input: RemoveAppTransferRequestInput!): RemoveAppTransferRequestPayload
Expand Down Expand Up @@ -3026,6 +3043,18 @@ input RenameAppAliasInput {
clientMutationId: String
}

"""Purges all cache for this app version"""
type PurgeCacheForAppVersionPayload {
appVersion: DeployAppVersion!
clientMutationId: String
}

input PurgeCacheForAppVersionInput {
"""ID of the app version to purge cache for."""
id: ID!
clientMutationId: String
}

type RequestAppTransferPayload {
appTransferRequest: AppTransferRequest
wasInstantlyTransferred: Boolean!
Expand Down Expand Up @@ -3086,6 +3115,7 @@ input CreateRepoForAppTemplateInput {
name: String!
namespace: String!
private: Boolean = false
domains: [String] = null
clientMutationId: String
}

Expand Down Expand Up @@ -3606,9 +3636,9 @@ type TagPackageReleasePayload {

input TagPackageReleaseInput {
packageReleaseId: ID!
name: String!
version: String!
manifest: String!
name: String
manifest: String
namespace: String
description: String
license: String
Expand Down
16 changes: 15 additions & 1 deletion lib/backend-api/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub async fn get_signed_url_for_package_upload(
version: Option<&str>,
) -> Result<Option<SignedUrl>, anyhow::Error> {
client
.run_graphql(types::GetSignedUrlForPackageUpload::build(
.run_graphql_strict(types::GetSignedUrlForPackageUpload::build(
GetSignedUrlForPackageUploadVariables {
expires_after_seconds,
filename,
Expand Down Expand Up @@ -1137,6 +1137,20 @@ pub fn get_all_dns_records_stream(
)
}

pub async fn purge_cache_for_app_version(
client: &WasmerClient,
vars: types::PurgeCacheForAppVersionVars,
) -> Result<(), anyhow::Error> {
client
.run_graphql_strict(types::PurgeCacheForAppVersion::build(vars))
.await
.map_err(anyhow::Error::from)
.map(|x| x.purge_cache_for_app_version)
.context("backend did not return data")?;

Ok(())
}

/// Convert a [`OffsetDateTime`] to a unix timestamp that the WAPM backend
/// understands.
fn unix_timestamp(ts: OffsetDateTime) -> f64 {
Expand Down
17 changes: 17 additions & 0 deletions lib/backend-api/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,23 @@ mod queries {
pub records: Option<Vec<Option<DnsRecord>>>,
}

#[derive(cynic::QueryVariables, Debug)]
pub struct PurgeCacheForAppVersionVars {
pub id: cynic::Id,
}

#[derive(cynic::QueryFragment, Debug)]
pub struct PurgeCacheForAppVersionPayload {
pub app_version: DeployAppVersion,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Mutation", variables = "PurgeCacheForAppVersionVars")]
pub struct PurgeCacheForAppVersion {
#[arguments(input: {id: $id})]
pub purge_cache_for_app_version: Option<PurgeCacheForAppVersionPayload>,
}

#[derive(cynic::Scalar, Debug, Clone)]
pub struct BigInt(pub i64);

Expand Down
7 changes: 5 additions & 2 deletions lib/cli/src/commands/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod get;
pub mod info;
pub mod list;
pub mod logs;
pub mod purge_cache;
pub mod version;

mod util;
Expand All @@ -16,15 +17,16 @@ use crate::commands::AsyncCliCommand;
/// Manage Wasmer Deploy apps.
#[derive(clap::Subcommand, Debug)]
pub enum CmdApp {
Deploy(deploy::CmdAppDeploy),
Create(create::CmdAppCreate),
Get(get::CmdAppGet),
Info(info::CmdAppInfo),
List(list::CmdAppList),
Logs(logs::CmdAppLogs),
Create(create::CmdAppCreate),
PurgeCache(purge_cache::CmdAppPurgeCache),
Delete(delete::CmdAppDelete),
#[clap(subcommand)]
Version(version::CmdAppVersion),
Deploy(deploy::CmdAppDeploy),
}

#[async_trait::async_trait]
Expand All @@ -50,6 +52,7 @@ impl AsyncCliCommand for CmdApp {
Self::Delete(cmd) => cmd.run_async().await,
Self::Version(cmd) => cmd.run_async().await,
Self::Deploy(cmd) => cmd.run_async().await,
Self::PurgeCache(cmd) => cmd.run_async().await,
}
}
}
Loading

0 comments on commit 6423ea9

Please sign in to comment.