Merge branch '19704-aneta-r-sdk' refs #19704
[arvados.git] / services / fuse / arvados_fuse / fusedir.py
index 8dcde59ec336e2ba4cb872f7a7fbdc2faa755807..f3816c0d3e783b6272c5abcc424641a4bb39d6dc 100644 (file)
@@ -525,7 +525,12 @@ class CollectionDirectory(CollectionDirectoryBase):
                         self.collection.update()
                         new_collection_record = self.collection.api_response()
                     else:
-                        get_threads = max(self.api.keep.block_cache.cache_max // (64 * 1024 * 1024)) - 1, 0)
+                        # If there's too many prefetch threads and you
+                        # max out the CPU, delivering data to the FUSE
+                        # layer actually ends up being slower.
+                        # Experimentally, capping 7 threads seems to
+                        # be a sweet spot.
+                        get_threads = min(max((self.api.keep.block_cache.cache_max // (64 * 1024 * 1024)) - 1, 1), 7)
                         # Create a new collection object
                         if uuid_pattern.match(self.collection_locator):
                             coll_reader = arvados.collection.Collection(
@@ -537,7 +542,6 @@ class CollectionDirectory(CollectionDirectoryBase):
                                 self.collection_locator, self.api, self.api.keep,
                                 num_retries=self.num_retries,
                                 get_threads=get_threads)
-                            )
                         new_collection_record = coll_reader.api_response() or {}
                         # If the Collection only exists in Keep, there will be no API
                         # response.  Fill in the fields we need.