| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
explicit add.
Note: Volatile is used here merely to avoid compiler optimizations.
|
|
|
|
| |
capturing
|
| |
|
|
|
|
| |
inline function, pulled-up from jau::type_info
|
|
|
|
|
|
|
| |
- Hide `delegate_t` union details using a non-anonymous type.
- Rename `function<R(A...)>::delegate_t_` to `function<R(A...)>::delegate_type`
- Add ylambda example using `function<R(A...)>::delegate_type` instead of `auto`
- Fix link to example
|
|
|
|
|
|
| |
(recursions, ...); API doc cleanup
Covered in unit tests, passed valgrind tests.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(footprint + performance)
Keep orig Runtime Polymorphic as `test/function2.hpp` for comparison and review.
delegate_t<R(A...)> allows fast path target function invocation.
This static polymorphous object, delegates invocation specific user template-type data and callbacks
and allows to:
- be maintained within function<R(A...)> instance as a member
- avoiding need for dynamic polymorphism, i.e. heap allocated specialization referenced by base type
- hence supporting good cache performance
- avoid using virtual function table indirection
- utilize constexpr inline for function invocation (callbacks)
Impact:
- Memory footprint reduced (64bit)
- lambda, member: 64 -> 48 bytes, i.e. 25.00% less size
- capval, capref: 56 -> 48 bytes, i.e. 14.29% less size
- Performance (linux-arm64, raspi4, gcc, mean @ 600 samples):
- member_jaufunc: 7.34998 -> 5.3406 ms, i.e. 27.34% perf. gain
- becoming faster than member_stdbind_unspec
- lambda_jaufunc: 6.89633 -> 5.52684 ms, i.e. 19.86% perf. gain
- aligning most trivial-types to similar performance
- Performance differences on linux-amd64 high-perf machine
- Less significant than linux-arm64
- Probably due to better CPU caching, memory access, branch prediction, etc.
- member_jaufunc: 1.880 -> 1.848 ms, i.e. ~2% perf. gain (too small)
- lambda_jaufunc: 1.871 -> 1.851 ms, i.e. ~1% perf. gain (too small)
- Lines of code incl. comments:
- From 1287 -> 1674 lines, i.e. 30% added lines of code
- Added code used for manual static polymorphism, see above.
- Performance methodology
- New code test
- nice -20 ./test_functional2_perf --benchmark-samples 600
- Old code test
- nice -20 ./test_functional1_perf --benchmark-samples 600
+++
Optimization of func::member_target_t<...> using `gcc`
Utilizing GCC C++ Extension: Pointer to Member Function (PMF) Conversion to function pointer
- Reduces function pointer size, i.e. PMF 16 (total 24) -> function 8 (total 16)
- Removes vtable lookup at invocation (performance)
- Pass object this pointer to function as 1st argument
- See [GCC PMF Conversion](https://gcc.gnu.org/onlinedocs/gcc/Bound-member-functions.html#Bound-member-functions)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`target_t<R(A...)>`
Drop target_t::delegate
- implementation insufficient regarding C++ UB and not yet enought to show performance benefit
- will be revised in upcoming commit for a pure Static Polymorphic delegate_t
- maintain simplified code for target_t<R(A...)> and its specializations
Use and expose jau::type_info and target size
- originally used for lambda only, it might benefit users to query the type_info
- same for target size
lambda_target simplified via jau::type_info
- encapsulated all RTTI/CTTI type_info, especially macros and equal operator
Misc
- Move target_t::size to function
- function<R(A...)>::toString() Show prototype signature with demangled names (if available) and size.
API:
- function<R(A...)>: Remove cap[val|ref]'s dataIsIdentity param, handle as dataIsIdentity==true (always)
- This simplifies the API and the data chunk shall always refer to its identity
- Add function<R(A...)> for member of type C0 and this base-pointer of type C1 derived-of or same-as C0
- This allows passing a instance reference for this base-pointer, derived from the actually used member-function
- Tested in test_function01's test01_memberfunc_this()
+++
test_function01
- test01_memberfunc_this() covers different this base-pointer and member-function relationships
- Use `constexpr jau::type_info::limited_lambda_id` instead of macro
- Added test09_lambda_ctti() regarding RTTI/CTTI type name limitations
test_function0_perf
- Add test00_usage(), showing memory footprint ...
|
|
|
|
|
|
|
|
|
|
| |
function size accessible (and show in toString()
Also, to avoid any template type deduction error,
have the internally used `function(std::shared_ptr<target_type> _funcPtr) noexcept`
made explicit as `explicit function(const void* dummy, std::shared_ptr<target_type> _funcPtr) noexcept`
Adopted test_functional01.cpp and test_functional_perf.hpp
|
|
target_t::delegate; Add function ctor for all types incl. simple lambda assignment; Add perf test.
|