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 [d...@doris.apache.org](mailto:d...@doris.apache.org) 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org