~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-17 18:20:10 UTC
  • mto: This revision was merged to the branch mainline in revision 1888.
  • Revision ID: john@arbash-meinel.com-20060717182010-135040240cc6990b
Cleanup and NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
184
184
    # there is a benefit in just reading.
185
185
    # TODO: jam 20060714 Do some real benchmarking to figure out
186
186
    #       where the biggest benefit between combining reads and
187
 
    #       and seeking is. It should even be possible to do this
188
 
    #       dynamically, by measuring the seek time versus the
189
 
    #       read / data size time. Though for sftp the round trip
190
 
    #       is hidden in the read()
 
187
    #       and seeking is. Consider a runtime auto-tune.
191
188
    _bytes_to_read_before_seek = 0
192
189
 
193
190
    def __init__(self, base):
382
379
                               limit=self._max_readv_combine,
383
380
                               fudge_factor=self._bytes_to_read_before_seek)
384
381
 
385
 
        trans_name = self.__class__.__name__
386
 
        loc = trans_name.find('Transport')
387
 
        if loc != -1:
388
 
            trans_name = trans_name[:loc]
389
 
        short_fname = relpath[:15]
390
382
        # Cache the results, but only until they have been fulfilled
391
383
        data_map = {}
392
384
        for start, size, sublists in coalesced:
396
388
                key = (start+offset, subsize)
397
389
                data_map[key] = data[offset:offset+subsize]
398
390
 
399
 
            # nice for debugging, but really fills the log file
400
 
            # mutter('%s readv of %s collapsed %s offsets =>'
401
 
            #        ' start %s len %s n chunks %s queue size %s',
402
 
            #        trans_name, short_fname, len(offsets),
403
 
            #        start, size, len(sublists), len(data_map))
404
 
 
405
 
            # Now that we've read some data, see if we can yield 
406
 
            # anything back
 
391
            # Now that we've read some data, see if we can yield anything back
407
392
            while offsets:
408
393
                if offsets[-1] not in data_map:
409
 
                    # We can't yield anything yet, the next entry
410
 
                    # isn't ready
 
394
                    # We can't yield anything yet, the next entry isn't ready
411
395
                    break
412
396
                key = offsets.pop()
413
397
                this_data = data_map.pop(key)
414
398
                yield key[0], this_data
415
399
 
416
400
        # If we got here, we should have processed all entries
 
401
        # We don't always reach here if someone is double iterating
417
402
        assert len(offsets) == 0
418
403
 
419
404
    @staticmethod