Skip to content

Commit 91cebeb

Browse files
committed
Reduce memory usage by dropping more cache fields
1 parent f02f44d commit 91cebeb

13 files changed

Lines changed: 200 additions & 163 deletions

File tree

Cargo.lock

Lines changed: 159 additions & 144 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
11
{
22

33
inputs = {
4-
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
4+
nixpkgs-unpatched.url = "github:NixOS/nixpkgs/nixos-unstable-small";
55
flake-utils.url = "github:numtide/flake-utils";
66

77
tts-utils.url = "github:Discord-TTS/shared-workflows";
88
};
99

1010
outputs =
1111
{
12-
nixpkgs,
12+
nixpkgs-unpatched,
1313
flake-utils,
1414
tts-utils,
1515
...
1616
}:
1717
flake-utils.lib.eachDefaultSystem (
1818
system:
1919
let
20-
pkgs = import nixpkgs { inherit system; };
20+
pkgsUnpatched = import nixpkgs-unpatched { inherit system; };
21+
nixpkgs = pkgsUnpatched.applyPatches {
22+
name = "nixpkgs-patched";
23+
src = nixpkgs-unpatched;
24+
patches = [
25+
# Bumps Rust to 1.94.1
26+
(pkgsUnpatched.fetchpatch2 {
27+
url = "https://github.com/NixOS/nixpkgs/pull/503830.patch";
28+
hash = "sha256-wCC+IJqZJTxyteNV//+M/+31xh+Pns0tQ/qgDkSOQaQ=";
29+
})
30+
# Bumps Rust to 1.95
31+
(pkgsUnpatched.fetchpatch2 {
32+
url = "https://github.com/NixOS/nixpkgs/pull/510674.patch";
33+
hash = "sha256-7s7lcdifXJd31XTECFoPwrZE3UrUiMn9dHSHPXHn4dc=";
34+
})
35+
];
36+
};
2137

38+
pkgs = import nixpkgs { inherit system; };
2239
pkgDesc = (pkgs.lib.importTOML ./Cargo.toml).package;
2340
botPkg = pkgs.rustPlatform.buildRustPackage {
2441
pname = pkgDesc.name;
@@ -29,8 +46,8 @@
2946
cargoLock = {
3047
lockFile = ./Cargo.lock;
3148
outputHashes = {
32-
"poise-0.6.1" = "sha256-qCTEkOWCpKgEXCt7apg+tiScE+X0Br0giTNNBxqNCs0=";
33-
"serenity-0.12.5" = "sha256-xlBuX0qdTclrKaZkAwK3kXZdurxFT3UVYC7Eh/f+emA=";
49+
"poise-0.6.1" = "sha256-6NU1UOQUz8WO77Luv7VLp/RL1May65Y7JmMWxaPbgvo=";
50+
"serenity-0.12.5" = "sha256-lyleiOtGDFH5zuHu3z4pUEE5lyyJZvZQkzH3pwu2XGA=";
3451
};
3552
};
3653

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async fn main_(start_time: std::time::SystemTime) -> Result<()> {
126126
voice_connections: parking_lot::Mutex::default(),
127127
update_startup_lock: tokio::sync::Mutex::new(()),
128128
entitlement_cache: mini_moka::sync::Cache::builder()
129-
.time_to_live(Duration::from_secs(60 * 60))
129+
.time_to_live(Duration::from_hours(1))
130130
.build(),
131131

132132
gtts_voices,

tts_commands/src/other.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub async fn botstats(ctx: Context<'_>) -> CommandResult {
209209
.to_arraystring(),
210210
guilds
211211
.into_iter()
212-
.map(|g| g.member_count)
212+
.map(|g| u64::from(g.member_count.get()))
213213
.sum::<u64>()
214214
.to_formatted_string(&Locale::en),
215215
)

tts_commands/src/owner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ pub async fn guild_info(ctx: Context<'_>, guild_id: Option<serenity::GuildId>) -
481481
let response = ctx
482482
.channel_id()
483483
.collect_component_interactions(ctx.serenity_context())
484-
.timeout(Duration::from_secs(60 * 5))
484+
.timeout(Duration::from_mins(5))
485485
.author_id(ctx.author().id)
486486
.custom_ids(custom_ids)
487487
.await;

tts_commands/src/settings/setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ async fn show_channel_select_menu(
108108
let interaction = reply_message
109109
.id
110110
.collect_component_interactions(ctx.serenity_context())
111-
.timeout(std::time::Duration::from_secs(60 * 5))
111+
.timeout(std::time::Duration::from_mins(5))
112112
.author_id(ctx.author().id)
113113
.await;
114114

tts_commands/src/settings/voice_paginator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<'a> MenuPaginator<'a> {
9797
loop {
9898
let builder = message_id
9999
.collect_component_interactions(serenity_context)
100-
.timeout(std::time::Duration::from_secs(60 * 5))
100+
.timeout(std::time::Duration::from_mins(5))
101101
.author_id(self.ctx.author().id);
102102

103103
let Some(interaction) = builder.await else {

tts_core/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub async fn confirm_dialog_wait(
182182
) -> Result<Option<bool>> {
183183
let interaction = message_id
184184
.collect_component_interactions(ctx)
185-
.timeout(std::time::Duration::from_secs(60 * 5))
185+
.timeout(std::time::Duration::from_mins(5))
186186
.author_id(author_id)
187187
.await;
188188

tts_core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![expect(async_fn_in_trait)]
2-
#![feature(if_let_guard, type_alias_impl_trait)]
2+
#![feature(type_alias_impl_trait)]
33

44
pub mod analytics;
55
pub mod common;

0 commit comments

Comments
 (0)