Review Memory Usage > Consider DB Implementation #63

Open
opened 2024-04-05 12:12:29 -04:00 by modulatingforce · 0 comments

I'm finding it fascinating that with rust, having to explicitly define static objects with Arc<RwLock<T>> , I can almost feel the weight of it in memory as there are more instances that are created this way. Specifically, I can see that since I've started adopting a lot of these static elements, I can see Raw that these records are making the bot take more and more memory .

  • At the moment, the bot starts out with 17-20 mb of memory . After about a 24 hour period, it was near 90mb 😓 , but fluctuates

Better may be to perhaps use a DB implementation & caching so the bot only stores in memory a subset of objects at a time . There could also be other optimizations to explore

For example, at the moment, I have Arc<RwLock<RateLimiter>> for each channel the bot is connected to , but the RateLimiter for inactive or low activity channels would not really need that RateLimier sitting in memory


Might hold this off until core parts of the bot are coded - but going to keep the above in mind moving forward for new objects

I'm finding it fascinating that with rust, having to explicitly define static objects with `Arc<RwLock<T>>` , I can almost feel the weight of it in memory as there are more instances that are created this way. Specifically, I can see that since I've started adopting a lot of these static elements, I can see Raw that these records are making the bot take more and more memory . - At the moment, the bot starts out with 17-20 mb of memory . After about a 24 hour period, it was near 90mb 😓 , but fluctuates Better may be to perhaps use a DB implementation & caching so the bot only stores in memory a subset of objects at a time . There could also be other optimizations to explore For example, at the moment, I have `Arc<RwLock<RateLimiter>>` for each channel the bot is connected to , but the `RateLimiter` for inactive or low activity channels would not really need that RateLimier sitting in memory --- Might hold this off until core parts of the bot are coded - but going to keep the above in mind moving forward for new objects
modulatingforce self-assigned this 2024-04-05 12:12:29 -04:00
modulatingforce added this to the Rust Learning project 2024-04-05 12:12:29 -04:00
modulatingforce added the
Status
Blocked
label 2024-04-05 12:13:44 -04:00
modulatingforce added
Complexity
Expert
and removed
Complexity
Advanced
labels 2024-04-09 13:07:03 -04:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: modulatingforce/forcebot_rs#63
No description provided.