Skip to content

refactor network stack, optimize performance, and add graceful shutdown#25

Merged
SpikeHD merged 11 commits intoSpikeHD:mainfrom
vMohammad24:optimizations
May 3, 2026
Merged

refactor network stack, optimize performance, and add graceful shutdown#25
SpikeHD merged 11 commits intoSpikeHD:mainfrom
vMohammad24:optimizations

Conversation

@vMohammad24
Copy link
Copy Markdown
Contributor

General:

added nix flake (dev env)
optimized release profile
updated dependencies
implemented graceful shutdown

CLI

replaced reqwest (blocking) with ureq (reqwest is "fake" blocking aka it creates a tokio thread in the background, ureq is light-weight and actual blocking)

lib

refactored DetectableActivityto use Arc (preventing useless clones)
optimized aho-corasick pattern matching
reduced Mutex locks
added logic to detect stale sockets and prune them
removed sysinfo from linux builds

refactors

ipc: improved unix socket handling for automatic cleanups
logging: used an atomic bool to prevent overhead (reading env var on every func call)
cleaned up useless allocations in url_params, simplified ipc packet

performance/conclusion

memory: went from idling 150MB to 60MB
binary size: went from 5.1mb to 3mb

@SpikeHD
Copy link
Copy Markdown
Owner

SpikeHD commented May 2, 2026

Nice! Do you mind splitting this into separate PRs though? It's much easier to review stuff in isolation that way.

@vMohammad24
Copy link
Copy Markdown
Contributor Author

i tried my best splitting them into 8 commits that you could review individually, if that's no hassle.

this PR didn't have much of a goal other than general optimizations so I didn't think of splitting it into multiple PRs (especially since most of the newer commits depend on the older ones).

although let me know if you still need me to split them (cant do them very soon tho cuz i have exams)

@SpikeHD
Copy link
Copy Markdown
Owner

SpikeHD commented May 2, 2026

Oh actually yea that's good enough, ty, I only originally looked at the changes tab

Copy link
Copy Markdown
Owner

@SpikeHD SpikeHD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just curious about the nix-related stuff

Comment thread flake.nix
@@ -0,0 +1,34 @@
{
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk anything abt nix (nor do I use it), do I need to do any maintenance/keep flake.lock up-to-date or anything?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a dev env (users cant install with it (i can add that if you'd like)) but no it does not require any maintenance

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can also remove it if you'd like

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok perfect, its totally fine to keep i just dont know anything about nix 🤪

@SpikeHD
Copy link
Copy Markdown
Owner

SpikeHD commented May 2, 2026

Idk if the clippy errors are related to your changes but if they are could you pls fix them? If not I'll get to them eventually ™️

@vMohammad24
Copy link
Copy Markdown
Contributor Author

yeah sorry they were from the last commit, fixed them.

@SpikeHD
Copy link
Copy Markdown
Owner

SpikeHD commented May 3, 2026

thanks!

@SpikeHD SpikeHD merged commit badb3ee into SpikeHD:main May 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants