Skip to content

Commit

Permalink
fix: fix pb dc alloc query (#1709)
Browse files Browse the repository at this point in the history
<!-- Please make sure there is an issue that this PR is correlated to. -->

## Changes
Fixes RVT-4455
<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
MasterPtato committed Jan 2, 2025
1 parent 3e040c7 commit f540dfb
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions packages/services/pegboard/src/workflows/datacenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ async fn allocate_actor(
"allocating actor"
);

// TODO(RVT-4455): Validate this isolate vs container logic
// Even though isolates autoscale based on CPU, we allocate machines based on reservation in
// balance proactively. Otherwise, we'd end up with bad scaling with retroactively choosing
// nodes based on CPU load since actors will show the CPU load after a delay.
Expand Down Expand Up @@ -173,23 +172,25 @@ async fn allocate_actor(
SELECT $3, client_id, $4, $5
FROM available_clients
WHERE
-- Containers: ensure has available resources
-- Isolates: don't limit resources for isolates since they scale on CPU
$8 = 1 OR
(
allocated_cpu + $6 <= available_cpu AND
allocated_memory + $7 <= available_memory
)
-- Container: binpack to the most-populated node to maximize density
-- Isolate: allocate to the least-allocated machine since we autoscale on CPU
-- Containers (0): ensure node has available resources
-- Isolates (1): don't limit resources since they scale on CPU
CASE WHEN $8 = 0
THEN (
allocated_cpu + $6 <= available_cpu AND
allocated_memory + $7 <= available_memory
)
ELSE TRUE
END
ORDER BY
CASE
WHEN $8 = 0 THEN -allocated_cpu
ELSE available_cpu
END ASC,
CASE
WHEN $8 = 0 THEN -allocated_memory
ELSE available_memory
-- Container (0): binpack to the most-populated node to maximize density
-- Isolate (1): allocate to the least-populated node since we autoscale on CPU
CASE WHEN $8 = 0
THEN allocated_cpu
ELSE -allocated_cpu
END DESC,
CASE WHEN $8 = 0
THEN allocated_memory
ELSE -allocated_memory
END DESC
LIMIT 1
RETURNING client_id
Expand Down

0 comments on commit f540dfb

Please sign in to comment.