Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,041 changes: 0 additions & 2,041 deletions Cargo.lock

This file was deleted.

10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,19 @@ AlloyStack/
│ └── *.json # workflow specification files
├── fs_images/
│ └── *.img # file system images
├── doc/
│ └── ... # detailed documents
```


To run a new test application on AlloyStack, user need to develop functions in the `user/` directory. Then, edit the workflow specification files in the `isol_config/` directory to declare how functions compose the workflow, specify dependencies on LibOS modules, and define input parameters for functions. If the workflow involves reading datasets from files, the datasets must also be added to the file system image. Please use the following command to extract the provided image archive, which contains the source code for the Python benchmarks.

```bash
AlloyStack$ just init
```

Additionally, the repository of AlloyStack is integrated with GitHub Actions. Therefore, tools such as [act](https://github.com/nektos/act) can be used locally to quickly run some basic test cases via Docker.
For detailed documentation, please refer to [AlloyStack User Guide](./doc/).

## Evaluation
### Cold start latency

The cold start of AlloyStack can be categorized into two scenarios: enabling and disabling on-demand loading. The approximate cold start latency is measured using the execution time of `hello_world` and `load_all`, respectively. The following script can be used to automate the testing process.
The cold start of AlloyStack can be categorized into two scenarios: enabling and disabling on-demand loading. The approximate cold start latency is measured using the execution time of `hello_world` and `load_all`, respectively. You have to set the `SUDO_PASSWD` environment variable before running this test using the command `export SUDO_PASSWD=<your_password>`, since some parts of the test require it. The following script can be used to automate the testing process.

```bash
AlloyStack$ just cold_start_latency
Expand Down
13 changes: 10 additions & 3 deletions as_std/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,16 @@ mod refer_based_impl {
}
} else {
let fingerprint = T::__fingerprint();

libos!(buffer_alloc(&slot, l, fingerprint)).expect("alloc failed.") as *mut T

let ptr = libos!(buffer_alloc(&slot, l, fingerprint));
let ptr = ptr.expect("alloc failed.") as *mut T;
if ptr.is_null() {
panic!("buffer_alloc returned null pointer!");
}
// key:Initialize memory immediately after allocation
unsafe {
core::ptr::write(ptr, T::default());
}
ptr
// let val = T::default();
// println!("will write addr=0x{:x}", addr as usize);
// unsafe { core::ptr::write(addr, val) };
Expand Down
148 changes: 148 additions & 0 deletions doc/content_included_in_justfile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Justfile Script Tools Reference

## Utility Tools

### Data Management
```
# Generate test data
AlloyStack$ just gen_data

# Initialize environment
AlloyStack$ just init
```

## Build Commands

### System Services
```
# Build all LibOS modules
AlloyStack$ just all_libos

# Build specific LibOS module
AlloyStack$ just libos <module_name> # e.g., just libos stdio
```

### User Functions
```
# Build Rust user function
AlloyStack$ just rust_func <function_name> # e.g., just rust_func mapper

# Build WASM user function
AlloyStack$ just wasm_func <function_name> # e.g., just wasm_func wasmtime_mapper
```

### Workflow-Specific Builds
```
# Build MapReduce components
AlloyStack$ just map_reduce

# Build Parallel Sort components
AlloyStack$ just parallel_sort

# Build Long Chain components
AlloyStack$ just long_chain

# Build Simple File components
AlloyStack$ just simple_file
```

## Test Execution Tools
### Performance Tests
```
# Run cold start latency tests
AlloyStack$ just cold_start_latency

# Run data transfer latency tests
AlloyStack$ just data_transfer_latency

# Run end-to-end latency tests
AlloyStack$ just end_to_end_latency

# Run breakdown analysis
AlloyStack$ just breakdown

# Run P99 latency tests
AlloyStack$ just p99

# Measure resource consumption
AlloyStack$ just resource_consume
```

### WASM Application Tests

```
# Test C WASM applications
AlloyStack$ just c_end_to_end_latency

# Test Python WASM applications
AlloyStack$ just py_end_to_end_latency
```

## Workflow-Specific Scripts

### C Applications
```
# Build and test C wordcount
AlloyStack$ just c_wordcount

# Build and test C parallel sort
AlloyStack$ just c_parallel_sort

# Build and test C long chain
AlloyStack$ just c_long_chain
```

### Python Applications
```
# Build and test Python wordcount
AlloyStack$ just python_wordcount

# Build and test Python parallel sort
AlloyStack$ just python_parallel_sort

# Build and test Python long chain
AlloyStack$ just python_long_chain
```

## Comprehensive Build Scripts
```
# Build all Rust components
AlloyStack$ just all_rust

# Build all C WASM applications
AlloyStack$ just all_c_wasm

# Build all Python WASM applications
AlloyStack$ just all_py_wasm

# Build all WASM applications
AlloyStack$ just all_wasm

# Build and run all Rust tests
AlloyStack$ just run_rust_test
```
## Environment Configuration
### Build Flags

`enable_mpk` : Enable Memory Protection Keys

`enable_pkey_per_func` : Enable per-function protection keys

`enable_file_buffer` : Enable file-based buffering

`enable_release` : Build in release mode

# Helper Scripts
These scripts are included in [AlloyStack/scripts](../scripts/) directory.

`build_all_common.sh` : Build common LibOS modules

`build_all_common_mpk.sh` : Build LibOS modules with MPK

`build_user.sh` : Build all user functions

`run_tests.sh` : Run test suite

`gen_data.py` : Generate test datasets

`clean_all.sh` : Delete files generated by compilation
81 changes: 81 additions & 0 deletions doc/testing_a_workflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
## Testing a Workflow: map_reduce Example

To test a workflow in AlloyStack user need to go through the following steps. The same methodology applies to any workflow (e.g., Parallel Sort, Function Chain).

### Build System Services
```
# Build all required Libos services
AlloyStack$ just all_libos
```
This command compiles essential system services: `fdtab` `stdio` `mm` `fatfs` `time`

### Build Workflow Functions
```
# Build each function in the workflow
AlloyStack$ just rust_func file_reader
AlloyStack$ just rust_func mapper
AlloyStack$ just rust_func reducer
```
These commands compile the workflow's functional components: `file_reader` `mapper` `reducer`

### Execute the Workflow
```
# Run the map_reduce workflow
AlloyStack$ target/release/asvisor --files isol_config/map_reduce.json
```
### Workflow Execution Process

#### Configuration (map_reduce.json)
```
{
"groups": [
// Stage 1: 3 file readers with different inputs
{
"list": [
{"name": "file_reader", "args": {"slot_name": "part-0", "input_file": "fake_data_0.txt"}},
{"name": "file_reader", "args": {"slot_name": "part-1", "input_file": "fake_data_1.txt"}},
{"name": "file_reader", "args": {"slot_name": "part-2", "input_file": "fake_data_2.txt"}}
]
},
// Stage 2: 3 parallel mappers
{
"list": ["mapper", "mapper", "mapper"],
"args": {"reducer_num": "4"}
},
// Stage 3: 4 parallel reducers
{
"list": ["reducer", "reducer", "reducer", "reducer"],
"args": {"mapper_num": "3"}
}
]
}

# Stage 1: File Reading (Parallel)
file_reader: slot_name: part-0
file_reader: read_size=9881
file_reader: slot_name: part-1
file_reader: read_size=9951
file_reader: slot_name: part-2
file_reader: read_size=9903
...
# Stage 2: Map Processing (Parallel)
mapper: The sum of all values is: 1194
mapper: the counter nums is 825
mapper: shuffle end, cost 0ms
...
# Stage 3: Reduce Processing (Parallel)
reducer0 has counted 372 words
reducer1 has counted 361 words
reducer2 has counted 350 words
reducer3 has counted 362 words
...
```

### Testing Other Workflows
The same 3-step process applies to any workflow:

1.Build services: `just all_libos`

2.Build functions: `just rust_func <function_name>`

3.Execute workflow: `target/release/asvisor --files isol_config/<workflow_name>.json`
21 changes: 15 additions & 6 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

set positional-arguments

enable_mpk := "0"
enable_mpk := "1"
enable_pkey_per_func := "0"
enable_file_buffer := "0"

Expand Down Expand Up @@ -29,7 +29,8 @@ rust_func func_name:

libos lib_name:
cargo build {{ release_flag }} {{ if enable_mpk == "1" { "--features mpk" } else { "" } }} \
--manifest-path common_service/{{ lib_name }}/Cargo.toml
--manifest-path common_service/{{ lib_name }}/Cargo.toml &&\
cp common_service/{{ lib_name }}/target/{{ profile }}/lib{{ lib_name }}.so ./target/{{ profile }}

pass_args:
just rust_func func_a
Expand Down Expand Up @@ -72,7 +73,7 @@ all_rust:
run_rust_test:
just all_libos
just all_rust
./scripts/run_tests.sh {{ mpk_flag }}
./scripts/run_tests.sh {{release_flag}} {{ mpk_flag }}

cc_flags_p1 := "-Wl,--gc-sections -nostdlib -Wl,--whole-archive"
cc_flags_p2 := "-Wl,--no-whole-archive -shared"
Expand Down Expand Up @@ -140,14 +141,22 @@ gen_data:
sudo -E ./scripts/gen_data.py

init:
rustup override set 'nightly-2023-12-01'
rustup override set 'nightly-2024-01-04'
rustup target add x86_64-unknown-linux-musl
rustup target add x86_64-unknown-none
[ -f fs_images/fatfs.img ] || unzip fs_images/fatfs.zip -d fs_images
[ -d image_content ] || mkdir image_content

asvisor:
cargo build {{ release_flag }}

cold_start_latency: asvisor all_libos
#!/bin/bash
if [ -z "$SUDO_PASSWD" ]; then
echo "Error: SUDO_PASSWD environment variable is not set"
echo "Please set it with: export SUDO_PASSWD=<your_password>" && exit 1
fi

just rust_func hello_world
just rust_func load_all
@-./scripts/del_tap.sh 2>/dev/null
Expand Down Expand Up @@ -197,7 +206,7 @@ py_end_to_end_latency: asvisor all_libos all_py_wasm
-sudo mount fs_images/fatfs.img image_content 2>/dev/null
sudo -E ./scripts/gen_data.py 1 '1 * 1024 * 1024' 1 '1 * 1024 * 1024'

sleep 3
sleep 5
@echo 'Python word count cost: '
target/{{profile}}/asvisor --files isol_config/wasmtime_cpython_wordcount_c1.json --metrics total-dur 2>&1 | grep 'total_dur'

Expand Down Expand Up @@ -241,7 +250,7 @@ breakdown: asvisor all_libos
target/{{profile}}/asvisor --files isol_config/parallel_sort_c5.json --metrics total-dur 2>&1 | grep 'total_dur'
target/{{profile}}/asvisor --files isol_config/long_chain_n15.json --metrics total-dur 2>&1 | grep 'total_dur'

p99: asvisor all_libos parallel_sort
p99_latency: asvisor all_libos parallel_sort
-sudo mount fs_images/fatfs.img image_content 2>/dev/null
sudo -E ./scripts/gen_data.py 0 0 3 '25 * 1024 * 1024'

Expand Down
13 changes: 9 additions & 4 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ declare -A results

# 获取脚本参数(feature)
feature_arg=""
if [ $# -gt 0 ]; then
feature_arg="--features $1"
fi
release_arg=""
for arg in "$@"; do
if [[ $arg == --features* ]]; then
feature_arg="$arg"
elif [[ $arg == --release ]]; then
release_arg="--release"
fi
done

for group in "${!test_groups[@]}"; do
names=${test_groups[$group]}

for name in $names; do
output=$(RUST_LOG=info cargo run $feature_arg -- --files "isol_config/$name.json")
output=$(RUST_LOG=info cargo run $release_arg $feature_arg -- --files "isol_config/$name.json")
if [ $? -eq 0 ]; then
results[$name]="passed"
((passed_count++)) # 增加通过计数
Expand Down
2 changes: 1 addition & 1 deletion user/wasmtime_checker/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion user/wasmtime_cpython_func/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion user/wasmtime_cpython_parallel_sort/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading