mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
fix: 号池 legacy 配置默认回退到 cache_affinity,multi_score 模式补全 LRU 数据获取
_build_from_legacy_fields 在无 legacy 字段时默认返回 cache_affinity 而非 lru, 与 PoolConfig 默认值保持一致。PoolManager 在 scheduling_mode 为 multi_score 时 也获取和更新 LRU 数据,修复 cache_affinity/single_account 维度因缺少 lru_scores 导致排序失效的问题。
This commit is contained in:
@@ -332,7 +332,10 @@ def _convert_legacy_string_list(
|
||||
|
||||
def _build_from_legacy_fields(legacy_mode: Any, legacy_lru: Any) -> tuple[SchedulingPreset, ...]:
|
||||
"""Build presets from legacy scheduling_mode / lru_enabled only."""
|
||||
lru_enabled = legacy_lru if isinstance(legacy_lru, bool) else True
|
||||
if lru_enabled:
|
||||
return (SchedulingPreset(preset="lru", enabled=True),)
|
||||
# Explicit lru_enabled=True -> LRU; explicit lru_enabled=False -> cache_affinity.
|
||||
# No legacy fields at all -> default to cache_affinity.
|
||||
if isinstance(legacy_lru, bool):
|
||||
if legacy_lru:
|
||||
return (SchedulingPreset(preset="lru", enabled=True),)
|
||||
return (SchedulingPreset(preset="cache_affinity", enabled=True),)
|
||||
return (SchedulingPreset(preset="cache_affinity", enabled=True),)
|
||||
|
||||
@@ -132,7 +132,11 @@ class PoolManager:
|
||||
)
|
||||
else None
|
||||
)
|
||||
_lru_coro = redis_ops.get_lru_scores(pid, all_key_ids) if self.config.lru_enabled else None
|
||||
# LRU scores are needed both for plain LRU sorting and for multi_score
|
||||
# dimensions (e.g. cache_affinity / single_account) that rely on
|
||||
# lru_scores data.
|
||||
_need_lru = self.config.lru_enabled or self.config.scheduling_mode == "multi_score"
|
||||
_lru_coro = redis_ops.get_lru_scores(pid, all_key_ids) if _need_lru else None
|
||||
_latency_coro = (
|
||||
redis_ops.batch_get_latency_avgs(pid, all_key_ids, self.config.latency_window_seconds)
|
||||
if self.config.scheduling_mode == "multi_score"
|
||||
@@ -504,7 +508,8 @@ class PoolManager:
|
||||
)
|
||||
else None
|
||||
)
|
||||
_lru_coro = redis_ops.get_lru_scores(pid, key_ids) if self.config.lru_enabled else None
|
||||
_need_lru_sk = self.config.lru_enabled or self.config.scheduling_mode == "multi_score"
|
||||
_lru_coro = redis_ops.get_lru_scores(pid, key_ids) if _need_lru_sk else None
|
||||
_latency_coro = (
|
||||
redis_ops.batch_get_latency_avgs(pid, key_ids, self.config.latency_window_seconds)
|
||||
if self.config.scheduling_mode == "multi_score"
|
||||
@@ -648,8 +653,9 @@ class PoolManager:
|
||||
pid, session_uuid, key_id, self.config.sticky_session_ttl_seconds
|
||||
)
|
||||
|
||||
# Touch LRU
|
||||
if self.config.lru_enabled:
|
||||
# Touch LRU -- needed for both plain LRU mode and multi_score dimensions
|
||||
# (e.g. cache_affinity) that rely on LRU timestamps.
|
||||
if self.config.lru_enabled or self.config.scheduling_mode == "multi_score":
|
||||
await redis_ops.touch_lru(pid, key_id)
|
||||
|
||||
# Record cost
|
||||
|
||||
Reference in New Issue
Block a user