Ancurio / mkxp

Free Software implementation of the Ruby Game Scripting System (RGSS)
GNU General Public License v2.0
512 stars 130 forks source link

What is "sigc::slot_base::empty() const" doing? #156

Open pulsejet opened 7 years ago

pulsejet commented 7 years ago

Trying to profile mkxp using gprof, I found that the call "sigc::slot_base::empty() const" had consumed a relatively huge CPU time. Any idea what this might be related to?

My output from gprof is here: https://drive.google.com/open?id=0Bxvz3wbxE2UXX0stZ0lJMFJsVVE

A visualization of the same here: https://drive.google.com/open?id=0Bxvz3wbxE2UXZ0JLOS1xQV9Uc0U (gprof2dot, track the green boxes)

Ancurio commented 7 years ago

https://git.gnome.org/browse/libsigcplusplus/tree/sigc++/functors/slot_base.h#n329 https://git.gnome.org/browse/libsigcplusplus/tree/sigc++/functors/slot_base.h#n375 https://git.gnome.org/browse/libsigcplusplus/tree/sigc++/functors/slot_base.h#n131 https://git.gnome.org/browse/libsigcplusplus/tree/sigc++/functors/slot_base.h#n31

::empty() is roughly equivalent to

struct B {
  void *p;
};

struct A {
  B *b;
  bool empty() const {
    return (!b || !b->p);
  }
};

My best guess is that the amount of calls to this method + induced cache misses are responsible for your results. Would be interesting to know how many times this method is called during signal emission.
Are you having issues with performance?

Edit: Expressions in brackets are negated.

pulsejet commented 7 years ago

Er... how can I find out the number of calls (is this the 416852x)? (I'm a total noob to profiling, actually). I'm not having performance issues on x86, but there are some performance issues on android for some games, but since there is no sane way to profile native code on android, I decided to try to see if something obvious comes up while profiling for x86.

Ancurio commented 7 years ago

Er... how can I find out the number of calls (is this the 416852x)?

I never used gprof before, but it does say "calls" in the column header, so that's what I'd suspect :)

I'm not having performance issues on x86, but there are some performance issues on android for some games

Have you looked into GPU profiling too? Many of the bottlenecks I saw 3 years ago were due to rendering. Although To the Moon lagged heavily and I don't believe that was due to GPU work..