Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
tazz4843 committed Nov 27, 2024
2 parents 4b402a0 + 6d9cab9 commit b855be9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 107 deletions.
34 changes: 0 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 22 additions & 25 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,34 @@ debug = true

[workspace]
members = [
"scripty_config",
"scripty_webserver",
"scripty_core",
"scripty_premium",
"scripty_stt",
"scripty_audio_handler",
"scripty_commands",
"scripty_i18n",
"scripty_db",
"scripty_metrics",
"scripty_utils",
"scripty_data_storage",
"scripty_redis",
"scripty_bot",
"scripty_bot_utils",
"scripty_automod",
"scripty_botlists",
"scripty_error",
"scripty_tts",
"scripty_integrations",
"scripty_build_checks",
"scripty_data_type",
"scripty_config",
"scripty_webserver",
"scripty_core",
"scripty_premium",
"scripty_stt",
"scripty_audio_handler",
"scripty_commands",
"scripty_i18n",
"scripty_db",
"scripty_metrics",
"scripty_utils",
"scripty_data_storage",
"scripty_redis",
"scripty_bot",
"scripty_bot_utils",
"scripty_automod",
"scripty_botlists",
"scripty_error",
"scripty_tts",
"scripty_integrations",
"scripty_build_checks",
"scripty_data_type",
]

[dependencies]
scripty_core = { path = "scripty_core" }
scripty_build_checks = { path = "scripty_build_checks" }

[target.'cfg(target_arch = "x86_64")'.dependencies]
tikv-jemallocator = "0.5"

[patch.crates-io]
serenity = { git = "https://github.com/serenity-rs/serenity", branch = "next" }
songbird = { git = "https://github.com/serenity-rs/songbird", branch = "serenity-next" }
Expand Down
1 change: 1 addition & 0 deletions scripty_audio_handler/src/events/speaking_state_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub async fn speaking_state_update(
debug!(%ssrc, "updated data");
}

debug!(%ssrc, %user_id, "adding ssrc-userID mapping");
if let Some(old_user_id) = ssrc_state
.ssrc_user_id_map
.insert(state_update.ssrc, user_id)
Expand Down
2 changes: 1 addition & 1 deletion scripty_bot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub async fn entrypoint() {

let mut client =
ClientBuilder::new_with_http(token, Arc::new(http), framework_opts::get_gateway_intents())
.compression(TransportCompression::Zstd)
.compression(TransportCompression::None)
.data(data.clone())
.framework(framework)
.voice_manager::<scripty_audio_handler::Songbird>(songbird)
Expand Down
3 changes: 0 additions & 3 deletions scripty_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ license = "EUPL-1.2"

[dependencies]
url = "2"
libc = "0.2"
rlimit = "0.10"
num_cpus = "1"
humantime = "2"
Expand All @@ -26,5 +25,3 @@ tokio = { version = "1", features = ["parking_lot", "rt-multi-thread"] }
scripty_data_storage = { path = "../scripty_data_storage" }
fenrir-rs = { git = "https://github.com/tazz4843/fenrir-rs", branch = "json-logs", features = ["reqwest-async", "json-log-fmt"] }

[target.'cfg(target_arch = "x86_64")'.dependencies]
tikv-jemalloc-ctl = "0.5"
44 changes: 0 additions & 44 deletions scripty_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,11 @@ use fern::{
Dispatch,
};
use rlimit::Resource;
#[cfg(target_arch = "x86_64")]
use tikv_jemalloc_ctl::{epoch, stats};
use url::Url;

pub fn start() {
load_config();

#[cfg(target_arch = "x86_64")]
spawn_malloc_trim();

let rt = get_tokio_rt();

rt.block_on(init_logging());
Expand Down Expand Up @@ -179,42 +174,3 @@ fn increase_open_file_limit() {
rlimit::setrlimit(Resource::NOFILE, 8192, 8192)
.expect("failed to increase open file limit: will likely cause issues with STT service");
}

#[cfg(target_arch = "x86_64")]
fn spawn_malloc_trim() {
std::thread::spawn(|| {
let emib = epoch::mib().expect("failed to get epoch mib");
let active = stats::active::mib().expect("failed to get active mib");
let allocated = stats::allocated::mib().expect("failed to get allocated mib");
let mapped = stats::mapped::mib().expect("failed to get mapped mib");
let metadata = stats::metadata::mib().expect("failed to get metadata mib");
let resident = stats::resident::mib().expect("failed to get resident mib");
let retained = stats::retained::mib().expect("failed to get retained mib");

let log_mem_info = || {
emib.advance().expect("failed to advance epoch");
debug!(
"running malloc_trim, {} bytes allocated",
allocated.read().unwrap()
);
trace!(
"detailed mem info: active: {} bytes, allocated: {} bytes, mapped: {} bytes, \
metadata: {} bytes, resident: {} bytes, retained: {} bytes",
active.read().unwrap(),
allocated.read().unwrap(),
mapped.read().unwrap(),
metadata.read().unwrap(),
resident.read().unwrap(),
retained.read().unwrap()
);
};

loop {
std::thread::sleep(std::time::Duration::from_secs(300));

log_mem_info();
unsafe { libc::malloc_trim(0) };
log_mem_info();
}
});
}

0 comments on commit b855be9

Please sign in to comment.