You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "keith-turner (via GitHub)" <gi...@apache.org> on 2026/01/13 18:42:20 UTC

[PR] buffer downloads [accumulo-classloaders]

keith-turner opened a new pull request, #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36#discussion_r2687967864


##########
modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java:
##########
@@ -290,12 +292,17 @@ private Path storeResource(final Resource resource) throws IOException {
     }
   }
 
+  private static final int DL_BUFF_SIZE = 1024 * 1024;
+
   private void downloadFile(FileResolver source, Path tempPath, Resource resource) {
     // CREATE_NEW ensures the temporary file name is unique for this attempt
-    // SYNC ensures file integrity on each write, in case of system failure
-    try (var in = source.getInputStream();
-        var out = Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC)) {
+    // SYNC ensures file integrity on each write, in case of system failure. Buffering minimizes
+    // system calls te read/write data which minimizes the number of syncs.
+    try (var in = new BufferedInputStream(source.getInputStream(), DL_BUFF_SIZE);
+        var out = new BufferedOutputStream(Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC),
+            DL_BUFF_SIZE)) {
       in.transferTo(out);
+      out.close();

Review Comment:
   Calling `fsout.getFD().sync()` once does seem better overall, but I was not sure how to get it to work end to end.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36#discussion_r2687653211


##########
modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java:
##########
@@ -290,12 +292,17 @@ private Path storeResource(final Resource resource) throws IOException {
     }
   }
 
+  private static final int DL_BUFF_SIZE = 1024 * 1024;
+
   private void downloadFile(FileResolver source, Path tempPath, Resource resource) {
     // CREATE_NEW ensures the temporary file name is unique for this attempt
-    // SYNC ensures file integrity on each write, in case of system failure
-    try (var in = source.getInputStream();
-        var out = Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC)) {
+    // SYNC ensures file integrity on each write, in case of system failure. Buffering minimizes
+    // system calls te read/write data which minimizes the number of syncs.
+    try (var in = new BufferedInputStream(source.getInputStream(), DL_BUFF_SIZE);
+        var out = new BufferedOutputStream(Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC),
+            DL_BUFF_SIZE)) {
       in.transferTo(out);
+      out.close();

Review Comment:
   I think we should remove the `SYNC` from the method call above and do the following instead.
   
   ```suggestion
         out.close();
         if (out instanceof FileOutputStream) {
           ((FileOutputStream) out).getFD().sync();
         }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36#discussion_r2687718453


##########
modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java:
##########
@@ -290,12 +292,17 @@ private Path storeResource(final Resource resource) throws IOException {
     }
   }
 
+  private static final int DL_BUFF_SIZE = 1024 * 1024;
+
   private void downloadFile(FileResolver source, Path tempPath, Resource resource) {
     // CREATE_NEW ensures the temporary file name is unique for this attempt
-    // SYNC ensures file integrity on each write, in case of system failure
-    try (var in = source.getInputStream();
-        var out = Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC)) {
+    // SYNC ensures file integrity on each write, in case of system failure. Buffering minimizes
+    // system calls te read/write data which minimizes the number of syncs.
+    try (var in = new BufferedInputStream(source.getInputStream(), DL_BUFF_SIZE);
+        var out = new BufferedOutputStream(Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC),
+            DL_BUFF_SIZE)) {
       in.transferTo(out);
+      out.close();

Review Comment:
   I was thinking a `FileOutputStream` is returned when it's a local file, it's just that the interface specifies `OutputStream`. But that might not be correct. Another way to approach it would be to `FileChannel.force` somehow.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on code in PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36#discussion_r2687875181


##########
modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java:
##########
@@ -290,12 +292,17 @@ private Path storeResource(final Resource resource) throws IOException {
     }
   }
 
+  private static final int DL_BUFF_SIZE = 1024 * 1024;
+
   private void downloadFile(FileResolver source, Path tempPath, Resource resource) {
     // CREATE_NEW ensures the temporary file name is unique for this attempt
-    // SYNC ensures file integrity on each write, in case of system failure
-    try (var in = source.getInputStream();
-        var out = Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC)) {
+    // SYNC ensures file integrity on each write, in case of system failure. Buffering minimizes
+    // system calls te read/write data which minimizes the number of syncs.
+    try (var in = new BufferedInputStream(source.getInputStream(), DL_BUFF_SIZE);
+        var out = new BufferedOutputStream(Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC),
+            DL_BUFF_SIZE)) {
       in.transferTo(out);
+      out.close();

Review Comment:
   I merged that in.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36#discussion_r2687720774


##########
modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java:
##########
@@ -290,12 +292,17 @@ private Path storeResource(final Resource resource) throws IOException {
     }
   }
 
+  private static final int DL_BUFF_SIZE = 1024 * 1024;
+
   private void downloadFile(FileResolver source, Path tempPath, Resource resource) {
     // CREATE_NEW ensures the temporary file name is unique for this attempt
-    // SYNC ensures file integrity on each write, in case of system failure
-    try (var in = source.getInputStream();
-        var out = Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC)) {
+    // SYNC ensures file integrity on each write, in case of system failure. Buffering minimizes
+    // system calls te read/write data which minimizes the number of syncs.
+    try (var in = new BufferedInputStream(source.getInputStream(), DL_BUFF_SIZE);
+        var out = new BufferedOutputStream(Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC),
+            DL_BUFF_SIZE)) {
       in.transferTo(out);
+      out.close();

Review Comment:
   I tried the following and build failed because the modenizer plugin wants `File.newOutputStream()`
   
   ```java
    try (var in = new BufferedInputStream(source.getInputStream(), DL_BUFF_SIZE);
           var fsout = new FileOutputStream(tempPath.toFile(), false);
           var out = new BufferedOutputStream(fsout, DL_BUFF_SIZE)) {
         in.transferTo(out);
         out.flush();
         fsout.getFD().sync();
         final String checksum = DIGESTER.digestAsHex(tempPath);
         if (!resource.getChecksum().equals(checksum)) {
           Files.delete(tempPath);
           throw new IllegalStateException(
               "Checksum " + checksum + " for resource " + resource.getLocation()
                   + " does not match checksum in context definition " + resource.getChecksum());
         }
       } catch (IOException e) {
         throw new UncheckedIOException(e);
       }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner merged PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on code in PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36#discussion_r2687676232


##########
modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java:
##########
@@ -290,12 +292,17 @@ private Path storeResource(final Resource resource) throws IOException {
     }
   }
 
