[LINUX] xbmc server: possible quick implementation?

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Odon Offline
Member
Posts: 74
Joined: Apr 2010
Reputation: 0
Post: #46
Something weird is that i had a normal XBMC running on a debian vm, and was able to get down to 20% on 1 vCPU when reduced.
I'll try to give a look to the code too if i have some time.
find quote
vikjon0 Offline
---
Posts: 2,502
Joined: Apr 2009
Reputation: 8
Location: Sweden
Post: #47
Quote: get down to 20% on 1 vCPU when reduced.
Do you mean minimized? The menus does use a lot of resources when not minimized or screen saver.

Quote:all i've really done with this patch is to remove the requirement for the front-end display
But the menu rendering is not being done I assume, or do XBMC still think he has an interface?
find quote
Odon Offline
Member
Posts: 74
Joined: Apr 2010
Reputation: 0
Post: #48
vikjon0 Wrote:Do you mean minimized? The menus does use a lot of resources when not minimized or screen saver.


But the menu rendering is not being done I assume, or do XBMC still think he has an interface?

Yes, minimized, sorry for my poor english Tongue

But why a headless XBMC without GUI is using more resources than a minimized standard XBMC ?
find quote
vikjon0 Offline
---
Posts: 2,502
Joined: Apr 2009
Reputation: 8
Location: Sweden
Post: #49
Quote:But why a headless XBMC without GUI is using more resources than a minimized standard XBMC ?
Exactly, it shouldn't That is what I wanted bladesuk1 to confirm. Maybe my question is stupid but based on the information on hand I though I should make sure.
find quote
Odon Offline
Member
Posts: 74
Joined: Apr 2010
Reputation: 0
Post: #50
Ok some awfull patch, in XBApplicationEx.cpp, search for "while" and add a sleep(1) just after.
Code:
// Run xbmc
  while (!m_bStop)
  {
      sleep(1);

edit: have another issue, database is not responding through web server :/
find quote
bladesuk1 Offline
Junior Member
Posts: 32
Joined: Jul 2011
Reputation: 0
Post: #51
Odon Wrote:Ok some awfull patch, in XBApplicationEx.cpp, search for "while" and add a sleep(1) just after.
Code:
// Run xbmc
  while (!m_bStop)
  {
      sleep(1);
edit: have another issue, database is not responding through web server :/

i've just rebased this onto the current master branch of xbmc, and i'm recompiling as we speak to see whether it makes any difference.

edit: no, it doesn't make any difference. still getting 100% of a single cpu in use.

i'm not sure if XBApplicationEx.cpp is going to be called as i think the changes i made prevent the application from calling that, but i could be wrong. if it is called, then checking the server mode flag and preventing that loop from executing at all would do the same job without the need to make it sleep, which would only prevent it from spiking, and would also prevent it from working properly when not in server mode. good spot, though, and i reckon i can put the serverMode flag check in there instead and skip over that entire section of code.

edit: silly me - yes, it's called, and it's obviously calling the methods in the Application.cpp class. so instead of changing that class, i've put the server mode check into the methods that it's calling in Application.cpp instead like i've done elsewhere. i've also added the sleep(1) into the code as suggested to see if that helps. i think the issue is that the code is designed to be active rather than passive, so it responds as quickly as it possibly can to an event. as such, it's pretty much always going to be taking up 100% as it's going to run as fast as it can to listen to everything it's been told to listen to. it's not acting as a passive event listener, if that makes any sense - it's actively checking instead. a sleep command will let it stop working briefly, but i suspect that it's always going to take up an entire cpu unless someone can find another mechanism to slow it up a little. as it stands, though, this little hack appears to have massively dropped the cpu usage (currently sitting at 1.8% atm). seems to be working as it did before for me, so good call for this little hack Smile

as to database, i've no idea - what are you using the query the database?
(This post was last modified: 2012-01-10 19:31 by bladesuk1.)
find quote
Odon Offline
Member
Posts: 74
Joined: Apr 2010
Reputation: 0
Post: #52
Great Smile and good job for thé better implementation.

Regarding DB, it is a MySQL DB i try to access through default XBMC web interface. Xbmc log shows that request is grabbed but i can't get neither my movie list nor my show list.

I ll do some tests tonight
find quote
bladesuk1 Offline
Junior Member
Posts: 32
Joined: Jul 2011
Reputation: 0
Post: #53
Odon Wrote:Great Smile and good job for thé better implementation.
Regarding DB, it is a MySQL DB i try to access through default XBMC web interface. Xbmc log shows that request is grabbed but i can't get neither my movie list nor my show list.
I ll do some tests tonight

it's the same solution that you suggested, just in a different place where i can use the server mode flag is all. to be honest, i wouldn't have thought of trying that, so the credit's yours (and you're mentioned in the commit notice, too, for what it's worth).

i've had a look at mine, and mine's grabbing the data from mysql quite happily. i'd suggest it's probably a configuration glitch? or perhaps an empty library? that seems to confuse the web interface an awful lot.
find quote
Odon Offline
Member
Posts: 74
Joined: Apr 2010
Reputation: 0
Post: #54
You definitely made most of the job : p
Finally DB works with your latest Git version, and a small cpu usage. I've probably made a mistake when patching my own sources.
Everything seems fine now : D
find quote
Odon Offline
Member
Posts: 74
Joined: Apr 2010
Reputation: 0
Post: #55
Well... DB update wasn't working but resolved \o/

You have to allow creation of two windows in Application.cpp:
- g_windowManager.Add(new CGUIDialogMusicScan);
- g_windowManager.Add(new CGUIDialogVideoScan);

If not allowed in server mode, DB updating does not work.

So finally, i have my headless xbmc which can automatically update my DB without using two much CPU Big Grin
find quote
bladesuk1 Offline
Junior Member
Posts: 32
Joined: Jul 2011
Reputation: 0
Post: #56
ah, that's why it didn't appear to be scanning. good spot Smile i'd never have thought that you'd need to create a window to make the scanners function. wonder what else works like that?

anyways, i've made that change and pushed it into the repo now. any more suggestions/finds/bugs, keep 'em coming, and with a bit of luck we can get this into the mainline code for the next release.
find quote
Odon Offline
Member
Posts: 74
Joined: Apr 2010
Reputation: 0
Post: #57
I had a look to xbmc/interfaces/Builtins.cpp.

It might also be required to deactivate some function in this file. XBMC had crash when playing with web interfaces or marischano (cf Supplemental Tools forum), one of them being when requested to play a file.
find quote
Odon Offline
Member
Posts: 74
Joined: Apr 2010
Reputation: 0
Post: #58
After a quick look, best solution to deactivate built-in commands would be to edit xbmc/interfaces/Builtins.cpp

- Add a bool to BUILT_IN struct
" bool availableAsServer;"

- Edit commands[] array to add a true/false value for available commands

- Edit bool CBuiltins::HasCommand(const CStdString& execString) to return false if availableAsServer is false and ServerMode is on.
find quote
bladesuk1 Offline
Junior Member
Posts: 32
Joined: Jul 2011
Reputation: 0
Post: #59
that's another good call. maybe you should be running this little side project Wink

there may need to be some input from the dev team on this - i believe that one requirement for this is to be able to play audio files when in server mode, for some reason. for now, though, i'll just disabe the playmedia/playercontrol commands entirely as a) i've no way to test and b) i don't see how it'll work anyway.

i've gone down the exact route you suggested - i'm just compiling and testing now, and if it still appears to be working i'll push it up to my fork. we've actually gone beyond my initial quick fix solution with this, but it makes perfect sense to disable the functionality that isn't required. for a hack of a solution, this feels like a rather elegant one Tongue
find quote
j1nx Offline
Fan
Posts: 607
Joined: Aug 2011
Reputation: 22
Location: Netherlands
Post: #60
Just to let you guys know. Now this little thing is at the point I will jump in aswell. I need this "main" xbmc install at my server for updating my MySQL library and to be notified by CP and SB.

Updating now works!
CPU is getting lower!

Perfect, for me. I will try it out and offcourse get back to you with any issues I might run into.

Great work, so far. Keep it up.
find quote
Post Reply