Make PreallocatedBuffersPerPool runtime-configurable#14
Open
Make PreallocatedBuffersPerPool runtime-configurable#14
Conversation
Author
|
@coderabbitai review |
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes WireGuard per-Device memory knobs runtime-configurable for embedded scenarios that create many Devices in one process.
PreallocatedBuffersPerPoolfromconsttovaron all platforms. Defaults preserved: 0 on default/windows, 4096 on android, 1024 on ios.SetPreallocatedBuffersPerPool(n uint32)to set the default for newly-created Devices.(*Device).SetPreallocatedBuffersPerPool(n uint32)and(*WaitPool).SetMax(n uint32)to retune live Devices in place. Waiters are broadcast so they re-check against the new cap.MaxBatchSizeOverrideglobal and(*Device).SetMaxBatchSize(n int)to control the per-Device batch size used byRoutineReceiveIncomingandRoutineReadFromTUN. Each of those goroutines eagerly allocatesbatchmessage buffers for its lifetime, so this knob bounds the steady-state per-Device buffer footprint. Zero means "no override" (Devices fall back tomax(bind.BatchSize(), tun.BatchSize())); zero is NOT unlimited.Device.BatchSize()now honors the override and is used uniformly on both the receive and TUN-read paths.max == 0: Get/Put skip the lock, andSetMaxis a no-op. Upstream default behavior is unchanged for callers that never set these knobs.