chore: Split auxiliary tools into separate crates

This commit is contained in:
Jonas Platte
2022-03-31 14:37:52 +02:00
committed by GitHub
15 changed files with 61 additions and 57 deletions

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@ target
master.zip
emsdk-*
.idea/
.vscode/

View File

@@ -1,4 +1,4 @@
[workspace]
members = ["crates/*", "xtask"]
# xtask should only be compiled when invoked explicitly
default-members = ["crates/*"]
members = ["benchmarks", "crates/*", "labs/*", "xtask"]
# xtask and labs should only be compiled when invoked explicitly
default-members = ["benchmarks", "crates/*"]

25
benchmarks/Cargo.toml Normal file
View File

@@ -0,0 +1,25 @@
[package]
name = "benchmarks"
description = "Matrix SDK benchmarks"
edition = "2021"
license = "Apache-2.0"
rust-version = "1.56"
version = "1.0.0"
publish = false
[dependencies]
criterion = { version = "0.3.4", features = ["async", "async_tokio", "html_reports"] }
matrix-sdk-crypto = { path = "../crates/matrix-sdk-crypto" }
matrix-sdk-sled = { path = "../crates/matrix-sdk-sled", default-features = false, features = ["crypto-store"] }
matrix-sdk-test = { path = "../crates/matrix-sdk-test" }
ruma = { git = "https://github.com/ruma/ruma", rev = "deea762b8" }
serde_json = "1.0.79"
tempfile = "3.2.0"
tokio = { version = "1.7.1", default-features = false, features = ["rt-multi-thread"] }
[target.'cfg(target_os = "linux")'.dependencies]
pprof = { version = "0.6.2", features = ["flamegraph", "criterion"] }
[[bench]]
name = "crypto_bench"
harness = false

View File

