You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cache: non-blocking &self reads, so that callers need no mutex #4
Cache reads (try_get, try_list_dir, try_access) take &mut self, so every caller that shares a Cache wraps it in a mutex. A caller that must not wait, as the meta-service watch caches of databend query nodes (databendlabs/databend#21110), holds a sync mutex just to poll try_access once with now_or_never(), and reads the remote store on None.
That has two costs:
Concurrent readers take turns on the outer mutex, though every read is read-only.
The poll returns None whenever the task's tokio coop budget is spent, even with the lock free: tokio::sync::Mutex::lock polls batch_semaphore::Acquire, whose poll calls coop::poll_proceed before it looks at the permits (tokio 1.54.1, src/sync/batch_semaphore.rs). Such a read goes to the remote store for no reason.
Proposal
A non-blocking &self read that admits concurrent readers, e.g. on an RwLock with try_read, and answers None while the cache initializes or reconnects. Callers can then drop their mutex and the now_or_never() poll.
#2 tried RwLock reads, together with a resync, and was closed without merging.
The callers in databend: Cache::try_get_ready and Cache::try_list_dir_ready in src/meta/plugins/cache/src/cache.rs, used through the parking_lot::Mutex<Cache> fields of UserMgr, SettingMgr and WarehouseMgr.
Activity