+  private static final int DL_BUFF_SIZE = 1024 * 1024;
+
   private void downloadFile(FileResolver source, Path tempPath, Resource resource) {
     // CREATE_NEW ensures the temporary file name is unique for this attempt
-    // SYNC ensures file integrity on each write, in case of system failure
-    try (var in = source.getInputStream();
-        var out = Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC)) {
+    // SYNC ensures file integrity on each write, in case of system failure. Buffering minimizes
+    // system calls te read/write data which minimizes the number of syncs.
+    try (var in = new BufferedInputStream(source.getInputStream(), DL_BUFF_SIZE);
+        var out = new BufferedOutputStream(Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC),
+            DL_BUFF_SIZE)) {
       in.transferTo(out);
+      out.close();

Review Comment:
   This out.close() call here creates a compiler warning. I fixed this differently in #37 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36#discussion_r2687697675


##########
modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java:
##########
@@ -290,12 +292,17 @@ private Path storeResource(final Resource resource) throws IOException {
     }
   }
 
+  private static final int DL_BUFF_SIZE = 1024 * 1024;
+
   private void downloadFile(FileResolver source, Path tempPath, Resource resource) {
     // CREATE_NEW ensures the temporary file name is unique for this attempt
-    // SYNC ensures file integrity on each write, in case of system failure
-    try (var in = source.getInputStream();
-        var out = Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC)) {
+    // SYNC ensures file integrity on each write, in case of system failure. Buffering minimizes
+    // system calls te read/write data which minimizes the number of syncs.
+    try (var in = new BufferedInputStream(source.getInputStream(), DL_BUFF_SIZE);
+        var out = new BufferedOutputStream(Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC),
+            DL_BUFF_SIZE)) {
       in.transferTo(out);
+      out.close();

Review Comment:
   I will remove the close after merging #37 into this.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36#discussion_r2687678852


##########
modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java:
##########
@@ -290,12 +292,17 @@ private Path storeResource(final Resource resource) throws IOException {
     }
   }
 
