No announcement yet.

Rust For Linux Kernel v9 Patches Trim Things Down Greatly For Easier Upstreaming

  • Filter
  • Time
  • Show
Clear All
new posts

  • #61
    Originally posted by NobodyXu View Post
    ultimA IMO this is because they want to retain the API/ABI stability, e.g. if this class is used in public API/ABI, then the compiler has to be careful when doing that.
    Yes, and that's the reason I tried stuff with anonymous namespaces and symbol visibility (also note I've been compiling an executable). ABI compatibility needn't be a concern here.


    • #62
      Originally posted by mdedetrich View Post

      Do note that there are multiple definitions of "zero cost". One is that it is literally free (as is with the case of exceptions, exceptions are "free" as long as you never catch them) where as the other is "for the abstraction you are opting into which in this case is vtables/OO, the implementation is as efficient as possible". C++ generally follows the latter definition of "zero cost", so its not that OO is free but rather their implementation of OO is as fast as you can get.

      The definition in of-itself is a bit loose when you deal with compiler optimisations as you noted.
      Just to clarify, I meant zero-cost in the former sense, meaning not "as efficient as possible", but truly zero. The virtual call was really replaced by a static call (or got inlined directly) without a vtable lookup, hence why I said zero-cost "as far as the executed instructions are concerned". The vtable, and more importantly the vtable pointer in the object instances, still remained, and so I said this was not zero-cost in space, even if this might still be efficient. Whether this is actually a performance problem depends on the application. If the objects need to be streamed in and out of memory and the app is memory bound, or if this causes some issues with efficient cache usage, then the space overhead can of course cause a performance degradation too. Otherwise, only the space taken up by itself, is probably a non-issue except on small embedded platforms.