Open mihaigalos opened 2 years ago
Thanks for the interest in the project!
I have not done any CPU usage test in a while but last it showed to be take up 1-5% on a 200 character wide terminal.
I have seem to miss placed the document on what I was using to test with due to that was over a year ago and a few machines. How are you testing this?
Regardless I do see your point and this would probably nice change.
How are you testing this?
Very flat cargo run --
, not sure how relevant it is. I see a 6-9% CPU usage on my old i5 (details below).
Maybe I'm biased, I find that a bit too much for something printing chars to the terminal.
I was curious so I profiled the release
binary. I don't see anything very strange, certainly not related to rng
:
callgrind_traces.tar.gz
I see you were already on the right track here, draw
is taking 93%
of all CPU cycles:
yeah I have been meaning to work on the IO part more.
I would have to do more research to be sure but if I remember correctly when queue
ing up a write call for the terminal if the queue exceeds a certain size flush is called premature. I believe there is a way to extend the buffer size but I am not sure this would help even if I knew how to do that.
I would have to do more research to be sure but if I remember correctly when
queue
ing up a write call for the terminal if the queue exceeds a certain size flush is called premature.
Yes:
The terminal will flush automatically if the buffer is full.
Potentially relevant: this.
Would you consider using a different crate for outputting to the screen?
termatrix which is using termion
is nowhere near as cool as your take, but is <2% of CPU (4-5x improvement!).
I don't believe termion is cross platform but even if it is I do not want to swap out crates there are other ways of getting performance out of crossterm
.
Rather than printing each character which can be a lot if your using the shading flag. Printing each row or Printing the hole screen at once could improve performance.
I will work on reducing RNG calls as well even though its probably not a massive contributor to the performance issue but ever little bit helps.
Rather than printing each character which can be a lot if your using the shading flag. Printing each row or Printing the hole screen at once could improve performance.
That would be great. I noticed the X server is also very busy redrawing the screen (>50% CPU), so perhaps redrawing everything at once would reduce events to it as well!
I cant get my CPU up that high. How big is your screen?
Making the screen pretty large does spike up the cpu to 17%.
I cant get my CPU up that high. How big is your screen?
A very generic 1920x1080
with the following terminal settings:
~ » tput cols
213
-------------------
~ » tput lines
57
I guess the behavior is more pronounced in my case because the CPU is older. But I actually noticed it on a Linux VM on Windows, which is even more pronounced.
But I actually noticed it on a Linux VM on Windows, which is even more pronounced.
Yeah windows and mac native terminals do not do well esc codes, but using the alacritty terminal helps a lot with this.
I guess the behavior is more pronounced in my case because the CPU is older.
Yeah that make sense, I'm sure this will help. Some time today I should be done with a basic implementation of it but not all flags will work. It will give a good indication if printing the hole screen helps. (If it doesn't I will be shocked)
Sorry for the delay. Work has taken over this week. I will have something up on Saturday or soon if I get the time.
So I have been working on the new draw improvements. This has turned out to be a usual a bit more complicated then I originally thought. Formatting the screen for characters that wider then a single space can throw a wrench in things. LOL I have ideas on fixing it but just thought Id post when I have so far.
One odd bug I manage to make was when adding color to the rain I get a weird solid character row flashing at the top. Just uncomment out the Some here if you want to take a look.
Just keep in mind this is highly unfinished work.
Looks great. Cannot reproduce the bug, can you perhaps try in a docker? Let me know if you need help.
Here's what I see (-s
doesn't work yet):
cargo run -- -c jap
Yeah pretty much no flags work yet.
Hi @cowboy8625, anything I can do to help here?
No sorry man its been a crazy couple months. Just got married and other life things have been taking all my free time. Ill work on it this weekend for sure.
Wow, congratulations! I wish you all the best. :+1:
Thanks!
Body and head colors work now. Some small bugs still to address but slowly getting there when I have time.
Hi, Awesome stuff here!
Did you consider an option for reducing the CPU load? I experimented a bit with removing the
rng
calls and noticed performance improvements. How about creating a vector of possible values (everything which is currently random) and looping through it?The user doesn't really care if a parameter is really random or not, they won't notice. They do care about CPU consumption, however. 😅
Here's what I've tried, let me know if you can reproduce: