tokio-rs / console-gsoc

Google Summer of Code tokio-console prototype
MIT License
12 stars 2 forks source link

Investigate resource consumption #22

Open matprec opened 5 years ago

matprec commented 5 years ago

On windows, the memory usage in the underlying console subsystem grows unproportionally fast, ~3.5-4Mb per second, while the console itself stays within 0.1-0.2% of the usage.

grafik

hawkw commented 5 years ago

I can see if I can reproduce this on macOS or not — I bet it would be helpful to know if this is a Windows-specific issue?

matprec commented 5 years ago

That would be extremely useful! Though i'll get back to this in a few weeks, this is not urgent atm

matprec commented 5 years ago

This does not happen with wsl

This indicates that cmd/powershell themself have internal problems, or that tui or an underlying library handle something unproperly on windows

matprec commented 5 years ago

https://github.com/TimonPost/crossterm/issues/195 is probably the culprit. Because of the early returns i initially just wrapped it in a loop and forgot about it.

https://github.com/tokio-rs/console/blob/39ae5d3b461898b0c419617f28e1af1218611657/console/src/ui/app.rs#L39-L41

Combined, this results in a busy looping over the console input count. This explains the cpu usage. I'm not sure what causes the unreasonable memory growth in the console subsystem underneath, but for now i'd be happy if it just goes away. We should keep this in mind, in case other memory issues surface.

Since the memory usage comes down to busy looping over the console input, pathological amounts of inputs or extremely long sessions could trigger this again.