Skip to content

Commit

Permalink
hub: set larger write buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed May 1, 2019
1 parent 28824f3 commit 3dc019c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion adc/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var (

const lineDelim = 0x0a

const writeBuffer = 64 * 1024

type Route interface {
WriteMessage(msg Message) error
Flush() error
Expand Down Expand Up @@ -77,7 +79,7 @@ func NewConn(conn net.Conn) (*Conn, error) {
c := &Conn{
conn: conn,
}
c.w = lineproto.NewWriter(conn)
c.w = lineproto.NewWriterSize(conn, writeBuffer)
c.r = lineproto.NewReader(conn, lineDelim)
if Debug {
c.w.OnLine(func(line []byte) (bool, error) {
Expand Down
1 change: 1 addition & 0 deletions cmd/dctor/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ github.com/direct-connect/go-dc v0.6.4/go.mod h1:AwUTf54jhNPJvs+QNHoZxEb3p0LS8ik
github.com/direct-connect/go-dc v0.7.0/go.mod h1:AwUTf54jhNPJvs+QNHoZxEb3p0LS8ik+2t0R8b4+MdI=
github.com/direct-connect/go-dc v0.7.1/go.mod h1:AwUTf54jhNPJvs+QNHoZxEb3p0LS8ik+2t0R8b4+MdI=
github.com/direct-connect/go-dc v0.7.2/go.mod h1:AwUTf54jhNPJvs+QNHoZxEb3p0LS8ik+2t0R8b4+MdI=
github.com/direct-connect/go-dc v0.7.3/go.mod h1:AwUTf54jhNPJvs+QNHoZxEb3p0LS8ik+2t0R8b4+MdI=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.12
require (
github.com/Shopify/go-lua v0.0.0-20181106184032-48449c60c0a9
github.com/beorn7/perks v1.0.0 // indirect
github.com/direct-connect/go-dc v0.7.2
github.com/direct-connect/go-dc v0.7.3
github.com/go-irc/irc v2.1.0+incompatible
github.com/hidal-go/hidalgo v0.0.0-20190420191634-c112d74960ad
github.com/inconshreveable/mousetrap v1.0.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ github.com/direct-connect/go-dc v0.7.1 h1:wb07NZE6pajqAgwqjjQD1Om19zV2J94sxDhalv
github.com/direct-connect/go-dc v0.7.1/go.mod h1:AwUTf54jhNPJvs+QNHoZxEb3p0LS8ik+2t0R8b4+MdI=
github.com/direct-connect/go-dc v0.7.2 h1:tcYyMyW9Nw7OtrVtwUZRXF6SwC9G1Qowcjm63ShstXI=
github.com/direct-connect/go-dc v0.7.2/go.mod h1:AwUTf54jhNPJvs+QNHoZxEb3p0LS8ik+2t0R8b4+MdI=
github.com/direct-connect/go-dc v0.7.3 h1:rLhI/8O50h/8dH2hXew4nmC6Io+grCCd963Pi4s0xuk=
github.com/direct-connect/go-dc v0.7.3/go.mod h1:AwUTf54jhNPJvs+QNHoZxEb3p0LS8ik+2t0R8b4+MdI=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
Expand Down
1 change: 1 addition & 0 deletions hub/plugins/tor/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ github.com/direct-connect/go-dc v0.7.0 h1:lSt/a+VQfyfV9aJ5LDZiSc6SPWAFcD6Rp3KI40
github.com/direct-connect/go-dc v0.7.0/go.mod h1:AwUTf54jhNPJvs+QNHoZxEb3p0LS8ik+2t0R8b4+MdI=
github.com/direct-connect/go-dc v0.7.1/go.mod h1:AwUTf54jhNPJvs+QNHoZxEb3p0LS8ik+2t0R8b4+MdI=
github.com/direct-connect/go-dc v0.7.2/go.mod h1:AwUTf54jhNPJvs+QNHoZxEb3p0LS8ik+2t0R8b4+MdI=
github.com/direct-connect/go-dc v0.7.3/go.mod h1:AwUTf54jhNPJvs+QNHoZxEb3p0LS8ik+2t0R8b4+MdI=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
Expand Down
4 changes: 3 additions & 1 deletion nmdc/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var (
DefaultFallbackEncoding encoding.Encoding
)

const writeBuffer = 64 * 1024

var dialer = net.Dialer{}

// Dial connects to a specified address.
Expand Down Expand Up @@ -78,7 +80,7 @@ func NewConn(conn net.Conn) (*Conn, error) {
c := &Conn{
conn: conn,
}
c.w = nmdc.NewWriter(conn)
c.w = nmdc.NewWriterSize(conn, writeBuffer)
c.r = nmdc.NewReader(conn)
c.r.OnUnknownEncoding = c.onUnknownEncoding
if DefaultFallbackEncoding != nil {
Expand Down

0 comments on commit 3dc019c

Please sign in to comment.