Overview
Comment: | Switched encoding/fibonacci.Encoder back to using a 2-bytes array as a preallocated write buffer. It seems that it otherwise escapes everytime and calls a causes a lot of allocations and subsequent gc work. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: | 90877fa64fa2a38e082a8eb74161a9a1f43ffd8d |
User & Date: | spaskalev on 2015-01-11 08:44:26 |
Other Links: | manifest | tags |
Context
2015-01-14
| ||
20:46 | Use for range in mtf's encoder for the position table. check-in: 3ea011cf07 user: spaskalev tags: trunk | |
2015-01-11
| ||
08:44 | Switched encoding/fibonacci.Encoder back to using a 2-bytes array as a preallocated write buffer. It seems that it otherwise escapes everytime and calls a causes a lot of allocations and subsequent gc work. check-in: 90877fa64f user: spaskalev tags: trunk | |
2015-01-10
| ||
21:28 | encoding/mtf optimizations check-in: 5c9c0a2164 user: spaskalev tags: trunk | |
Changes
Modified src/0dev.org/encoding/fibonacci/fib.go from [32c0b16287] to [ad0ff53aaf].
98
99
100
101
102
103
104
105
106
107
108
109
110
111
...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
var enc encoder enc.target = target return &enc } type encoder struct { target io.Writer remaining byte length byte } // Implements io.Writer func (e *encoder) Write(input []byte) (int, error) { var ( ................................................................................ continue } // Clearing e.length is not necessary as it will be overwritten later // Stage the complete byte for writing buffer := make([]byte, 1, 2) buffer[0] = byte(e.remaining) // Stage every full byte from the encoded value for writing // // The bitlength of the largest encoded byte value, 255, is 13. // Even with 7 bits already in the buffer this leaves [7+1], [8] // and 4 bits remaining => a single if is enough instead of a for. |
>
|
|
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
...
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
var enc encoder enc.target = target return &enc } type encoder struct { target io.Writer buffer [2]byte remaining byte length byte } // Implements io.Writer func (e *encoder) Write(input []byte) (int, error) { var ( ................................................................................ continue } // Clearing e.length is not necessary as it will be overwritten later // Stage the complete byte for writing buffer := e.buffer[:1] buffer[0] = byte(e.remaining) // Stage every full byte from the encoded value for writing // // The bitlength of the largest encoded byte value, 255, is 13. // Even with 7 bits already in the buffer this leaves [7+1], [8] // and 4 bits remaining => a single if is enough instead of a for. |