optimize

package
v1.3.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package optimize applies kernel/network tuning for high-throughput, low-latency tunnels. It is used by the "Optimize" menu item and applied automatically behind the Best Performance preset.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(logf func(string), reserve []int)

Apply performs the full optimization with progress output. printf is used so the caller can pass a logging function (e.g. tui printer).

reserve is the set of ports this machine listens on and must keep: they are put in ip_local_reserved_ports so the kernel never hands one out as the source port of an outgoing connection. A port taken that way cannot be bound by the service that owns it, and nothing in the usual listener view shows why — see the note over ip_local_port_range above. Callers pass the tunnels' own ports; nil reserves nothing, which is the old behaviour.

func ApplyQuiet

func ApplyQuiet(reserve []int)

ApplyQuiet runs Apply discarding output — used by the Best Performance flow.

func CleanRAM

func CleanRAM() (beforeMB, afterMB uint64, err error)

CleanRAM flushes system disk caches (drop_caches) and signals the Go runtime to release all unused memory back to the OS. Returns used memory before and after in MB.

func EngineStartupTuning

func EngineStartupTuning() [][2]string

EngineStartupTuning returns the settings a starting tunnel applies, taken from the same table Optimize writes so the two can never disagree again.

func FullTuning

func FullTuning() [][2]string

FullTuning returns everything Optimize applies, so a caller can be checked against it rather than against a second list written by hand.

func WasApplied

func WasApplied() bool

WasApplied reports whether Optimize has ever run on this machine, by the one durable trace it leaves: the sysctl file it owns.

It exists so an update can repair what an older Optimize wrote without applying tuning to a machine that never asked for it. Installing a new version is not consent to have the kernel retuned; rewriting a file this program put there, to values this version believes in, is a different thing and is the only way a server set up before a fix ever receives it — nothing else rewrites that file, so the old values would otherwise outlive every update.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL