readysettech / readyset

Readyset is a MySQL and Postgres wire-compatible caching layer that sits in front of existing databases to speed up queries and horizontally scale read throughput. Under the hood, ReadySet caches the results of cached select statements and incrementally updates these results over time as the underlying data changes.
https://readyset.io
Other
4.28k stars 117 forks source link

Add metrics for QueryStatusCache sizes #787

Closed lukoktonos closed 10 months ago

lukoktonos commented 11 months ago

Description

The QueryStatusCache currently has 2 maps: id_to_status: a lighter weight map that is used for query routing decisions but can grow unbounded (which may be mitigated if we switch to using a bloom/cuckoo filter at this layer: REA-3568). statuses: an LruCache that stores the full query strings and has a maximum capacity, currently, of 100,000.

Having a gauge for the size of these would allow us to roughly estimate their current memory usage in the system, and allow us to observe the rate of unique queries that readyset is observing

Change in user-visible behavior yes

Requires documentation change

yes

neeleshbisht99 commented 10 months ago

Hi @lukoktonos I'd like to take this up. Here's a simple approach I think would work, please correct me if I've missed anything: Following for roughly estimating current memory usage:

  1. id_to_status: Adding a gauge in the insert_with_status method, denoting the len of DashMap.
  2. statuses: Adding a gauge in the persistent_handle.insert_with_status method, denoting the len of LruCache.
lukoktonos commented 10 months ago

@neeBis thanks for looking to contribute! Yep, those gauges both sound right to me!

neeleshbisht99 commented 10 months ago

Hi @lukoktonos Can you please take a look at the above PR?

lukoktonos commented 10 months ago

Resolved in 5b33d1f33