Skip to content

Preserve TLog write bandwidth when disk space caps the queue target - #14672

Draft
tclinkenbeard-oai wants to merge 2 commits into
apple:mainfrom
tclinkenbeard-oai:dev/tclinkenbeard/tlog-disk-spring
Draft

tclinkenbeard-oai wants to merge 2 commits into
apple:mainfrom
tclinkenbeard-oai:dev/tclinkenbeard/tlog-disk-spring

Conversation

@tclinkenbeard-oai

Copy link
Copy Markdown
Collaborator

Ratekeeper subtracts the TLog queue spring from the target to compute the MVCC write bandwidth. When both are capped at the same positive disk headroom, the result is zero even with an empty queue.

Cap the scaled spring at one fifth of the headroom, keeping the one-byte floor. This moves the onset of queue throttling closer to the target under disk pressure. The target ramp, free-space reserve and emergency stop are unchanged.

Compile-time checks cover a constrained spring, an unconstrained spring and exhausted headroom. All 20 simulation cases passed across MinimumThroughput, DiskFailureCycle and LocalRatekeeper. In two additional MinimumThroughput cases with a 12 GB target, an 8 GB spring and throttle start ratios of 5% and 20%, main failed both at 3,020 transactions. This change passed both at 5,887. The simulations had comparable disk headroom but diverged in execution.

@foundationdb-ci

This comment has been minimized.

@foundationdb-ci

This comment has been minimized.

@foundationdb-ci

This comment has been minimized.

@foundationdb-ci

This comment has been minimized.

@foundationdb-ci

This comment has been minimized.

@foundationdb-ci

This comment has been minimized.

@foundationdb-ci

This comment has been minimized.

Shrinking the spring before disk space caps the queue target can raise
the write limit as the disk fills. Limit the reduction in the spring to
the reduction in the target. Check the remaining write budget at and
below the batch target as well as under severe disk pressure.

@tclinkenbeard-oai tclinkenbeard-oai left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated by Codex.

What problem is this PR trying to solve? (ELI10)

Ratekeeper decides how fast transactions can start by checking how much work a transaction log can hold. It sets a queue target and subtracts a cushion called the spring. Imagine a log with 375 MB free above its safety reserve. The old calculation could set both the target and the cushion to 375 MB. That left zero bytes for writes, so a log that had recently received traffic could pause new transactions even with an empty queue. Old disk caps · Old bandwidth calculation

How does this PR solve the problem? (ELI10 and review walkthrough)

With the normal settings, the 375 MB example now gets a 75 MB cushion, leaving 300 MB for writes. The cushion shrinks only as far as the configured write allowance permits.

  1. Ratekeeper subtracts the reserve from the log’s smoothed free space, scales both settings as the disk fills, and caps the queue target at the space above the reserve. Disk measurement and target
  2. The helper starts with the smaller of the scaled spring and one fifth of the capped target. It keeps at least one byte for the spring and raises it if necessary to keep the write budget within the scaled allowance. Spring calculation
  3. The resulting difference sets the point where the queue starts exerting pressure and the bytes allowed over the read transaction lifetime plus two seconds. The separate emergency stop uses the latest disk sample. Proxies enforce the resulting normal and batch rates. Queue pressure and emergency stop · Bandwidth limit · Rates sent to proxies · Proxy admission

What is it trying to do?

Keep transactions moving when disk space limits the log queue, while respecting the write ceiling for each priority.

Is it correct?

Yes. With the batch defaults, the 1,400 MB target and 300 MB spring allow 1,100 MB of writes per window. As usable space falls from 1,500 MB to 1,400 MB, the target still fits and the spring stays at 300 MB. At 1,390 MB the spring falls to 290 MB, keeping the budget at 1,100 MB. For fixed scaled settings, reducing the target can only maintain or lower that budget. At exhaustion the target and spring both reach one byte, giving zero bandwidth. Batch defaults · Budget bound and regression checks

Are there bugs?

I found no correctness bugs in the published revision. The one-byte floor also keeps the queue-pressure divisor positive.

Are there omissions?

