2
0
mirror of https://github.com/soheilhy/cmux.git synced 2024-09-20 11:05:48 +08:00
Commit Graph

4 Commits

Author SHA1 Message Date
Tamir Duberstein
36dc9894b6 Replace buffer with bufferedReader
bufferedReader is an optimized implementation of io.Reader that behaves
like
```
io.MultiReader(bytes.NewReader(buffer.Bytes()), io.TeeReader(source, buffer))
```
without allocating.

This has a measurable effect on benchmarks:
```
name        old time/op    new time/op    delta
CMuxConn-4    1.09µs ± 4%    0.99µs ±19%   -9.32%  (p=0.000 n=17+19)

name        old alloc/op   new alloc/op   delta
CMuxConn-4      240B ± 0%      260B ± 0%   +8.33%  (p=0.000 n=20+20)

name        old allocs/op  new allocs/op  delta
CMuxConn-4      9.00 ± 0%      5.00 ± 0%  -44.44%  (p=0.000 n=20+20)
```

Note that appropriate test coverage is provided by `TestRead`.
2016-02-26 06:00:06 -05:00
Tamir Duberstein
48443df968 buffer: do not retain passed-in memory
This is in violation of the io.Writer interface specification.
2016-02-25 11:40:31 -05:00
Tamir Duberstein
6490dea199 Reduce the number of calls needed to (*MuxConn).Read
Also affects (*buffer).Read.
2016-02-23 09:49:37 -05:00
Soheil Hassas Yeganeh
fbd0877935 Use a custom buffer intead of buffers from bytes
This commit implements a new buffer that eliminates a few copies.
2015-08-01 11:59:50 -04:00