You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cassandra.apache.org by Dmitry Konstantinov <ne...@gmail.com> on 2020/05/28 16:22:02 UTC
purpose of queryStates map in ServerConnection
Hello,
Could you please help to understand the purpose of a particular part of
code in Cassandra
codebase: org.apache.cassandra.transport.ServerConnection#getQueryState
https://github.com/apache/cassandra/blob/cassandra-3.11.6/src/java/org/apache/cassandra/transport/ServerConnection.java#L46
I noticed it originally in a profiler output:
[image: image.png]
For each CQL connection we have here cached QueryState instances per each
streamId value. This map is only dropped/garbage collected when
ServerCollection is released.
Can we just create a new QueryState for each request?
Regards,
Dmitry
--
Dmitry Konstantinov
Re: purpose of queryStates map in ServerConnection
Posted by Chris Lohfink <cl...@gmail.com>.
I cant see your profiler image so I may be missing something.
I remember looking at this in past too. At least with 3.x version of
java client the stream ids are reused as released so low volume apps wont
have much overhead and highly concurrent ones it prevents allocating
20-100k objs/sec. I think it's something that actually is nuanced on
usecase and client and not a straight forward good or bad change. Have you
tried benchmarking allocations with newing on each request vs caching by
streamid per connection?
Another improvement may be removing the need for the QueryState all
together since it doesn't really represent much over being a ClientState
wrapper. Or creating an immutable common state thats reused for non-tracing
queries per clientstate/connection.
Chris
On Thu, May 28, 2020 at 11:22 AM Dmitry Konstantinov <ne...@gmail.com>
wrote:
> Hello,
> Could you please help to understand the purpose of a particular part of
> code in Cassandra
> codebase: org.apache.cassandra.transport.ServerConnection#getQueryState
>
> https://github.com/apache/cassandra/blob/cassandra-3.11.6/src/java/org/apache/cassandra/transport/ServerConnection.java#L46
>
> I noticed it originally in a profiler output:
> [image: image.png]
> For each CQL connection we have here cached QueryState instances per each
> streamId value. This map is only dropped/garbage collected when
> ServerCollection is released.
> Can we just create a new QueryState for each request?
>
> Regards,
> Dmitry
> --
> Dmitry Konstantinov
>