You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/03/26 11:24:29 UTC

[GitHub] [incubator-doris] stdpain opened a new issue #5576: [optimize] a better defer operater

stdpain opened a new issue #5576:
URL: https://github.com/apache/incubator-doris/issues/5576


   **Is your feature request related to a problem? Please describe.**
   
   Our current defer operation is based on std:: function But in most C + + standard libraries, when creating a function, there will be a new overhead, which is not necessary for the defer operation. But in fact, if we pass in a lambda expression, we can determine it during compilation, so we can avoid a new / delete overhead during the defer operation
   
   STL std::funcional implement
   ```c++ 
   private:
     static void
     _M_init_functor(_Any_data& __functor, _Functor&& __f, true_type)
     { ::new (__functor._M_access()) _Functor(std::move(__f)); }
   
     static void
     _M_init_functor(_Any_data& __functor, _Functor&& __f, false_type)
     { __functor._M_access<_Functor*>() = new _Functor(std::move(__f)); }
   ```
   
   we could use this code instread of DeferOP
   ```c++
   template <class T>
   class Defer {
   public:
       Defer(T& closure) : _closure(closure) {}
       ~Defer() { _closure(); }
   
   private:
       T& _closure;
   };
   ```
   
   
   **Describe the solution you'd like**
   Here was the bench mark: https://quick-bench.com/q/4IKpxAA5VEbXVziV1G2Po-ZupSE
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman closed issue #5576: [optimize] a better defer operater

Posted by GitBox <gi...@apache.org>.
morningman closed issue #5576:
URL: https://github.com/apache/incubator-doris/issues/5576


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org