The compile-time checks cover the original stall, the batch boundary, and exhaustion. The main residual uncertainty is how quickly queue feedback responds to a burst while the free-space estimate catches up. I reviewed the source without running builds or tests during this review. Public CI was in progress for this head. PR checks

Are there better ways of doing things?

Keeping the bound in the spring calculation gives the queue and bandwidth calculations the same threshold with constant work per log.

Should this CL be LGTMd?

Yes, LGTM.

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-clang-arm on Linux RHEL 9

  • Commit ID: 03e8980
  • Duration 0:48:12
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-clang-ide on Linux RHEL 9

  • Commit ID: 03e8980
  • Duration 2:00:54
  • Result: ❌ FAILED
  • Error: Build has timed out.
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-clang on Linux RHEL 9

  • Commit ID: 03e8980
  • Duration 3:00:46
  • Result: ❌ FAILED
  • Error: Build has timed out.
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr on Linux RHEL 9

  • Commit ID: 03e8980
  • Duration 3:00:57
  • Result: ❌ FAILED
  • Error: Build has timed out.
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-macos on macOS

  • Commit ID: 03e8980
  • Duration 4:10:56
  • Result: ❌ FAILED
  • Error: `Error while executing command: # compatible with bash and zsh
    ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${HOME}/.ssh_key
    -o ServerAliveInterval=9 ec2-user@${MAC_EC2_HOST} "
    set -e -o noclobber
    BUILDNUM=${CODEBUILD_BUILD_NUMBER}
    WAIT_TIME=14400 # 4 hours
    LOCK_STALE=4500 # 75 minutes
    LOCK=/tmp/ci.lock
    "'

macOS stat flags, not linux compatible

lock_mtime() { stat -f %m $LOCK || echo 0 }
I=0
while ! (echo $BUILDNUM >$LOCK) 2>/dev/null ; do
if (( ++I >= WAIT_TIME )); then
echo "timeout waiting for ci.lock after $I seconds"
exit 3
fi
if (( $(date +%s) - $(lock_mtime) >= LOCK_STALE )); then
echo "lock expired after $LOCK_STALE seconds ..."
# racy but sleep so chances are low
sleep $(( 3 + RANDOM % 8 ))
if (( $(date +%s) - $(lock_mtime) >= LOCK_STALE )); then
echo "lock holder is gone"
rm -f $LOCK
else
echo "new lock holder"
fi
fi
sleep 1
done
echo "acquired ci.lock"
'
. Reason: exit status 3`

  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-macos-m1 on macOS

  • Commit ID: 03e8980
  • Duration 4:11:25
  • Result: ❌ FAILED
  • Error: `Error while executing command: # compatible with bash and zsh
    ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${HOME}/.ssh_key
    -o ServerAliveInterval=9 ec2-user@${MAC_EC2_HOST} "
    set -e -o noclobber
    BUILDNUM=${CODEBUILD_BUILD_NUMBER}
    WAIT_TIME=14400 # 4 hours
    LOCK_STALE=4500 # 75 minutes
    LOCK=/tmp/ci.lock
    "'

macOS stat flags, not linux compatible

lock_mtime() { stat -f %m $LOCK || echo 0 }
I=0
while ! (echo $BUILDNUM >$LOCK) 2>/dev/null ; do
if (( ++I >= WAIT_TIME )); then
echo "timeout waiting for ci.lock after $I seconds"
exit 3
fi
if (( $(date +%s) - $(lock_mtime) >= LOCK_STALE )); then
echo "lock expired after $LOCK_STALE seconds ..."
# racy but sleep so chances are low
sleep $(( 3 + RANDOM % 8 ))
if (( $(date +%s) - $(lock_mtime) >= LOCK_STALE )); then
echo "lock holder is gone"
rm -f $LOCK
else
echo "new lock holder"
fi
fi
sleep 1
done
echo "acquired ci.lock"
'
. Reason: exit status 3`

  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-cluster-tests on Linux RHEL 9

  • Commit ID: 03e8980
  • Duration 5:44:08
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)
  • Cluster Test Logs zip file of the test logs (available for 30 days)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants