Opened 12 years ago

#4803 new Feature Requests

[function][patch] use a static "empty" target

Reported by: Daniel Walker Owned by: Douglas Gregor
Milestone: To Be Determined Component: function
Version: Boost 1.44.0 Severity: Optimization
Keywords: Cc:

Description

boost::function throws bad_function_call if invoked when empty. Currently, this is implemented by performing a pointer comparison at runtime. Alternatively, boost::function's empty state could be represented by a static vtable object targeting an "empty" function which throws bad_function_call when invoked. There has been a lot of interest in this alternative scheme, which would trade the time overhead of a pointer comparison for an increase in space overhead in the initialized static variable section of the executable's data segment. The degree to which this trade-off will improve performance depends on compiler optimization. The attached patch implements a configuration macro, BOOST_FUNCTION_USE_STATIC_EMPTY, which allows the user to make this trade-off. The patch includes updated documentation and tests. I verified that the updated test suite passes on gcc 4.2, 4.5 and msvc 7.1, 10.

Attachments (5)

function_benchmark.tar.bz2 (839 bytes ) - added by Daniel Walker 12 years ago.
A simple benchmark system that can be used to compare the performance of boost::function and a function pointer.
signal_benchmark.tar.bz2 (1.2 KB ) - added by Daniel Walker 12 years ago.
Measure the impact of the static empty state on the performance of boost::signal.
signal_benchmark.tar.2.bz2 (1.5 KB ) - added by Daniel Walker 12 years ago.
Use a dummy_mutex and other changes.
signal_benchmark.tar.3.bz2 (1.5 KB ) - added by Daniel Walker 12 years ago.
Use a dummy_mutex, normalize by # of slots, etc.
djw_function_static_empty.patch (23.0 KB ) - added by Daniel Walker 12 years ago.
Implements BOOST_FUNCTION_USE_STATIC_EMPTY config macro with tests and docs.

Download all attachments as: .zip

Change History (5)

by Daniel Walker, 12 years ago

Attachment: function_benchmark.tar.bz2 added

A simple benchmark system that can be used to compare the performance of boost::function and a function pointer.

by Daniel Walker, 12 years ago

Attachment: signal_benchmark.tar.bz2 added

Measure the impact of the static empty state on the performance of boost::signal.

by Daniel Walker, 12 years ago

Attachment: signal_benchmark.tar.2.bz2 added

Use a dummy_mutex and other changes.

by Daniel Walker, 12 years ago

Attachment: signal_benchmark.tar.3.bz2 added

Use a dummy_mutex, normalize by # of slots, etc.

by Daniel Walker, 12 years ago

Implements BOOST_FUNCTION_USE_STATIC_EMPTY config macro with tests and docs.

Note: See TracTickets for help on using tickets.