Skip to content

Conversation

@joao-r-reis
Copy link
Contributor

@joao-r-reis joao-r-reis commented Sep 24, 2025

In 2.0.0-rc1 we got rid of the query object pooling and now the extra allocs associated with the code that is collecting QueryMetrics is 1 of the factors that are leading to a small performance regression.

Since the majority of the users don't use Query Metrics, it makes more sense to make these opt-in.

Benchmarks here (this branch vs v1.7.0). With this change, the results are much more acceptable. I still think the v5 implementation has room for improvement but this is the first version of our v5 implementation and we can iterate on it in follow up releases. The most important part is that now v4 (in 1.7.0) vs v4 (in 2.0 - this branch) looks ok.

Don't collect host metrics if a query/batch observer is not provided, this is a small optimization.

@joao-r-reis joao-r-reis force-pushed the querymetrics branch 2 times, most recently from e860946 to aa3829a Compare September 24, 2025 22:02
@joao-r-reis joao-r-reis changed the title CASSGO-90 Make QueryMetrics (Latency and Attempts) opt-in CASSGO-90 Make QueryMetrics (Latency) and HostMetrics opt-in Sep 24, 2025
@joao-r-reis joao-r-reis force-pushed the querymetrics branch 2 times, most recently from caa8d88 to eb0375d Compare September 24, 2025 22:26
Copy link
Contributor

@worryg0d worryg0d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good idea to make query metrics collectors optional. If someone doesn't care about them or has their own mechanisms to collect such metrics, the driver should allow disabling them. Also, it reduces the amount of mem allocations when we don't really need them.

I left some comments regarding naming and godoc.

Now it makes more sense to me than a copy call on a zero-length source to impact performance that much. Ofc it has some place, but believing that this causes 10% performance degradation is really hard

@joao-r-reis joao-r-reis force-pushed the querymetrics branch 2 times, most recently from 8bac773 to 41efd6d Compare September 25, 2025 13:54
@joao-r-reis joao-r-reis changed the title CASSGO-90 Make QueryMetrics (Latency) and HostMetrics opt-in CASSGO-90 Don't collect host metrics if a query/batch observer is not provided Oct 1, 2025
@joao-r-reis joao-r-reis force-pushed the querymetrics branch 3 times, most recently from bdb525b to adeb204 Compare October 1, 2025 16:34
@joao-r-reis
Copy link
Contributor Author

After discussing with @jameshartig we decided to go with another approach. Instead of doing a breaking change and adding a new API we'll just stop collecting host metrics (therefore removing the map allocation) when an observer is not provided.

Patch by João Reis; reviewed by Bohdan Siryk and James Hartig for CASSGO-90
Copy link
Contributor

@jameshartig jameshartig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@worryg0d worryg0d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@joao-r-reis joao-r-reis merged commit 759351e into apache:trunk Oct 3, 2025
72 checks passed
@joao-r-reis joao-r-reis deleted the querymetrics branch October 3, 2025 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants