[ARVADOS] updated: 1.1.0-28-gd0414ca

Git user git at public.curoverse.com
Mon Oct 16 13:17:01 EDT 2017


Summary of changes:
 sdk/go/keepclient/block_cache.go | 17 +++++++----------
 sdk/go/keepclient/keepclient.go  |  1 +
 services/crunch-run/crunchrun.go | 11 +++++++----
 3 files changed, 15 insertions(+), 14 deletions(-)

       via  d0414ca727006b821b10b25d3920dc0f66400356 (commit)
      from  60e0be49f6fa0e24349635621acb4f7d273064d9 (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 d0414ca727006b821b10b25d3920dc0f66400356
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon Oct 16 13:13:44 2017 -0400

    12447: Simplify BlockCache locking.
    
    Close response body when content-length is missing.
    
    Tweak messages related to crunch-run -memprofile.
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>

diff --git a/sdk/go/keepclient/block_cache.go b/sdk/go/keepclient/block_cache.go
index 5d8daad..e841a00 100644
--- a/sdk/go/keepclient/block_cache.go
+++ b/sdk/go/keepclient/block_cache.go
@@ -18,9 +18,8 @@ type BlockCache struct {
 	// default size (currently 4) is used instead.
 	MaxBlocks int
 
-	cache     map[string]*cacheBlock
-	mtx       sync.Mutex
-	setupOnce sync.Once
+	cache map[string]*cacheBlock
+	mtx   sync.Mutex
 }
 
 const defaultMaxBlocks = 4
@@ -53,9 +52,11 @@ func (c *BlockCache) Sweep() {
 // Get returns data from the cache, first retrieving it from Keep if
 // necessary.
 func (c *BlockCache) Get(kc *KeepClient, locator string) ([]byte, error) {
-	c.setupOnce.Do(c.setup)
 	cacheKey := locator[:32]
 	c.mtx.Lock()
+	if c.cache == nil {
+		c.cache = make(map[string]*cacheBlock)
+	}
 	b, ok := c.cache[cacheKey]
 	if !ok || b.err != nil {
 		b = &cacheBlock{
@@ -93,16 +94,12 @@ func (c *BlockCache) Get(kc *KeepClient, locator string) ([]byte, error) {
 	return b.data, b.err
 }
 
-func (c *BlockCache) setup() {
+func (c *BlockCache) Clear() {
 	c.mtx.Lock()
-	c.cache = make(map[string]*cacheBlock)
+	c.cache = nil
 	c.mtx.Unlock()
 }
 
-func (c *BlockCache) Clear() {
-	c.setup()
-}
-
 type timeSlice []time.Time
 
 func (ts timeSlice) Len() int { return len(ts) }
diff --git a/sdk/go/keepclient/keepclient.go b/sdk/go/keepclient/keepclient.go
index 6ed0d11..cbfad81 100644
--- a/sdk/go/keepclient/keepclient.go
+++ b/sdk/go/keepclient/keepclient.go
@@ -248,6 +248,7 @@ func (kc *KeepClient) getOrHead(method string, locator string) (io.ReadCloser, i
 				}
 			} else if resp.ContentLength < 0 {
 				// Missing Content-Length
+				resp.Body.Close()
 				return nil, 0, "", fmt.Errorf("Missing Content-Length of block")
 			} else {
 				// Success.
diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index 7d5ee7e..b1d3671 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -1434,7 +1434,7 @@ func main() {
 	networkMode := flag.String("container-network-mode", "default",
 		`Set networking mode for container.  Corresponds to Docker network mode (--net).
     	`)
-	memprofile := flag.String("memprofile", "", "write memory profile to `file`")
+	memprofile := flag.String("memprofile", "", "write memory profile to `file` after running container")
 	flag.Parse()
 
 	containerId := flag.Arg(0)
@@ -1484,13 +1484,16 @@ func main() {
 	if *memprofile != "" {
 		f, err := os.Create(*memprofile)
 		if err != nil {
-			log.Fatal("could not create memory profile: ", err)
+			log.Printf("could not create memory profile: ", err)
 		}
 		runtime.GC() // get up-to-date statistics
 		if err := pprof.WriteHeapProfile(f); err != nil {
-			log.Fatal("could not write memory profile: ", err)
+			log.Printf("could not write memory profile: ", err)
+		}
+		closeerr := f.Close()
+		if closeerr != nil {
+			log.Printf("closing memprofile file: ", err)
 		}
-		f.Close()
 	}
 
 	if runerr != nil {

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list