teip
teip copied to clipboard
-e option allocates memory aggressively
See https://github.com/greymd/teip/wiki/Memory-Usage-Benchmark
-e
requires approx 3 times as much memory as the standard input.
It can be reduced more.
Let me note my brief idea.
One of the reasons why it allocates large mount of memory is standard input is taken "hard copy" in _tee_thread
.
https://github.com/greymd/teip/blob/v2.0.0/src/main.rs#L294-L349
Instead of hard copy of text, the text can be possessed in a linked list or a ring buffer.
If so, _tee_thread
will not need to pass text through channel, instead, pass the index numbers of buffer.
Then, Main thread
and _ex_thread
may have to refer to the shared mutex object which indicates the latest index. All the data stored on the indexes smaller than the latest one would be released then.
Put help wante
label.
Currently, I do not have enough resources to address this issue.
Any PRs are welcome.