@@ -26,7 +26,7 @@ fn alice_device_id() -> &'static DeviceId {
}
fn keys_query_response() -> get_keys::v3::Response {
let data = include_bytes!("./keys_query.json");
let data = include_bytes!("crypto_bench/keys_query.json");
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
get_keys::v3::Response::try_from_http_response(data)
@@ -34,7 +34,7 @@ fn keys_query_response() -> get_keys::v3::Response {
}
fn keys_claim_response() -> claim_keys::v3::Response {
let data = include_bytes!("./keys_claim.json");
let data = include_bytes!("crypto_bench/keys_claim.json");
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
claim_keys::v3::Response::try_from_http_response(data)
@@ -42,7 +42,7 @@ fn keys_claim_response() -> claim_keys::v3::Response {
}
fn huge_keys_query_response() -> get_keys::v3::Response {
let data = include_bytes!("./keys_query_2000_members.json");
let data = include_bytes!("crypto_bench/keys_query_2000_members.json");
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
get_keys::v3::Response::try_from_http_response(data)

View File

@@ -72,26 +72,6 @@ http = "0.2.4"
indoc = "1.0.3"
matches = "0.1.8"
matrix-sdk-test = { version = "0.4.0", path = "../matrix-sdk-test" }
# This is needed for the benchmarks
matrix-sdk-sled = { version = "0.1.0", path = "../matrix-sdk-sled", default-features = false, features = ["crypto-store"] }
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
criterion = { version = "0.3.4", features = [
"async",
"async_tokio",
"html_reports",
] }
proptest = "1.0.0"
tempfile = "3.2.0"
tokio = { version = "1.7.1", default-features = false, features = [
"rt-multi-thread",
"macros",
] }
[target.'cfg(target_os = "linux")'.dev-dependencies]
pprof = { version = "0.6.2", features = ["flamegraph", "criterion"] }
[[bench]]
name = "crypto_bench"
harness = false
# required for async_test macro
tokio = { version = "1.7.1", default-features = false, features = ["macros", "rt-multi-thread"] }

View File

@@ -610,7 +610,7 @@ mod test {
}
fn keys_query_response() -> get_keys::v3::Response {
let data = include_bytes!("../../benches/keys_query.json");
let data = include_bytes!("../../../../benchmarks/benches/crypto_bench/keys_query.json");
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
get_keys::v3::Response::try_from_http_response(data)
@@ -618,7 +618,7 @@ mod test {
}
fn keys_claim_response() -> claim_keys::v3::Response {
let data = include_bytes!("../../benches/keys_claim.json");
let data = include_bytes!("../../../../benchmarks/benches/crypto_bench/keys_claim.json");
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
claim_keys::v3::Response::try_from_http_response(data)

View File

@@ -3,24 +3,11 @@ name = "matrix-sdk-sled"
version = "0.1.0"
edition = "2021"
[[bin]]
name = "state-inspector"
path = "bin/state_inspector.rs"
required-features = ["binary-build"]
[features]
default = ["state-store", "crypto-store"]
state-store = ["matrix-sdk-base"]
crypto-store = ["matrix-sdk-crypto"]
binary-build = [
"atty",
"clap",
"futures",
"rustyline",
"rustyline-derive",
"syntect",
]
[dependencies]
futures-core = "0.3.15"
@@ -39,14 +26,6 @@ tracing = "0.1.26"
anyhow = "1"
dashmap = "5.1.0"
# binary-build only
atty = { version = "0.2.14", optional = true }
clap = { version = "3.1.0", optional = true }
futures = { version = "0.3.15", default-features = false, features = ["executor"], optional = true }
rustyline = { version = "9.0.0", optional = true }
rustyline-derive = { version = "0.6.0", optional = true }
syntect = { version = "4.5.0", optional = true }
[dev-dependencies]
lazy_static = "1.4"
tempfile = "3.2.0"

View File

@@ -0,0 +1,17 @@
[package]
name = "sled-state-inspector"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
atty = "0.2.14"
clap = "3.1.0"
futures = { version = "0.3.15", default-features = false, features = ["executor"] }
matrix-sdk-base = { path = "../../crates/matrix-sdk-base" }
matrix-sdk-sled = { path = "../../crates/matrix-sdk-sled" }
rustyline = "9.0.0"
rustyline-derive = "0.6.0"
serde = "1.0.136"
serde_json = "1.0.79"
syntect = "4.5.0"

View File

@@ -3,8 +3,10 @@ use std::{convert::TryFrom, fmt::Debug, sync::Arc};
use atty::Stream;
use clap::{Arg, ArgMatches, Command as Argparse};
use futures::executor::block_on;
use matrix_sdk_base::{RoomInfo, Store};
use matrix_sdk_common::ruma::{events::StateEventType, RoomId, UserId};
use matrix_sdk_base::{
ruma::{events::StateEventType, RoomId, UserId},
RoomInfo, Store,
};
use matrix_sdk_sled::StateStore;
use rustyline::{
completion::{Completer, Pair},
@@ -66,7 +68,7 @@ impl InspectorHelper {
fn complete_event_types(&self, arg: Option<&&str>) -> Vec<Pair> {
Self::EVENT_TYPES
.iter()
.map(|t| Pair { display: t.to_string(), replacement: format!("{} ", t) })
.map(|&t| Pair { display: t.to_owned(), replacement: format!("{} ", t) })
.filter(|r| if let Some(arg) = arg { r.replacement.starts_with(arg) } else { true })
.collect()
}
@@ -161,8 +163,8 @@ struct Printer {
impl Printer {
fn new(json: bool, color: bool) -> Self {
let syntax_set: SyntaxSet = from_binary(include_bytes!("./syntaxes.bin"));
let themes: ThemeSet = from_binary(include_bytes!("./themes.bin"));
let syntax_set: SyntaxSet = from_binary(include_bytes!("../syntaxes.bin"));
let themes: ThemeSet = from_binary(include_bytes!("../themes.bin"));
Self { ps: syntax_set.into(), ts: themes.into(), json, color }
}
@@ -223,7 +225,7 @@ impl Inspector {
Some(("list-rooms", _)) => self.list_rooms().await,
Some(("get-display-names", args)) => {
let room_id = RoomId::parse(args.value_of("room-id").unwrap()).unwrap();
let display_name = args.value_of("display-name").unwrap().to_string();
let display_name = args.value_of("display-name").unwrap().to_owned();
self.get_display_name_owners(room_id, display_name).await;
}
Some(("get-state", args)) => {