English Only
Please check existing issues first to avoid duplication and answer the questions below before submitting your issue.
Use case(s)
When we are building a query
, we can use strings.Builder
. But in fact, we should think about reuse the buffer to avoid GC and improve the performance.
Usually, we will use sync.Pool
to cache the buffer. But there is a problem that the buffer's capacity may be expanded when it was put back.
For example, the original capacity of buffer is 128, and it means that we can only store 128 bytes. However, we reuse this buffer to build a long query which has more than 128 bytes, e.g. 200 bytes, and then the buffer capacity was expanded to 256 bytes.
If most of the queries only need 50 bytes, it means that we waste a lot memory. A typical solution is avoiding cache big buffer.
Proposed Solution
(Please describe your proposed design/solution, if any)
Alternatives Considered
(Other possible options for solving the problem?)
Additional Context
(Paste any relevant logs - please use code blocks (```) to format console output,
logs, and code as it's very hard to read otherwise.)
(If you can, link to the line of code that might be helpful to explain the context)
feature