zenoyang opened a new pull request, #21427:
URL: https://github.com/apache/doris/pull/21427

   
   ## Proposed changes
   
   Issue Number: close #xxx
   Eliminate virtual function calls when serializing and deserializing 
aggregate functions.
   
   For example, in `AggregateFunctionUniq::deserialize_and_merge` method, 
calling `read_pod_binary(ref, buf)` in the for loop generates a large number of 
virtual function calls.
   ```c++
   void deserialize_and_merge(AggregateDataPtr __restrict place, 
BufferReadable& buf,
                              Arena* arena) const override {
       auto& set = this->data(place).set;
       UInt64 size;
       read_var_uint(size, buf);
       set.rehash(size + set.size());
       for (size_t i = 0; i < size; ++i) {
           KeyType ref;
           read_pod_binary(ref, buf);
           set.insert(ref);
       }
   }
   
   template <typename Type>
   void read_pod_binary(Type& x, BufferReadable& buf) {
       buf.read(reinterpret_cast<char*>(&x), sizeof(x));
   }
   ```
   
   `BufferReadable` has only one subclass, VectorBufferReader, so it is better 
to implement the `BufferReadable` class directly.
   
   The following sql was tested on SSB-flat dataset:
   ```sql
   SELECT COUNT (DISTINCT lo_partkey), COUNT (DISTINCT lo_suppkey) FROM 
lineorder_flat;
   ```
   before: `MergeTime: 415.398ms`
   after opt: `MergeTime: 174.660ms` 
   
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at 
[[email protected]](mailto:[email protected]) by explaining why you 
chose the solution you did and what alternatives you considered, etc...
   
   


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to