mutrace

Moderator: Moderator

User avatar
arj
Site Admin
Posts: 2316
Joined: Thu Dec 01, 2005 8:51 pm
Location: Denmark
Contact:

mutrace

Postby arj » Fri Sep 25, 2009 9:46 am

Hello all

I found the following program today:

http://0pointer.de/blog/projects/mutrace.html

It's quite interesting in that it measures lock contention. I tried running it on mms of course and it appears that the threaded design we have is not really that good because stuff like SDL and imlib especially are single threaded (so we end up locking a critical resource).

My results from a simple test session was:

- 5 s total running time spent in a ost mutex in renderer. Most likely image_mut.
- 2 s total running time spent in a mutex in sdl. This is the one with most contention
- 2 s total running time spent in a mutex in graphical audio.

The results are reproducible across several runs.

To be fair I spent most of the testing in audio.

User avatar
Uatschitchun
Overlord
Posts: 3189
Joined: Tue Dec 06, 2005 6:55 pm
Location: Germany
Contact:

Re: mutrace

Postby Uatschitchun » Sat Sep 26, 2009 7:15 am

What to do with these results?
Lg
Roman

User avatar
arj
Site Admin
Posts: 2316
Joined: Thu Dec 01, 2005 8:51 pm
Location: Denmark
Contact:

Re: mutrace

Postby arj » Sun Sep 27, 2009 1:11 pm

That's a good question. Right now I have an idea about how we can make things "better" :)

User avatar
Uatschitchun
Overlord
Posts: 3189
Joined: Tue Dec 06, 2005 6:55 pm
Location: Germany
Contact:

Re: mutrace

Postby Uatschitchun » Sun Sep 27, 2009 3:22 pm

As I read Irc-log, it would be nice to have a comparison to NG
Lg

Roman

User avatar
arj
Site Admin
Posts: 2316
Joined: Thu Dec 01, 2005 8:51 pm
Location: Denmark
Contact:

Re: mutrace

Postby arj » Thu Oct 29, 2009 11:13 pm

I was tinkering today. The results above lead me to ponder a better solution. To me the big sinner is updater, I might go as far as to call it the biggest design mistake of mms. It runs in it's own thread, and thus everything that runs in it, will have to have everything it touches locked, if it can be reached from the main thread. So to me there are two big reasons for moving updater to main thread: fixing not-yet-uncovered bugs and making mms faster. I did a simple hack to make updater run in main thread today. Suffice to the say the results are very nice. There is almost no lock contention left and generally mms feels a bit smoother (this is probably a placebo effect).

I'd be grateful if people could test it and let me know what they think.

http://people.iola.dk/anders/make-updater-behave.diff

lorenzodes
master
Posts: 772
Joined: Sun Mar 11, 2007 4:50 pm
Location: move.l 4.w,a6

Re: mutrace

Postby lorenzodes » Sat Oct 31, 2009 7:38 am

"I’m not frightened of dying, anytime will do, I don’t mind. Why should I be frightened of dying? There’s no reason for it, you gotta go sometime"

User avatar
Uatschitchun
Overlord
Posts: 3189
Joined: Tue Dec 06, 2005 6:55 pm
Location: Germany
Contact:

Re: mutrace

Postby Uatschitchun » Sat Oct 31, 2009 8:42 am

Seems like ;)
Lg

Roman

User avatar
arj
Site Admin
Posts: 2316
Joined: Thu Dec 01, 2005 8:51 pm
Location: Denmark
Contact:

Re: mutrace

Postby arj » Sat Oct 31, 2009 10:55 am

you killed it. Bastards :D

It's up again ;)

lorenzodes
master
Posts: 772
Joined: Sun Mar 11, 2007 4:50 pm
Location: move.l 4.w,a6

Re: mutrace

Postby lorenzodes » Sat Oct 31, 2009 11:34 am

arj wrote:you killed it. Bastards :D

It's up again ;)


IMHO It's not thread safe :(

And by that I mean every thread can add/remove timer elements in the wrong moment.
"I’m not frightened of dying, anytime will do, I don’t mind. Why should I be frightened of dying? There’s no reason for it, you gotta go sometime"

loswillios
veteran
Posts: 100
Joined: Wed Aug 02, 2006 10:38 am

Re: mutrace

Postby loswillios » Sat Oct 31, 2009 3:21 pm

arj wrote:I'd be grateful if people could test it and let me know what they think.

http://people.iola.dk/anders/make-updater-behave.diff

Running nicely here with my dxr3. Playing some music with alsaplayer and movies with mplayer.

User avatar
arj
Site Admin
Posts: 2316
Joined: Thu Dec 01, 2005 8:51 pm
Location: Denmark
Contact:

Re: mutrace

Postby arj » Sat Oct 31, 2009 5:00 pm

Lorenzodes, what makes it not-thread-safe?

With the patch we have the following threads:

- Main
- All input is in a thread (doesn't touch core)
- All output is in a thread (doesn't touch core)
- Epg has a thread, but that one just does backgrund stuff, so again ok
- Rip is a sinner and must be converted
- python: seems ok
- notify: ok

Rip has been fixed in the latest patch. The deal is that now all mutexes in core can be removed, and more importantly. We can stop thinking in terms of things running concurrently. This will make it much easier to understand. I really hope we can come up with something similar for ng.

User avatar
arj
Site Admin
Posts: 2316
Joined: Thu Dec 01, 2005 8:51 pm
Location: Denmark
Contact:

Re: mutrace

Postby arj » Sat Oct 31, 2009 5:01 pm

I couldn't test rip since my cd drive is broken. So please anyone with a working drive please test :)

lorenzodes
master
Posts: 772
Joined: Sun Mar 11, 2007 4:50 pm
Location: move.l 4.w,a6

Re: mutrace

Postby lorenzodes » Sat Oct 31, 2009 8:10 pm

arj wrote:Lorenzodes, what makes it not-thread-safe?


What does? The fact it is, by your own words, unable to cope with concurrent, from multiple threads, read/write operations. Mind you, that doesn't mean it sucks, it means we have a new limitation in plugins. Wheather it is a good thing or not, apparently, it is a matter of opinion.

I am not sure it is a good idea to throw away the multi-thread safety without trying other solutions first.
"I’m not frightened of dying, anytime will do, I don’t mind. Why should I be frightened of dying? There’s no reason for it, you gotta go sometime"


Return to “general discussion”

Who is online

Users browsing this forum: No registered users and 1 guest