Baunsgaard commented on code in PR #2019:
URL: https://github.com/apache/systemds/pull/2019#discussion_r1567371448
##########
src/main/java/org/apache/sysds/runtime/util/DoubleBufferingOutputStream.java:
##########
@@ -43,42 +42,49 @@ public DoubleBufferingOutputStream(OutputStream out, int
num, int size) {
super(out);
if(size <= 0)
throw new IllegalArgumentException("Buffer size <= 0.");
- if( size%8 != 0 )
+ if(size % 8 != 0)
throw new IllegalArgumentException("Buffer size not a
multiple of 8.");
_buff = new byte[num][size];
_locks = new Future<?>[num];
- for(int i=0; i<num; i++)
+ for(int i = 0; i < num; i++) // fill the futures to avoid null
pointers.
_locks[i] = ConcurrentUtils.constantFuture(null);
}
@Override
public void write(int b) throws IOException {
- throw new IOException("Not supported");
+ throw new IOException("Not supported");
}
@Override
- public void write(byte[] b, int off, int len)
- throws IOException
- {
+ public void write(byte[] b, int off, int len) throws IOException {
Review Comment:
The code should not modify the handling of tiny arrays, if it does, I made a
mistake.
The change is primarily only addressing the handling of byte[]'s of lengths
that are longer than 8192. (or what we set out BYTE_BUFFER sizes to).
Where is the race condition?
The idea of the pool in this code is to force it into a single async stream
that has one thread allocated to processing (as you designed it) the write task
in seqence outside the 'hot' path.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]