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)
Change History (5)
by , 12 years ago
Attachment: | function_benchmark.tar.bz2 added |
---|
by , 12 years ago
Attachment: | signal_benchmark.tar.bz2 added |
---|
Measure the impact of the static empty state on the performance of boost::signal.
by , 12 years ago
Attachment: | signal_benchmark.tar.2.bz2 added |
---|
Use a dummy_mutex and other changes.
by , 12 years ago
Attachment: | signal_benchmark.tar.3.bz2 added |
---|
Use a dummy_mutex, normalize by # of slots, etc.
by , 12 years ago
Attachment: | djw_function_static_empty.patch added |
---|
Implements BOOST_FUNCTION_USE_STATIC_EMPTY config macro with tests and docs.
A simple benchmark system that can be used to compare the performance of boost::function and a function pointer.