From 3cbd0d5e228d0cacb81578e42df1e8345c6be681 Mon Sep 17 00:00:00 2001 From: Yoo1tic <137816438+Yoo1tic@users.noreply.github.com> Date: Mon, 28 Jul 2025 15:59:05 +0800 Subject: [PATCH] feat: add mimalloc dependency and update memory allocator; remove unused ASCII art --- Cargo.lock | 22 +++++++++++++++++++++- Cargo.toml | 1 + src/config/basic_config.rs | 17 ----------------- src/config/mod.rs | 2 +- src/lib.rs | 18 ++++++++++++++---- src/main.rs | 18 +++++++++++++----- 6 files changed, 50 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3550179..508b4b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -393,6 +393,7 @@ dependencies = [ "clap", "figment", "futures", + "mimalloc", "regex", "reqwest", "serde", @@ -757,6 +758,16 @@ version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +[[package]] +name = "libmimalloc-sys" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88cd67e9de251c1781dbe2f641a1a3ad66eaae831b8a2c38fbdc5ddae16d4d" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "litemap" version = "0.8.0" @@ -781,6 +792,15 @@ version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +[[package]] +name = "mimalloc" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1791cbe101e95af5764f06f20f6760521f7158f69dbf9d6baf941ee1bf6bc40" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "miniz_oxide" version = "0.8.9" @@ -955,7 +975,7 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e36baa0..9585149 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2024" [dependencies] +mimalloc = { version = "*" } anyhow = "1.0" backon = "1" clap = { version = "4.5", features = ["derive"] } diff --git a/src/config/basic_config.rs b/src/config/basic_config.rs index 533b6b0..ea344ae 100644 --- a/src/config/basic_config.rs +++ b/src/config/basic_config.rs @@ -167,24 +167,7 @@ pub static TEST_MESSAGE_BODY: LazyLock = LazyLock::new(|| { }) }); -// ASCII art for Gemini -pub const GEMINI_ASCII: &str = r#" - ______ _ _ - / ____/___ ____ ___ (_)____ (_) - / / __ / _ \ / __ `__ \ / // __ \ / / -/ /_/ // __// / / / / // // / / // / -\____/ \___//_/ /_/ /_//_//_/ /_//_/ -"#; -// LazyLock for the application banner -pub static BANNER: LazyLock = LazyLock::new(|| { - format!( - "{}\n{}\nKey Checker - Configuration Status\n{}", - GEMINI_ASCII, - "=".repeat(42), - "=".repeat(42) - ) -}); fn default_api_host() -> Url { DEFAULT_CONFIG.api_host.clone() diff --git a/src/config/mod.rs b/src/config/mod.rs index 2bfe070..688680a 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -2,4 +2,4 @@ mod basic_client; mod basic_config; pub use basic_client::client_builder; -pub use basic_config::{BANNER, KeyCheckerConfig, TEST_MESSAGE_BODY}; +pub use basic_config::{KeyCheckerConfig, TEST_MESSAGE_BODY}; diff --git a/src/lib.rs b/src/lib.rs index 2dcabb5..e987dfc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,15 @@ -pub mod config; -pub mod types; -pub mod key_validator; pub mod adapters; -pub mod validation; \ No newline at end of file +pub mod config; +pub mod key_validator; +pub mod types; +pub mod validation; + +// ASCII art for Gemini +pub const BANNER: &str = r#" + ______ _ _ + / ____/___ ____ ___ (_)____ (_) + / / __ / _ \ / __ `__ \ / // __ \ / / +/ /_/ // __// / / / / // // / / // / +\____/ \___//_/ /_/ /_//_//_/ /_//_/ +"#; + diff --git a/src/main.rs b/src/main.rs index ac0a9e5..f17cad8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,15 @@ use anyhow::Result; -use gemini_keychecker::adapters::load_keys; -use gemini_keychecker::config::{BANNER, KeyCheckerConfig, client_builder}; -use gemini_keychecker::validation::ValidationService; +use gemini_keychecker::{ + BANNER, + adapters::load_keys, + config::{KeyCheckerConfig, client_builder}, + validation::ValidationService, +}; + +use mimalloc::MiMalloc; + +#[global_allocator] +static GLOBAL: MiMalloc = MiMalloc; /// Main function - orchestrates the key validation process #[tokio::main] @@ -9,8 +17,8 @@ async fn main() -> Result<()> { let config = KeyCheckerConfig::load_config().unwrap(); // Display banner and configuration status at startup - println!("{}", *BANNER); - println!("{}", config); + println!("{BANNER}"); + println!("{config}"); let keys = load_keys(config.input_path.as_path())?; let client = client_builder(&config)?;