[GH-ISSUE #293] Circular / Ring Buffer for Text Widget #146

Open
opened 2026-03-03 16:22:51 +03:00 by kerem · 3 comments
Owner

Originally created by @timbutler on GitHub (Feb 12, 2021).
Original GitHub issue: https://github.com/mum4k/termdash/issues/293

Originally assigned to: @timbutler on GitHub.

I've started using this for a quick internal project, with one of features being log files monitored and displayed in real-time while other stats are displayed.

While this is working, one issue we've of course hit is when verbose logs are monitored that the size of the text buffer keeps increasing and of course leads to high memory usage and performance degradation.

A possible fix to this is to implement a simple ring buffer, where the Text content has an (optional) maximum it can grow to. During the Write call it could then pop content off the top of the buffer as required so that it never grows further than the maximum content.

I've added this as a basic proof of concept internally, but wanted to confirm if this would be the best approach (or if I'm missing something obvious!) before submitting any pull request.

Originally created by @timbutler on GitHub (Feb 12, 2021). Original GitHub issue: https://github.com/mum4k/termdash/issues/293 Originally assigned to: @timbutler on GitHub. I've started using this for a quick internal project, with one of features being log files monitored and displayed in real-time while other stats are displayed. While this is working, one issue we've of course hit is when verbose logs are monitored that the size of the text buffer keeps increasing and of course leads to high memory usage and performance degradation. A possible fix to this is to implement a simple ring buffer, where the Text `content` has an (optional) maximum it can grow to. During the `Write` call it could then pop content off the top of the buffer as required so that it never grows further than the maximum content. I've added this as a basic proof of concept internally, but wanted to confirm if this would be the best approach (or if I'm missing something obvious!) before submitting any pull request.
Author
Owner

@mum4k commented on GitHub (Feb 12, 2021):

Hi @timbutler, you raise a good point about the memory usage when the content of the Text widget just grows.

Adding an optional circular buffer sounds like a great idea. Such PR would be a great addition to the Text widget, if you're willing to submit it. Please see CONTRIBUTING.md for additional instructions (e.g. which branch to fork from).

Don't hesitate to let me know if you have any questions or would like to discuss the API change upfront.

<!-- gh-comment-id:777987356 --> @mum4k commented on GitHub (Feb 12, 2021): Hi @timbutler, you raise a good point about the memory usage when the `content` of the `Text` widget just grows. Adding an optional circular buffer sounds like a great idea. Such PR would be a great addition to the `Text` widget, if you're willing to submit it. Please see [CONTRIBUTING.md](https://github.com/mum4k/termdash/blob/master/CONTRIBUTING.md) for additional instructions (e.g. which branch to fork from). Don't hesitate to let me know if you have any questions or would like to discuss the API change upfront.
Author
Owner

@timbutler commented on GitHub (Feb 12, 2021):

Thanks for the rapid feedback @mum4k! I'll tidy my quick edits and submit a PR in the next few days for further feedback.

<!-- gh-comment-id:777991776 --> @timbutler commented on GitHub (Feb 12, 2021): Thanks for the rapid feedback @mum4k! I'll tidy my quick edits and submit a PR in the next few days for further feedback.
Author
Owner

@mum4k commented on GitHub (Feb 12, 2021):

Sounds great, looking forward to it @timbutler.

<!-- gh-comment-id:778030867 --> @mum4k commented on GitHub (Feb 12, 2021): Sounds great, looking forward to it @timbutler.
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
starred/termdash#146
No description provided.