[ARVADOS] updated: b001425779a0189b357c4e3a47734eda6b77ce2d

Git user git at public.curoverse.com
Fri Jan 27 02:13:28 EST 2017


Summary of changes:
 sdk/go/keepclient/collectionreader.go | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

       via  b001425779a0189b357c4e3a47734eda6b77ce2d (commit)
      from  2b37f7a8e843638431dc9e8031c1c2c2a81c1e7e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit b001425779a0189b357c4e3a47734eda6b77ce2d
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Jan 27 02:10:46 2017 -0500

    10990: Adjust readahead to work better on small segments. Improve comments.

diff --git a/sdk/go/keepclient/collectionreader.go b/sdk/go/keepclient/collectionreader.go
index d2a8260..61fabef 100644
--- a/sdk/go/keepclient/collectionreader.go
+++ b/sdk/go/keepclient/collectionreader.go
@@ -72,6 +72,7 @@ type file struct {
 	readaheadDone bool
 }
 
+// Close implements io.Closer.
 func (f *file) Close() error {
 	f.kc = nil
 	f.segments = nil
@@ -79,6 +80,7 @@ func (f *file) Close() error {
 	return nil
 }
 
+// Read implements io.Reader.
 func (f *file) Read(buf []byte) (int, error) {
 	if f.seg == nil || f.offset < f.segStart || f.offset >= f.segStart+int64(f.seg.Len) {
 		// f.seg does not cover the current read offset
@@ -113,16 +115,19 @@ func (f *file) Read(buf []byte) (int, error) {
 		}
 		f.segData = data[f.seg.Offset : f.seg.Offset+f.seg.Len]
 	}
+	// dataOff and dataLen denote a portion of f.segData
+	// corresponding to a portion of the file at f.offset.
 	dataOff := int(f.offset - f.segStart)
 	dataLen := f.seg.Len - dataOff
 
-	if !f.readaheadDone && len(f.segNext) > 0 && f.offset >= 1048576 && dataOff+dataLen >= 1048576 {
+	if !f.readaheadDone && len(f.segNext) > 0 && f.offset >= 1048576 && dataOff+dataLen > len(f.segData)/16 {
 		// If we have already read more than just the first
-		// few bytes of this file, and more than just a few
-		// bytes of this block, and there's more data for this
-		// file in the next segment/block ... then there's a
-		// good chance we are going to want the next block
-		// soon. Start getting it into the cache now.
+		// few bytes of this file, and we have already
+		// consumed a noticeable portion of this segment, and
+		// there's more data for this file in the next segment
+		// ... then there's a good chance we are going to need
+		// the data for that next segment soon. Start getting
+		// it into the cache now.
 		go f.kc.cache().Get(f.kc, f.segNext[0].Locator)
 		f.readaheadDone = true
 	}
@@ -136,6 +141,7 @@ func (f *file) Read(buf []byte) (int, error) {
 	return n, nil
 }
 
+// Seek implements io.Seeker.
 func (f *file) Seek(offset int64, whence int) (int64, error) {
 	var want int64
 	switch whence {
@@ -158,6 +164,7 @@ func (f *file) Seek(offset int64, whence int) (int64, error) {
 	return f.offset, nil
 }
 
+// Len returns the file size in bytes.
 func (f *file) Len() uint64 {
 	return uint64(f.size)
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list