mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-17 14:04:52 +02:00
disk-cache: Improve hole management
Make coalescing of neighboring holes robust. Speed up hole finding. Cost is we replace a single array tracking holes with three hashmaps tracking size->[pos] pos->size and endpos->size.
This commit is contained in:
@@ -263,7 +263,7 @@ class TestGraphics(BaseTest):
|
||||
self.assertEqual(sz, dc.size_on_disk())
|
||||
self.assertEqual(holes, {x[1] for x in dc.holes()})
|
||||
self.assertEqual(sz, dc.size_on_disk())
|
||||
# fill holes largest first to ensure small one doesnt go into large accidentally causing fragmentation
|
||||
# fill holes largest first to ensure small one doesn't go into large accidentally causing fragmentation
|
||||
for i, x in enumerate(sorted(holes, reverse=True)):
|
||||
x = 'ABCDEFGH'[i] * x
|
||||
add(x, x)
|
||||
@@ -341,6 +341,17 @@ class TestGraphics(BaseTest):
|
||||
dc.wait_for_write()
|
||||
self.ae(sz, dc.size_on_disk())
|
||||
|
||||
# test hole coalescing
|
||||
reset()
|
||||
for i in range(1, 6):
|
||||
self.assertIsNone(add(i, str(i)*i))
|
||||
dc.wait_for_write()
|
||||
remove(2)
|
||||
remove(4)
|
||||
self.assertEqual(dc.holes(), {(1, 2), (6, 4)})
|
||||
remove(3)
|
||||
self.assertEqual(dc.holes(), {(1, 9)})
|
||||
|
||||
def test_suppressing_gr_command_responses(self):
|
||||
s, g, pl, sl = load_helpers(self)
|
||||
self.ae(pl('abcd', s=10, v=10, q=1), 'ENODATA:Insufficient image data: 4 < 400')
|
||||
|
||||
Reference in New Issue
Block a user