38
39
number of times we will try.
39
40
In testing, some values for bzr.dev::
41
w/o copy w/ copy w/ copy ins w/ copy & save
42
repack time MB time MB time MB time MB
43
1 8.8 5.1 8.9 5.1 9.6 4.4 12.5 4.1
44
2 9.6 4.4 10.1 4.3 10.4 4.2 11.1 4.1
45
3 10.6 4.2 11.1 4.1 11.2 4.1 11.3 4.1
48
20 12.9 4.1 12.2 4.1 12.3 4.1
42
repack time MB hit_max_repack buffer_full
50
49
In testing, some values for mysql-unpacked::
52
w/o copy w/ copy w/ copy ins w/ copy & save
53
repack time MB time MB time MB time MB
55
2 59.3 14.1 62.6 13.5 64.3 13.4
51
repack time MB hit_max_repack buffer_full
59
58
:cvar _default_min_compression_size: The expected minimum compression.
60
59
While packing nodes into the page, we won't Z_SYNC_FLUSH until we have
162
161
self.bytes_in.append(bytes)
163
162
self.seen_bytes = next_seen_size
165
if self.num_repack >= self._max_repack and not reserved:
166
# We already know we don't want to try to fit more
164
if self.num_repack > self._max_repack and not reserved:
165
self.unused_bytes = bytes
168
167
# This may or may not fit, try to add it with Z_SYNC_FLUSH
169
168
out = comp.compress(bytes)
172
171
self.bytes_list.append(out)
173
172
self.bytes_out_len += len(out)
174
if self.bytes_out_len + 10 > capacity:
173
if self.bytes_out_len + 10 <= capacity:
174
# It fit, so mark it added
175
self.bytes_in.append(bytes)
176
self.seen_bytes = next_seen_size
175
178
# We are over budget, try to squeeze this in without any
176
179
# Z_SYNC_FLUSH calls
177
180
self.num_repack += 1
178
bytes_out, this_len, compressor = self._recompress_all_bytes_in(bytes)
181
(bytes_out, this_len,
182
compressor) = self._recompress_all_bytes_in(bytes)
183
if self.num_repack >= self._max_repack:
184
# When we get *to* _max_repack, bump over so that the
185
# earlier > _max_repack will be triggered.
179
188
if this_len + 10 > capacity:
180
# No way we can add anymore, we need to re-pack because our
181
# compressor is now out of sync.
182
# This seems to be rarely triggered over
183
# num_repack > _max_repack
184
bytes_out, this_len, compressor = self._recompress_all_bytes_in()
189
# In real-world testing, this only happens when _max_repack
190
# is set >2, and even then rarely (46 out of 1022)
191
(bytes_out, this_len,
192
compressor) = self._recompress_all_bytes_in()
185
194
self.compressor = compressor
186
195
self.bytes_list = bytes_out
187
196
self.bytes_out_len = this_len
191
200
# This fits when we pack it tighter, so use the new packing
192
201
# There is one Z_SYNC_FLUSH call in
193
202
# _recompress_all_bytes_in
194
204
self.compressor = compressor
195
205
self.bytes_in.append(bytes)
196
206
self.bytes_list = bytes_out
197
207
self.bytes_out_len = this_len
199
# It fit, so mark it added
200
self.bytes_in.append(bytes)
201
self.seen_bytes = next_seen_size