From 12635886f9712cb6701e5287bdd5f192ec7fc210 Mon Sep 17 00:00:00 2001 From: "Dawid J. Kubis" Date: Thu, 25 May 2023 21:30:46 +0200 Subject: [PATCH] attempting to improve thread performance --- Cargo.lock | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 3 +++ 3 files changed, 71 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 6456f73..674cb57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -101,6 +101,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fs2" version = "0.4.3" @@ -156,6 +165,16 @@ dependencies = [ "utf8-width", ] +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "instant" version = "0.1.12" @@ -187,6 +206,7 @@ dependencies = [ "structopt", "thiserror", "threadpool", + "url", "urlencoding", ] @@ -274,6 +294,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -512,12 +538,42 @@ dependencies = [ "time-core", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + [[package]] name = "unicode-ident" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.10.1" @@ -530,6 +586,17 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "urlencoding" version = "2.1.2" diff --git a/Cargo.toml b/Cargo.toml index b484b9f..8de4b8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ simplelog = "0.12.1" html-escape = "0.2.13" urlencoding = "2.1.2" byteorder = "1.4.3" +url = "2.3.1" #ctrlc = "3.3.1" #image = "0.24.6" diff --git a/src/main.rs b/src/main.rs index d4af90b..208a569 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,6 +54,9 @@ struct State { // cache here? } +unsafe impl Send for State {} +unsafe impl Sync for State {} + impl State { fn new(db_name: impl AsRef) -> Self { let mut s = Self {