[Signals] Observation about performance
I have an application that implements the Observer pattern, based on the GOF code and was interested in using Boost.Signals in a new application. Before committing myself, I decided to check the relative performance when signalling two observers. Both tests were performed on Windows XP, using MSVC 8 beta 2, with the /Ox optimisation. Here are the times for 6,000,000 signals, measured with the Win32 GetTickCount() API on a 3GHz P4 with 1GB RAM: GOF Observer: 109 Boost.Signals: 6203 Clearly, you have to trade convenience for performance with this library. - Keith MacDonald
On May 10, 2005, at 7:11 AM, Keith MacDonald wrote:
I have an application that implements the Observer pattern, based on the GOF code and was interested in using Boost.Signals in a new application. Before committing myself, I decided to check the relative performance when signalling two observers. Both tests were performed on Windows XP, using MSVC 8 beta 2, with the /Ox optimisation. Here are the times for 6,000,000 signals, measured with the Win32 GetTickCount() API on a 3GHz P4 with 1GB RAM:
GOF Observer: 109 Boost.Signals: 6203
Clearly, you have to trade convenience for performance with this library.
The performance of Signals has been drastically improved in 1.33.0 thanks to a patch from Robert Zeh. It may still not be as quick as a specific implementation of the Observer pattern, but it's much more reasonable now. Doug
Doug,
I omitted to state that I linked with Boost.Signals from the current CVS
head. Is that different from 1.33.0?
Keith MacDonald
"Doug Gregor"
On May 10, 2005, at 7:11 AM, Keith MacDonald wrote:
I have an application that implements the Observer pattern, based on the GOF code and was interested in using Boost.Signals in a new application. Before committing myself, I decided to check the relative performance when signalling two observers. Both tests were performed on Windows XP, using MSVC 8 beta 2, with the /Ox optimisation. Here are the times for 6,000,000 signals, measured with the Win32 GetTickCount() API on a 3GHz P4 with 1GB RAM:
GOF Observer: 109 Boost.Signals: 6203
Clearly, you have to trade convenience for performance with this library.
The performance of Signals has been drastically improved in 1.33.0 thanks to a patch from Robert Zeh. It may still not be as quick as a specific implementation of the Observer pattern, but it's much more reasonable now.
Doug
Doug,
Following up my previous message, I have run the tests with Boost 1.32.0 and
can see what you mean about a drastic improvement. The full set of figures
are:
VC8.0 GOF Observer: 109
VC8.0 Signals 1.33.0: 6203
VC7.1 GOF Observer: 78
VC7.1 Signals 1.32.0: 112109
It's interesting that the Observer pattern is actually slower with VC 8.
- Keith MacDonald
"Doug Gregor"
The performance of Signals has been drastically improved in 1.33.0 thanks to a patch from Robert Zeh. It may still not be as quick as a specific implementation of the Observer pattern, but it's much more reasonable now.
Doug
It might be a good idea to launch the benchmark in a seperate thread,
then call something like:
double GetThreadTime(HANDLE t) {
__int64 c, e, k, u;
GetThreadTimes(t, (FILETIME*)&c, (FILETIME*)&e, (FILETIME*)&k,
(FILETIME*)&u);
return u/10000000.0; // user-mode time in seconds
}
to get a more precise time.
On 5/10/05, Keith MacDonald
Doug,
Following up my previous message, I have run the tests with Boost 1.32.0 and can see what you mean about a drastic improvement. The full set of figures are:
VC8.0 GOF Observer: 109 VC8.0 Signals 1.33.0: 6203
VC7.1 GOF Observer: 78 VC7.1 Signals 1.32.0: 112109
It's interesting that the Observer pattern is actually slower with VC 8.
- Keith MacDonald
"Doug Gregor"
wrote in message news:9d494fe2c9d82d8a37c8c9a18f1b553e@cs.indiana.edu... The performance of Signals has been drastically improved in 1.33.0 thanks to a patch from Robert Zeh. It may still not be as quick as a specific implementation of the Observer pattern, but it's much more reasonable now.
Doug
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Cory Nelson http://www.int64.org
Given that the difference in times is a factor of 57, I'm not convinced that
any greater precision is warranted.
"Cory Nelson"
It might be a good idea to launch the benchmark in a seperate thread, then call something like:
double GetThreadTime(HANDLE t) { __int64 c, e, k, u; GetThreadTimes(t, (FILETIME*)&c, (FILETIME*)&e, (FILETIME*)&k, (FILETIME*)&u);
return u/10000000.0; // user-mode time in seconds }
to get a more precise time.
I was talking more about the diff between VC8 and VC71.
On 5/10/05, Keith MacDonald
Given that the difference in times is a factor of 57, I'm not convinced that any greater precision is warranted.
"Cory Nelson"
wrote in message news:9b1d061405051008415769eb3c@mail.gmail.com... It might be a good idea to launch the benchmark in a seperate thread, then call something like:
double GetThreadTime(HANDLE t) { __int64 c, e, k, u; GetThreadTimes(t, (FILETIME*)&c, (FILETIME*)&e, (FILETIME*)&k, (FILETIME*)&u);
return u/10000000.0; // user-mode time in seconds }
to get a more precise time.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Cory Nelson http://www.int64.org
On May 10, 2005, at 10:41 AM, Cory Nelson wrote:
It might be a good idea to launch the benchmark in a seperate thread, then call something like:
double GetThreadTime(HANDLE t) { __int64 c, e, k, u; GetThreadTimes(t, (FILETIME*)&c, (FILETIME*)&e, (FILETIME*)&k, (FILETIME*)&u);
return u/10000000.0; // user-mode time in seconds }
to get a more precise time.
At 60x overhead, I don't think more precise timing is the problem :) Signals likely needs some kind of overhaul w.r.t. performance. The major problem now is the slot groups. Doug
"Keith MacDonald"
Doug,
Following up my previous message, I have run the tests with Boost 1.32.0 and can see what you mean about a drastic improvement. The full set of figures are:
VC8.0 GOF Observer: 109 VC8.0 Signals 1.33.0: 6203
VC7.1 GOF Observer: 78 VC7.1 Signals 1.32.0: 112109
It's interesting that the Observer pattern is actually slower with VC 8.
- Keith MacDonald
"Doug Gregor"
wrote in message news:9d494fe2c9d82d8a37c8c9a18f1b553e@cs.indiana.edu... The performance of Signals has been drastically improved in 1.33.0 thanks to a patch from Robert Zeh. It may still not be as quick as a specific implementation of the Observer pattern, but it's much more reasonable now.
Doug
It's nice to see that my patches had an impact! I'm working on improvements (suggested by Doug Gregor) that replace some boost::any usages with template classes. This should make the library faster by removing some of the memory management it does. Is your application openly available? I'm always looking for more benchmarks. Robert Zeh
participants (4)
-
Cory Nelson
-
Doug Gregor
-
Keith MacDonald
-
Robert Zeh