Comments (4)
@ingangi I tried to compile your code with GCC 11.4, and observed that the virtual function calls in use_vtable()
are devertualized, but not devertualized in use_proxy()
and use_vtable_proxy()
. See the screenshots below:
Indeed, GCC is better at devertualizing native virtual functions than proxy
in this case. However, in most scenarios, runtime abstraction is used accross translation units or even ABI boundaries, and there is little chance for devirtualization. I think it would be more reasonable for the benchmark to separate the abstraction and implementation into different translation units, and see how it goes. From my personal experience, the numbers shoule be similar.
from proxy.
Update:
When I change the loop count from 10000 to 10, the result changed, proxy is faster.
from proxy.
@ingangi Could you share more context about the compiler version, flags and your test environment? Any template library, including STL implementations requires compiler optimizations to generate high quality code. If compiler optimization is properly set, I guess all the indirect calls in your code will be optimized away, because the implementation is in the same compilation unit. I suggest reviewing the generated code via Compiler Explorer.
from proxy.
@mingxwa thank you for the quick response.
compiler: g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
flags: -std=c++20 -O2 -isystem benchmark/include -Lbenchmark/build/src -lbenchmark -lpthread
from proxy.
Related Issues (20)
- Add support for fuzz test
- Add support for pointer casting
- inherit member variable using proxy HOT 3
- Compilation error in Linux (centos8, gcc10.5) HOT 1
- Where is document? HOT 3
- A class cannot have a constructor with parameters? HOT 1
- Calling a polymorphic function with a rvalue-reference convention shall be destructive
- Having two or more indirect conventions will make `proxy` 8 bytes larger than expected in MSVC
- Provide c++20 module interface HOT 1
- `facade_builder::restrict_layout` may make the resulting facade ill-formed
- Is it possible to implement template classes inherit from facade_builder with proxy? HOT 1
- Error: call to member function 'Area' is ambiguous when try to add_convention Area function with different return type. HOT 1
- How to set a default implement for a member function? HOT 1
- How to create a class that does not contain all the signature definition functions? HOT 3
- pro::proxy<Drawable> obj may reconstruct class when it's a function return value unless using make_proxy. HOT 5
- How to forbid the implicit type conversion of function parameter definition in add_convention? HOT 4
- What's the best way to implement a LD_PRELOAD-able plug-in registry class in proxy style? HOT 1
- Compile warnings in clang 18 HOT 2
- CMake won't build if the version is below 3.24
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proxy.