Project

General

Profile

Actions

Bug #3663

closed

[SDKs] Python CollectionReader should return at least one byte to caller per block read from Keep.

Added by Tom Clegg over 9 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Normal
Assigned To:
Tim Pierce
Category:
SDKs
Target version:
Story points:
0.5

Description

The manifest format makes it possible to describe a single file consisting of a small amount of data from each of many large data blocks.
  • "foo.txt consists of the first 4 bytes of 64M blob A, followed by the first 4 bytes of 64M blob B, ..."
When this happens, clients should expect poor performance, but there are two things we should do to make this less painful.
  1. (Big improvement in a future story) Retrieve partial content from Keep. Doing an HTTP request per 4-byte segment will be slow, but much faster than doing an HTTP request and 64MB of disk and network traffic per 4-byte segment!
  2. (Small improvement in this story) After fetching a full (or partial) block from Keep, there is always at least one byte ready to return to the caller. Return the available data to the caller right away. Don't fetch the next block until the next read() call.

This is the offending code in sdk/python/arvados/stream.py:

    def read(self, size):
        """Read up to 'size' bytes from the stream, starting at the current file position""" 
        if size == 0:
            return ''

        data = ''
        for locator, blocksize, segmentoffset, segmentsize in locators_and_ranges(self.segments, self._filepos, size):
            data += self._stream.readfrom(locator+segmentoffset, segmentsize)
        self._filepos += len(data)
        return data

Rather than looping through locators_and_ranges, it should get as much data as it can from the first element of locators_and_ranges, and return that.

This mimics the behavior of io.read(), except that we don't [yet] support the "unspecified size" and "size=-1" shortcuts.

Related: flush outfile after each outfile.write(data) in arv-get.


Subtasks 2 (0 open2 closed)

Task #3816: Review 3663-collection-reader-performanceResolvedTim Pierce09/04/2014Actions
Task #3745: Print output immediately after readResolvedTim Pierce09/04/2014Actions

Related issues

Related to Arvados - Feature #3734: [Keep] Keepstore and keepproxy support HTTP Range requestsNewActions
Actions #1

Updated by Tom Clegg over 9 years ago

  • Description updated (diff)
Actions #2

Updated by Tom Clegg over 9 years ago

  • Category set to SDKs
Actions #3

Updated by Tom Clegg over 9 years ago

  • Description updated (diff)
Actions #4

Updated by Ward Vandewege over 9 years ago

  • Target version changed from Arvados Future Sprints to 2014-09-17 sprint
Actions #5

Updated by Tim Pierce over 9 years ago

  • Assigned To set to Tim Pierce
Actions #6

Updated by Tim Pierce over 9 years ago

  • Status changed from New to In Progress
Actions #7

Updated by Brett Smith over 9 years ago

d070454 looks good to me. Thanks.

Actions #8

Updated by Tim Pierce over 9 years ago

  • Status changed from In Progress to Resolved

Applied in changeset arvados|commit:90fc79852a995fd8e665cf48ae20c49a9bbc78eb.

Actions

Also available in: Atom PDF