Skip to content

Commit be9fb01

Browse files
committed
bp/Instance: discard an exponential number of processes on memory pressure
1 parent f62eb73 commit be9fb01

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

debian/changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cm4all-beng-proxy (21.32) unstable; urgency=low
22

3+
* bp: discard an exponential number of processes on memory pressure
34
* prometheus: add "beng_proxy_stock_total_create_duration"
45
* spawn: eliminate epoll_wait() roundtrip
56

src/bp/Instance.cxx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,11 @@ BpInstance::ReloadState() noexcept
349349
void
350350
BpInstance::OnCgroupPressure(unsigned repeat) noexcept
351351
{
352-
constexpr std::size_t discard_request = 64;
353-
354-
(void)repeat; // TODO use this
352+
/* the number of processes we discard in each call grows
353+
exponentially (but no more than 512 at a time), just in
354+
case we're spawning new processes faster than this method
355+
shuts them down */
356+
const std::size_t discard_request = std::size_t{32} << std::min(repeat, 4U);
355357

356358
std::size_t n = 0;
357359

0 commit comments

Comments
 (0)