Don't set the MTU for loopback interfaces.

Setting the MTU for loopback has a huge performance impact on intra-container
traffic. The loopback interface is not an ethernet interface and does not need
the same limit. with this change I see a 4x speedup for loopback throughput.

Docker-DCO-1.1-Signed-off-by: Tim Hockin <thockin@google.com> (github: thockin)
This commit is contained in:
Tim Hockin 2014-07-15 00:50:54 +00:00
parent 65c37a84af
commit d25aa3cee7
2 changed files with 2 additions and 3 deletions

View File

@ -15,9 +15,7 @@ func (l *Loopback) Create(n *Network, nspid int, networkState *NetworkState) err
} }
func (l *Loopback) Initialize(config *Network, networkState *NetworkState) error { func (l *Loopback) Initialize(config *Network, networkState *NetworkState) error {
if err := SetMtu("lo", config.Mtu); err != nil { // Do not set the MTU on the loopback interface - use the default.
return fmt.Errorf("set lo mtu to %d %s", config.Mtu, err)
}
if err := InterfaceUp("lo"); err != nil { if err := InterfaceUp("lo"); err != nil {
return fmt.Errorf("lo up %s", err) return fmt.Errorf("lo up %s", err)
} }

View File

@ -25,6 +25,7 @@ type Network struct {
// Mtu sets the mtu value for the interface and will be mirrored on both the host and // Mtu sets the mtu value for the interface and will be mirrored on both the host and
// container's interfaces if a pair is created, specifically in the case of type veth // container's interfaces if a pair is created, specifically in the case of type veth
// Note: This does not apply to loopback interfaces.
Mtu int `json:"mtu,omitempty"` Mtu int `json:"mtu,omitempty"`
} }