Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC4J-606 DFSClient Allow ReadBuffer size to be set #788

Open
wants to merge 4 commits into
base: candidate-9.10.x
Choose a base branch
from

Conversation

jpmcmu
Copy link
Contributor

@jpmcmu jpmcmu commented Jan 17, 2025

  • Created new CircularByteBuffer class
  • Created CircularByteBufferTest
  • Made changes to allow read buffer size to be smaller than the read request size

Signed-off-by: James McMullan [email protected]

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change is a breaking change (fix or feature that will cause existing behavior to change).

Checklist:

  • I have created a corresponding JIRA ticket for this submission
  • My code follows the code style of this project.
    • I have applied the Eclipse code-format template provided.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the HPCC Systems CONTRIBUTORS document (https://github.com/hpcc-systems/HPCC-Platform/wiki/Guide-for-contributors).
  • The change has been fully tested:
    • This change does not cause any existing JUnits to fail.
    • I have include JUnit coverage to test this change
    • I have performed system test and covered possible regressions and side effects.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Premature optimization
    • This change fixes the problem, not just the symptom

Testing:

- Created new CircularByteBuffer class
- Created CircularByteBufferTest
- Made changes to allow read buffer size to be smaller than the read request size

Signed-off-by: James McMullan [email protected]
Copy link

Jira Issue: https://hpccsystems.atlassian.net/browse/HPCC4J-606

Jirabot Action Result:
Workflow Transition To: Merge Pending
Updated PR

@jpmcmu jpmcmu requested a review from rpastrana January 17, 2025 20:04
@@ -0,0 +1,217 @@
/*******************************************************************************
* HPCC SYSTEMS software Copyright (C) 2024 HPCC Systems®.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2025?


public CircularByteBuffer(int bufferSize)
{
buffer = new byte[bufferSize];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are 0 and negative ints ok here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we consider an upper limit as well?

buffer = new byte[bufferSize];
}

public int getCurrentNumberOfBytes()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the meaning of current bytes? I assume this is the number of occupied bytes ? is there a more self documenting name for the method and the member?

return getSpace() > 0;
}

public int getSpace()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getAvailableByteCount?

{
if (currentNumberOfBytes + length > buffer.length)
{
throw new IOException("Not enough space available");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who is the target of the message, and will this be enough information to trivially identify the problem, and formulate a solution?

@@ -1190,28 +1179,6 @@ private void readDataInFetch()
// Loop here while data is being consumed quickly enough
while (remainingDataInCurrentRequest > 0)
{
if (CompileTimeConstants.PROFILE_CODE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what replaces this removed logic? L1219?

dis.readFully(this.readBuffer, currentBufferLen, bytesToRead);
synchronized (readBuffer)
{
// int contiguousCapacity = readBuffer.getContiguousSpace();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we plan to remove the comments?

{
availBytes = readBuffer.getCurrentNumberOfBytes();
}

// Do the check for closed first here to avoid data races
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this old comment mean you shouldn't getcurrentnumberofbytes first?

@@ -0,0 +1,163 @@
/*******************************************************************************
* HPCC SYSTEMS software Copyright (C) 2024 HPCC Systems®.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, but 2025?

import org.junit.experimental.categories.Category;

@Category(org.hpccsystems.commons.annotations.RemoteTests.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just confirming we need to execute the tests in alphabetical order

@jpmcmu jpmcmu marked this pull request as ready for review January 27, 2025 14:56
@jpmcmu jpmcmu changed the base branch from master to candidate-9.10.x January 27, 2025 14:57
Copy link
Member

@rpastrana rpastrana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpmcmu we're very close, I had a couple of questions.

@@ -737,6 +738,15 @@ private void readIntoScratchBuffer(int offset, int dataLen) throws IOException
throw e;
}

if (bytesRead == 0)
{
try
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this just hoping we'll start getting data after the sleep?
Also, is it possible to get stuck in this loop if it doesn't receive any data for a long time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could get stuck in this loop until the socket timeout kicks in. After which the call to read() will either throw an exception or return -1 which will cause an exception to be thrown. (Which case depends on how the socket was closed.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To Rodrigo's point should add an indicator / counter if we get stuck in this loop for a while


public CircularByteBuffer(int bufferSize)
{
buffer = new byte[bufferSize];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we consider an upper limit as well?

if (availBytes == 0)
{
String prefix = "RowServiceInputStream.available(), file " + dataPart.getFileName() + " part " + dataPart.getThisPart() + " on IP " + getIP() + ":";

// this.bufferWriteMutex.release();
IOException wrappedException = new IOException(prefix + "End of input stream, bufferLen:" + bufferLen + ", this.readPos:" + this.readPos + ", availableBytes=0");
IOException wrappedException = new IOException(prefix + "End of input stream");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this enough information for debugger to understand the problem and how to fix?

@@ -1583,50 +1508,11 @@ public void close() throws IOException
@Override
public void mark(int readLim)
{
if (CompileTimeConstants.PROFILE_CODE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we dropping all profiling code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the other profiling code will remain, I removed code that tracking if the buffer mutex was being held for too long because it was no longer useful.

Copy link
Member

@rpastrana rpastrana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpmcmu approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants