Giter VIP home page Giter VIP logo

Comments (4)

mingxwa avatar mingxwa commented on September 2, 2024 1

@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:

image
image

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.

ingangi avatar ingangi commented on September 2, 2024

Update:
When I change the loop count from 10000 to 10, the result changed, proxy is faster.
image

from proxy.

mingxwa avatar mingxwa commented on September 2, 2024

@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.

ingangi avatar ingangi commented on September 2, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.