Improve memory performance for txt chat download #757
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WHY
My use case includes running this cli to download twitch chats, in a constraint environment (e.g, Rapsberri Pi).
The tool is great, but for large streams (with a lot of messages) the memory footprint can be big.
for instance for:
https://www.twitch.tv/videos/1857424785
The tool takes around 510 mbs of memory (see images).
I was looking at the code, and I found out some points in which we could optimize.
For instance, emotes, and Badges information are not used for txt files.
And creating these instances takes a lot of memory.
With the proposed changes I was able to reduce the memory usage significantly, to around: 360mbs for that particular case.
I also added a quiet mode (-q) option to the CLI, since some users might not be interested in keeping track of the progress (for instance my case, were the process is automated and I'm not looking at the progress), and this also lowers the memory consumption.
Improve memory performance.
HOW
-q
).int
array to be allocated in the stack and initialized at 0.List
ofComment
s objects, and made the comments unification and sorting after all tasks are finished to avoid concurrency issues,Note:
Hi this is my first attempt to contribute to this project, so I'm sorry if I overlooked something.