+  private static final int DL_BUFF_SIZE = 1024 * 1024;
+
   private void downloadFile(FileResolver source, Path tempPath, Resource resource) {
     // CREATE_NEW ensures the temporary file name is unique for this attempt
-    // SYNC ensures file integrity on each write, in case of system failure
-    try (var in = source.getInputStream();
-        var out = Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC)) {
+    // SYNC ensures file integrity on each write, in case of system failure. Buffering minimizes
+    // system calls te read/write data which minimizes the number of syncs.
+    try (var in = new BufferedInputStream(source.getInputStream(), DL_BUFF_SIZE);
+        var out = new BufferedOutputStream(Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC),
+            DL_BUFF_SIZE)) {
       in.transferTo(out);
+      out.close();

Review Comment:
   That does not feel like it guaranteed to always work.  The buffer will significantly reduce the number of syncs done w/ the current code.  Also in the past I have seen good result when wrapping file and network streams w/ buffered streams, so adding the buffers is probably generally good.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36#discussion_r2687687541


##########
modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java:
##########
@@ -290,12 +292,17 @@ private Path storeResource(final Resource resource) throws IOException {
     }
   }
 
+  private static final int DL_BUFF_SIZE = 1024 * 1024;
+
   private void downloadFile(FileResolver source, Path tempPath, Resource resource) {
     // CREATE_NEW ensures the temporary file name is unique for this attempt
-    // SYNC ensures file integrity on each write, in case of system failure
-    try (var in = source.getInputStream();
-        var out = Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC)) {
+    // SYNC ensures file integrity on each write, in case of system failure. Buffering minimizes
+    // system calls te read/write data which minimizes the number of syncs.
+    try (var in = new BufferedInputStream(source.getInputStream(), DL_BUFF_SIZE);
+        var out = new BufferedOutputStream(Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC),
+            DL_BUFF_SIZE)) {
       in.transferTo(out);
+      out.close();

Review Comment:
   Moving the verify after the try w/ resource is much better than closing in the try.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36#discussion_r2687694439


##########
modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java:
##########
@@ -290,12 +292,17 @@ private Path storeResource(final Resource resource) throws IOException {
     }
   }
 
+  private static final int DL_BUFF_SIZE = 1024 * 1024;
+
   private void downloadFile(FileResolver source, Path tempPath, Resource resource) {
     // CREATE_NEW ensures the temporary file name is unique for this attempt
-    // SYNC ensures file integrity on each write, in case of system failure
-    try (var in = source.getInputStream();
-        var out = Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC)) {
+    // SYNC ensures file integrity on each write, in case of system failure. Buffering minimizes
+    // system calls te read/write data which minimizes the number of syncs.
+    try (var in = new BufferedInputStream(source.getInputStream(), DL_BUFF_SIZE);
+        var out = new BufferedOutputStream(Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC),
+            DL_BUFF_SIZE)) {
       in.transferTo(out);
+      out.close();

Review Comment:
   Would need to change how the file stream is created to make that always work.  Can poke at that and see what it looks like.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36#issuecomment-3745989830

   >  I don't think it really helps with anything else, given that the underlying local storage is almost certainly going to be 4K block sizes (most common).
   
   Minimizing system calls can impact performance.  


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36#issuecomment-3746104245

   The buffers are not going to slow things down (the in memory copies they introduce would likely never be the bottle neck vs system calls, network I/O, disk I/O) and they may speed things up.  So this PR may improve performance in some situations, but it probably will  never hinder performance.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] buffer downloads [accumulo-classloaders]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #36:
URL: https://github.com/apache/accumulo-classloaders/pull/36#discussion_r2687967864


##########
modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java:
##########
@@ -290,12 +292,17 @@ private Path storeResource(final Resource resource) throws IOException {
     }
   }
 
+  private static final int DL_BUFF_SIZE = 1024 * 1024;
+
   private void downloadFile(FileResolver source, Path tempPath, Resource resource) {
     // CREATE_NEW ensures the temporary file name is unique for this attempt
-    // SYNC ensures file integrity on each write, in case of system failure
-    try (var in = source.getInputStream();
-        var out = Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC)) {
+    // SYNC ensures file integrity on each write, in case of system failure. Buffering minimizes
+    // system calls te read/write data which minimizes the number of syncs.
+    try (var in = new BufferedInputStream(source.getInputStream(), DL_BUFF_SIZE);
+        var out = new BufferedOutputStream(Files.newOutputStream(tempPath, CREATE_NEW, WRITE, SYNC),
+            DL_BUFF_SIZE)) {
       in.transferTo(out);
+      out.close();

Review Comment:
   Calling `fsout.getFD().sync()` once does seem better overall, but I was not sure how to get to work end to end.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org