Cache configuration documentation

This commit is contained in:
Artur Jamro
2019-09-12 15:45:14 -07:00
committed by Dan Gohman
parent 1c22211d57
commit dde1c6ba58
18 changed files with 1238 additions and 233 deletions

View File

@@ -50,7 +50,7 @@ use std::str;
use std::str::FromStr;
use target_lexicon::Triple;
use wasmtime_debug::{emit_debugsections, read_debuginfo};
use wasmtime_environ::cache_init;
use wasmtime_environ::{cache_create_new_config, cache_init};
use wasmtime_environ::{
Compiler, Cranelift, ModuleEnvironment, ModuleVmctxInfo, Tunables, VMOffsets,
};
@@ -63,7 +63,8 @@ The translation is dependent on the environment chosen.
The default is a dummy environment that produces placeholder values.
Usage:
wasm2obj [--target TARGET] [-Odg] [--cache | --cache-config=<cache_config_file>] [--create-cache-config] [--enable-simd] <file> -o <output>
wasm2obj [--target TARGET] [-Odg] [--cache | --cache-config=<cache_config_file>] [--enable-simd] <file> -o <output>
wasm2obj --create-cache-config [--cache-config=<cache_config_file>]
wasm2obj --help | --version
Options:
@@ -73,10 +74,12 @@ Options:
-g generate debug information
-c, --cache enable caching system, use default configuration
--cache-config=<cache_config_file>
enable caching system, use specified cache configuration
enable caching system, use specified cache configuration;
can be used with --create-cache-config to specify custom file
--create-cache-config
used with --cache or --cache-config, creates default configuration and writes it to the disk,
will fail if specified file already exists (or default file if used with --cache)
creates default configuration and writes it to the disk,
use with --cache-config to specify custom config file
instead of default one
--enable-simd enable proposed SIMD instructions
-O, --optimize runs optimization passes on the translated functions
--version print the Cranelift version
@@ -91,7 +94,7 @@ struct Args {
flag_g: bool,
flag_debug: bool,
flag_cache: bool, // TODO change to disable cache after implementing cache eviction
flag_cache_config_file: Option<String>,
flag_cache_config: Option<String>,
flag_create_cache_config: bool,
flag_enable_simd: bool,
flag_optimize: bool,
@@ -123,10 +126,25 @@ fn main() {
Some(prefix)
};
if args.flag_create_cache_config {
match cache_create_new_config(args.flag_cache_config) {
Ok(path) => {
println!(
"Successfully created new configuation file at {}",
path.display()
);
return;
}
Err(err) => {
eprintln!("Error: {}", err);
process::exit(1);
}
}
}
let errors = cache_init(
args.flag_cache || args.flag_cache_config_file.is_some(),
args.flag_cache_config_file.as_ref(),
args.flag_create_cache_config,
args.flag_cache || args.flag_cache_config.is_some(),
args.flag_cache_config.as_ref(),
log_config,
);

View File

@@ -45,7 +45,7 @@ use std::process::exit;
use wabt;
use wasi_common::preopen_dir;
use wasmtime_api::{Config, Engine, HostRef, Instance, Module, Store};
use wasmtime_environ::cache_init;
use wasmtime_environ::{cache_create_new_config, cache_init};
use wasmtime_interface_types::ModuleData;
use wasmtime_jit::Features;
use wasmtime_wasi::instantiate_wasi;
@@ -62,8 +62,9 @@ including calling the start function if one is present. Additional functions
given with --invoke are then called.
Usage:
wasmtime [-odg] [--enable-simd] [--wasi-c] [--cache | --cache-config=<cache_config_file>] [--create-cache-config] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] <file> [<arg>...]
wasmtime [-odg] [--enable-simd] [--wasi-c] [--cache | --cache-config=<cache_config_file>] [--create-cache-config] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] --invoke=<fn> <file> [<arg>...]
wasmtime [-odg] [--enable-simd] [--wasi-c] [--cache | --cache-config=<cache_config_file>] [--preload=<wasm>...] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] <file> [<arg>...]
wasmtime [-odg] [--enable-simd] [--wasi-c] [--cache | --cache-config=<cache_config_file>] [--env=<env>...] [--dir=<dir>...] [--mapdir=<mapping>...] --invoke=<fn> <file> [<arg>...]
wasmtime --create-cache-config [--cache-config=<cache_config_file>]
wasmtime --help | --version
Options:
@@ -71,10 +72,12 @@ Options:
-o, --optimize runs optimization passes on the translated functions
-c, --cache enable caching system, use default configuration
--cache-config=<cache_config_file>
enable caching system, use specified cache configuration
enable caching system, use specified cache configuration;
can be used with --create-cache-config to specify custom file
--create-cache-config
used with --cache or --cache-config, creates default configuration and writes it to the disk,
will fail if specified file already exists (or default file if used with --cache)
creates default configuration and writes it to the disk,
use with --cache-config to specify custom config file
instead of default one
-g generate debug information
-d, --debug enable debug output on stderr/stdout
--enable-simd enable proposed SIMD instructions
@@ -94,7 +97,7 @@ struct Args {
arg_arg: Vec<String>,
flag_optimize: bool,
flag_cache: bool, // TODO change to disable cache after implementing cache eviction
flag_cache_config_file: Option<String>,
flag_cache_config: Option<String>,
flag_create_cache_config: bool,
flag_debug: bool,
flag_g: bool,
@@ -222,10 +225,25 @@ fn rmain() -> Result<(), Error> {
Some(prefix)
};
if args.flag_create_cache_config {
match cache_create_new_config(args.flag_cache_config) {
Ok(path) => {
println!(
"Successfully created new configuation file at {}",
path.display()
);
return Ok(());
}
Err(err) => {
eprintln!("Error: {}", err);
exit(1);
}
}
}
let errors = cache_init(
args.flag_cache || args.flag_cache_config_file.is_some(),
args.flag_cache_config_file.as_ref(),
args.flag_create_cache_config,
args.flag_cache || args.flag_cache_config.is_some(),
args.flag_cache_config.as_ref(),
log_config,
);

View File

@@ -33,7 +33,7 @@ use pretty_env_logger;
use serde::Deserialize;
use std::path::Path;
use std::process;
use wasmtime_environ::cache_init;
use wasmtime_environ::{cache_create_new_config, cache_init};
use wasmtime_jit::{Compiler, Features};
use wasmtime_wast::WastContext;
@@ -41,7 +41,8 @@ const USAGE: &str = "
Wast test runner.
Usage:
wast [-do] [--enable-simd] [--cache | --cache-config=<cache_config_file>] [--create-cache-config] <file>...
wast [-do] [--enable-simd] [--cache | --cache-config=<cache_config_file>] <file>...
wast --create-cache-config [--cache-config=<cache_config_file>]
wast --help | --version
Options:
@@ -50,10 +51,12 @@ Options:
-o, --optimize runs optimization passes on the translated functions
-c, --cache enable caching system, use default configuration
--cache-config=<cache_config_file>
enable caching system, use specified cache configuration
enable caching system, use specified cache configuration;
can be used with --create-cache-config to specify custom file
--create-cache-config
used with --cache or --cache-config, creates default configuration and writes it to the disk,
will fail if specified file already exists (or default file if used with --cache)
creates default configuration and writes it to the disk,
use with --cache-config to specify custom config file
instead of default one
-d, --debug enable debug output on stderr/stdout
--enable-simd enable proposed SIMD instructions
";
@@ -65,7 +68,7 @@ struct Args {
flag_function: Option<String>,
flag_optimize: bool,
flag_cache: bool, // TODO change to disable cache after implementing cache eviction
flag_cache_config_file: Option<String>,
flag_cache_config: Option<String>,
flag_create_cache_config: bool,
flag_enable_simd: bool,
}
@@ -89,10 +92,25 @@ fn main() {
Some(prefix)
};
if args.flag_create_cache_config {
match cache_create_new_config(args.flag_cache_config) {
Ok(path) => {
println!(
"Successfully created new configuation file at {}",
path.display()
);
return;
}
Err(err) => {
eprintln!("Error: {}", err);
process::exit(1);
}
}
}
let errors = cache_init(
args.flag_cache || args.flag_cache_config_file.is_some(),
args.flag_cache_config_file.as_ref(),
args.flag_create_cache_config,
args.flag_cache || args.flag_cache_config.is_some(),
args.flag_cache_config.as_ref(),
log_config,
);