Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem regarding cpu usage #57

Open
tramhao opened this issue May 21, 2021 · 5 comments
Open

Problem regarding cpu usage #57

tramhao opened this issue May 21, 2021 · 5 comments

Comments

@tramhao
Copy link
Contributor

tramhao commented May 21, 2021

I met a problem for both beep and mpd:
When open the app, the cup usage for gomu in gotop for mpd is about 2%, and beep is about 20%. After pressing N for like 10 seconds or more (skip), the cup usage for mpd is 40% and beep is 50%, and they don't drop back.

I think it's probably related to the go routine for play. I mean, the player.Run is in go routing, and it never returns, but it will spawn another go routine for next song.

What do you think?

@tramhao
Copy link
Contributor Author

tramhao commented May 21, 2021

Probably the problem is playingbar running for each song and didn't finish.

@issadarkthing
Copy link
Owner

I suspect playingbar is the problem. Try disable the playingbar, to see if the problem persists.

@tramhao
Copy link
Contributor Author

tramhao commented May 25, 2021

Yes, after comment out the content inside playingbar.go:run(), everything seems fine. Probably something wrong inside here.

@tramhao
Copy link
Contributor Author

tramhao commented May 26, 2021

I think I found the reason. playingbar.skip is never set to true, so the for loop is not ended. When playing, it's not a problem because for loop can be stopped.

@tramhao
Copy link
Contributor Author

tramhao commented May 28, 2021

Fixed it for now. But I still have too many doubts about this run function.

  1. Data cannot be fed into go func(). For example, if I move full:=p.getFull before go func, the full length of status bar will not be updated when skip. It's just wired.
  2. Inside go func, I need access to many data outside, like subtitle or photo, and this create data race which I cannot fix. For int, I could use sync/atomic to avoid data race, but what can I do with pointer?
  3. The whole block is getting messy but I don't have any clue how to refactor playingbar. Do you have some ideas? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants