~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/groupcompress.py

  • Committer: John Arbash Meinel
  • Date: 2009-09-01 21:21:53 UTC
  • mto: This revision was merged to the branch mainline in revision 4672.
  • Revision ID: john@arbash-meinel.com-20090901212153-lpuduugn7xvpvanl
An alternative implementation that passes both tests.
Basically, instead of always rebuilding all blocks, just mark blocks
that have a single record as needing to be repacked.
This isn't a great solution, but it is one-step inbetween always rebuild
and never rebuild.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1516
1516
        # test_insert_record_stream_existing_keys fail for groupcompress and
1517
1517
        # groupcompress-nograph, this needs to be revisited while addressing
1518
1518
        # 'bzr branch' performance issues.
1519
 
        for _ in self._insert_record_stream(stream, random_id=False,
1520
 
            reuse_blocks=False):
 
1519
        for _ in self._insert_record_stream(stream, random_id=False):
1521
1520
            pass
1522
1521
 
1523
1522
    def _insert_record_stream(self, stream, random_id=False, nostore_sha=None,
1581
1580
                               ' but then inserted %r two times', record.key)
1582
1581
                    continue
1583
1582
                inserted_keys.add(record.key)
1584
 
            if not inserted_keys and reuse_blocks:
 
1583
            reuse_this_block = reuse_blocks
 
1584
            if reuse_this_block:
1585
1585
                # If the reuse_blocks flag is set, check to see if we can just
1586
1586
                # copy a groupcompress block as-is.
1587
1587
                if record.storage_kind == 'groupcompress-block':
 
1588
                    # Check to see if we really want to re-use this block
 
1589
                    insert_manager = record._manager
 
1590
                    if len(insert_manager._factories) == 1:
 
1591
                        # This block only has a single record in it
 
1592
                        # Mark this block to be rebuilt
 
1593
                        reuse_this_block = False
 
1594
            if reuse_this_block:
 
1595
                # We still want to reuse this block
 
1596
                if record.storage_kind == 'groupcompress-block':
1588
1597
                    # Insert the raw block into the target repo
1589
1598
                    insert_manager = record._manager
1590
 
                    insert_manager._check_rebuild_block()
1591
1599
                    bytes = record._manager._block.to_bytes()
1592
1600
                    _, start, length = self._access.add_raw_records(
1593
1601
                        [(None, len(bytes))], bytes)[0]