Flatten perf improvements: gzip response and parallelize sorting
This commit is contained in:
parent
4112c7d79d
commit
d492afc885
4 changed files with 21 additions and 3 deletions
15
Cargo.lock
generated
15
Cargo.lock
generated
|
@ -65,6 +65,19 @@ version = "0.7.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
|
||||
|
||||
[[package]]
|
||||
name = "async-compression"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fec134f64e2bc57411226dfc4e52dec859ddfc7e711fc5e07b612584f000e4aa"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"futures-core",
|
||||
"memchr",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.81"
|
||||
|
@ -2789,8 +2802,10 @@ version = "0.5.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5"
|
||||
dependencies = [
|
||||
"async-compression",
|
||||
"bitflags 2.6.0",
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"http 1.1.0",
|
||||
"http-body",
|
||||
|
|
|
@ -42,7 +42,7 @@ thiserror = "1.0.62"
|
|||
tokio = { version = "1.39", features = ["macros", "rt-multi-thread"] }
|
||||
tokio-util = { version = "0.7.11", features = ["io"] }
|
||||
toml = "0.8.19"
|
||||
tower-http = { version = "0.5.2", features = ["fs"] }
|
||||
tower-http = { version = "0.5.2", features = ["compression-gzip", "fs"] }
|
||||
trie-rs = { version = "0.4.2", features = ["serde"] }
|
||||
unicase = "2.7.0"
|
||||
ureq = { version = "2.10.0", default-features = false, features = ["tls"] }
|
||||
|
|
|
@ -7,6 +7,7 @@ use std::{
|
|||
};
|
||||
|
||||
use lasso2::{Rodeo, RodeoReader};
|
||||
use rayon::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tinyvec::TinyVec;
|
||||
use trie_rs::{Trie, TrieBuilder};
|
||||
|
@ -112,7 +113,7 @@ impl Browser {
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
files.sort_by(|a, b| {
|
||||
files.par_sort_by(|a, b| {
|
||||
let a = UniCase::new(a.as_os_str().to_string_lossy());
|
||||
let b = UniCase::new(b.as_os_str().to_string_lossy());
|
||||
a.cmp(&b)
|
||||
|
|
|
@ -11,6 +11,7 @@ use axum_extra::TypedHeader;
|
|||
use axum_range::{KnownSize, Ranged};
|
||||
use base64::{prelude::BASE64_STANDARD_NO_PAD, Engine};
|
||||
use percent_encoding::percent_decode_str;
|
||||
use tower_http::{compression::CompressionLayer, CompressionLevel};
|
||||
|
||||
use crate::{
|
||||
app::{config, ddns, index, lastfm, playlist, scanner, settings, thumbnail, user, vfs, App},
|
||||
|
@ -56,7 +57,6 @@ pub fn router() -> Router<App> {
|
|||
.route("/playlist/:name", put(put_playlist))
|
||||
.route("/playlist/:name", get(get_playlist))
|
||||
.route("/playlist/:name", delete(delete_playlist))
|
||||
.route("/audio/*path", get(get_audio))
|
||||
.route("/thumbnail/*path", get(get_thumbnail))
|
||||
.route("/lastfm/now_playing/*path", put(put_lastfm_now_playing))
|
||||
.route("/lastfm/scrobble/*path", post(post_lastfm_scrobble))
|
||||
|
@ -70,7 +70,9 @@ pub fn router() -> Router<App> {
|
|||
.route("/random/", get(get_random))
|
||||
.route("/recent/", get(get_recent))
|
||||
.route("/search/", get(get_search_root))
|
||||
.layer(CompressionLayer::new().quality(CompressionLevel::Fastest))
|
||||
.layer(DefaultBodyLimit::max(10 * 1024 * 1024)) // 10MB
|
||||
.route("/audio/*path", get(get_audio))
|
||||
}
|
||||
|
||||
async fn get_version() -> Json<dto::Version> {
|
||||
|
|
Loading…
Add table
Reference in a new issue