refactor: rename wanted_trimmed_bytes to evict_bytes

This commit is contained in:
Christian Schwarz
2023-03-20 16:40:03 +01:00
parent 5aef192bf2
commit 5015194b40
3 changed files with 12 additions and 12 deletions

View File

@@ -37,15 +37,15 @@ paths:
schema:
type: object
required:
- wanted_trimmed_bytes
- evict_bytes
properties:
wanted_trimmed_bytes:
evict_bytes:
type: integer
responses:
"200":
description: |
The run completed.
This does not necessarily mean that we actually evicted `wanted_trimmed_bytes`.
This does not necessarily mean that we actually evicted `evict_bytes`.
Examine the returned object for detail, or, just watch the actual effect of the call using `du` or `df`.
content:
application/json:

View File

@@ -1205,19 +1205,19 @@ async fn disk_usage_eviction_run(mut r: Request<Body>) -> Result<Response<Body>,
#[derive(serde::Deserialize)]
struct Config {
/// How much to trim at minimum
wanted_trimmed_bytes: u64,
/// How many bytes to evict before reporting that pressure is relieved.
evict_bytes: u64,
}
#[derive(Debug, Clone, Copy, serde::Serialize)]
struct Usage {
wanted_trimmed_bytes: u64,
evict_bytes: u64,
freed_bytes: u64,
}
impl crate::disk_usage_eviction_task::Usage for Usage {
fn has_pressure(&self) -> bool {
self.wanted_trimmed_bytes > self.freed_bytes
self.evict_bytes > self.freed_bytes
}
fn add_available_bytes(&mut self, bytes: u64) {
@@ -1230,7 +1230,7 @@ async fn disk_usage_eviction_run(mut r: Request<Body>) -> Result<Response<Body>,
.map_err(|_| ApiError::BadRequest(anyhow::anyhow!("invalid JSON body")))?;
let usage = Usage {
wanted_trimmed_bytes: config.wanted_trimmed_bytes,
evict_bytes: config.evict_bytes,
freed_bytes: 0,
};

View File

@@ -166,7 +166,7 @@ def test_pageserver_evicts_until_pressure_is_relieved(eviction_env: EvictionEnv)
target = total_on_disk // 2
response = pageserver_http.disk_usage_eviction_run({"wanted_trimmed_bytes": target})
response = pageserver_http.disk_usage_eviction_run({"evict_bytes": target})
log.info(f"{response}")
(later_total_on_disk, _, _) = env.timelines_du()
@@ -211,7 +211,7 @@ def test_pageserver_respects_overridden_resident_size(eviction_env: EvictionEnv)
ps_http.set_tenant_config(large_tenant[0], {"min_resident_size_override": min_resident_size})
# do one run
response = ps_http.disk_usage_eviction_run({"wanted_trimmed_bytes": target})
response = ps_http.disk_usage_eviction_run({"evict_bytes": target})
log.info(f"{response}")
time.sleep(1) # give log time to flush
@@ -251,7 +251,7 @@ def test_pageserver_falls_back_to_global_lru(eviction_env: EvictionEnv):
(total_on_disk, _, _) = env.timelines_du()
target = total_on_disk
response = ps_http.disk_usage_eviction_run({"wanted_trimmed_bytes": target})
response = ps_http.disk_usage_eviction_run({"evict_bytes": target})
log.info(f"{response}")
(later_total_on_disk, _, _) = env.timelines_du()
@@ -281,7 +281,7 @@ def test_partial_evict_tenant(eviction_env: EvictionEnv):
env.pg_bin.run(["pgbench", "-S" , pg.connstr()])
target = total_on_disk - (tenant_usage//2)
response = ps_http.disk_usage_eviction_run({"wanted_trimmed_bytes": target})
response = ps_http.disk_usage_eviction_run({"evict_bytes": target})
log.info(f"{response}")
(later_total_on_disk, _, _) = env.timelines_du()