Avoid memory copy in ColumnString and Add Reserve function to reduce memory allocation times
Avoid memory copy in ColumnString and Add Reserve function to reduce memory allocation times.
In the working environment, we encountered the situation that the clickhouse machine hangs up several times. At this time, the server can receive the client's request, but will not respond, which will cause the client to be stuck in the recv() link, which will affect the subsequent data. write. Adding the timeout config and cooperating with the logic of switching the write replica when the write fails can avoid the above problems.
The clickhouse writing service knows the number of rows of data when accumulating data. At this time, we can directly calculate the memory space they need, and allocate them directly through Reserve, which can reduce the number of memory allocations and reduce the time consuming when constructing columns.
Hi! Thank you for your contribution, there are some issues with this PR though.
There are 3 unrelated features, please split it into 3 PRs:
- socket timeout
- ColumnString optimizations
- Reserve
Please add some tests that cover ColumnString and Reserve.
Also, maybe consider making Reserve a virtual method of Column and providing reasonable defaults to other columns (Decimal, Enum, Tuple, etc) too.
Seems to be inactive, closing. Please feel free to re-open, update, and address highlighted issues.