Skip to content

Conversation

@steveloughran
Copy link
Contributor

HADOOP-19303.

Adds a new method with a release method to

readVectored(List<? extends FileRange> ranges,
IntFunction allocate,
Consumer release)

This is return buffers to pools even in failures.

The default implementation hands back to readVectored/2, so that existing custom implementations of that will get invoked.

S3A, ABFS and HDFS don't do this.

This is the hadoop-common side of #7105, which I'm going to retire to
focus on analytics vector read performance.

Getting the new API into hadoop releases before that means that it is
ready for applications to use, if built against it.

How was this patch tested?

For code changes:

  • Does the title or this PR starts with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')?
  • [=] Object storage: have the integration tests been executed and the endpoint declared according to the connector-specific documentation?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE, LICENSE-binary, NOTICE-binary files?

Adds a new method with a release method too

readVectored(List<? extends FileRange> ranges,
      IntFunction<ByteBuffer> allocate,
      Consumer<ByteBuffer> release)

This is return buffers to pools even in failures.

The default implementation hands back to readVectored/2,
so that existing custom implementations of that will get
invoked.

There is a weakness there: it means implementations which
don't implement readVectored/2 will not have buffer release
working.

Checksum, Buffer and RawLocal all do this.

S3A, ABFS and HDFS don't do this.

Change-Id: I26fa7214014482e39af6a9212d2e30dd0fc6d429
@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 32s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 2 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 40m 29s trunk passed
+1 💚 compile 15m 30s trunk passed with JDK Ubuntu-11.0.26+4-post-Ubuntu-1ubuntu120.04
+1 💚 compile 13m 38s trunk passed with JDK Private Build-1.8.0_442-8u442-b06us1-0ubuntu120.04-b06
+1 💚 checkstyle 1m 17s trunk passed
+1 💚 mvnsite 1m 35s trunk passed
+1 💚 javadoc 1m 16s trunk passed with JDK Ubuntu-11.0.26+4-post-Ubuntu-1ubuntu120.04
+1 💚 javadoc 0m 52s trunk passed with JDK Private Build-1.8.0_442-8u442-b06us1-0ubuntu120.04-b06
+1 💚 spotbugs 2m 32s trunk passed
+1 💚 shadedclient 36m 4s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 54s the patch passed
+1 💚 compile 14m 53s the patch passed with JDK Ubuntu-11.0.26+4-post-Ubuntu-1ubuntu120.04
+1 💚 javac 14m 53s the patch passed
+1 💚 compile 13m 37s the patch passed with JDK Private Build-1.8.0_442-8u442-b06us1-0ubuntu120.04-b06
+1 💚 javac 13m 37s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 1m 13s the patch passed
+1 💚 mvnsite 1m 35s the patch passed
-1 ❌ javadoc 1m 12s /results-javadoc-javadoc-hadoop-common-project_hadoop-common-jdkUbuntu-11.0.26+4-post-Ubuntu-1ubuntu120.04.txt hadoop-common-project_hadoop-common-jdkUbuntu-11.0.26+4-post-Ubuntu-1ubuntu120.04 with JDK Ubuntu-11.0.26+4-post-Ubuntu-1ubuntu120.04 generated 1 new + 0 unchanged - 0 fixed = 1 total (was 0)
+1 💚 javadoc 0m 54s the patch passed with JDK Private Build-1.8.0_442-8u442-b06us1-0ubuntu120.04-b06
+1 💚 spotbugs 2m 39s the patch passed
+1 💚 shadedclient 36m 17s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 14m 49s hadoop-common in the patch passed.
+1 💚 asflicense 1m 4s The patch does not generate ASF License warnings.
203m 55s
Subsystem Report/Notes
Docker ClientAPI=1.48 ServerAPI=1.48 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-7418/1/artifact/out/Dockerfile
GITHUB PR #7418
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux b360fd423f8d 5.15.0-126-generic #136-Ubuntu SMP Wed Nov 6 10:38:22 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / a38d38d
Default Java Private Build-1.8.0_442-8u442-b06us1-0ubuntu120.04-b06
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.26+4-post-Ubuntu-1ubuntu120.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_442-8u442-b06us1-0ubuntu120.04-b06
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-7418/1/testReport/
Max. process+thread count 1560 (vs. ulimit of 5500)
modules C: hadoop-common-project/hadoop-common U: hadoop-common-project/hadoop-common
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-7418/1/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0 https://yetus.apache.org

This message was automatically generated.

@steveloughran
Copy link
Contributor Author

@cnauroth @anujmodi2021 have either of you two implemented the vector read API yet?

I ask as this PR currently maps the readVectored/3 call to the readVectored/2 call unless overridden, so the default implementation will leak buffers on failure, even if a release function is passed in.

If I change it to passing the release call down, then any input stream which implemented readVectored/2 will not have the readVectored/3 call invoking it, unless they override that explicitly too. In this PR, everything in hadoop common does, and I will in S3AInputStream.

I'm just trying to work out the best design for other streams. IF all the implementation are in the hadoop source tree, I can do the overrides there and have a default which does release buffers everywhere else.

channel.read(buffers[i], range.getOffset(), i, asyncHandler);
}
} catch (IOException ioe) {
LOG.debug("Exception occurred during vectored read ", ioe);
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like this was unnecessary. Any failure will automatically be caught in failed() method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is no IOE to be raised any more

* part of their error handling.
* @param ranges the byte ranges to read
* @param allocate the function to allocate ByteBuffer
* @param release the function to release a ByteBuffer.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove "the"

* Implementations SHOULD override this method if they can release buffers as
* part of their error handling.
* @param ranges the byte ranges to read
* @param allocate the function to allocate ByteBuffer
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove "the"

*/
public static final Consumer<ByteBuffer> LOG_BYTE_BUFFER_RELEASED =
(buffer) -> {
LOG.debug("release buffer {}", buffer.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

should we parameterize and add. releasing buffer for range[x-y] ?

* No matter what kind of buffer is requested, the allocation function
* is invoked; that is: the direct flag is ignored.
*/
public final class VectorIOBufferPool implements ByteBufferPool {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this when we have WeakReferencedElasticByteBufferPool ? An actual implementation of release function should call putBuffer() of the WeakReferencedElasticByteBufferPool no?

Copy link
Contributor Author

@steveloughran steveloughran Feb 26, 2025

Choose a reason for hiding this comment

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

I added this as it's a handy way to combine the allocate and release methods into a tuple of oerations; my extended s3a recovery PR used/uses it.

Used this in the RawLocalFS to show how it can be used to pass around the combined allocate/release operations in one parameter

@anmolanmol1234
Copy link
Contributor

@cnauroth @anujmodi2021 have either of you two implemented the vector read API yet?

I ask as this PR currently maps the readVectored/3 call to the readVectored/2 call unless overridden, so the default implementation will leak buffers on failure, even if a release function is passed in.

If I change it to passing the release call down, then any input stream which implemented readVectored/2 will not have the readVectored/3 call invoking it, unless they override that explicitly too. In this PR, everything in hadoop common does, and I will in S3AInputStream.

I'm just trying to work out the best design for other streams. IF all the implementation are in the hadoop source tree, I can do the overrides there and have a default which does release buffers everywhere else.

Hi @steveloughran, I am working on the vectored read API feature from the ABFS driver team. We are still working on the design part of the feature and will pick up the implementation soon.

@steveloughran steveloughran changed the title HADOOP-19303. VectorIO API HADOOP-19303. VectorIO API: support pass-down of a release() operator Feb 24, 2025
@cnauroth
Copy link
Contributor

@cnauroth @anujmodi2021 have either of you two implemented the vector read API yet?
I ask as this PR currently maps the readVectored/3 call to the readVectored/2 call unless overridden, so the default implementation will leak buffers on failure, even if a release function is passed in.
If I change it to passing the release call down, then any input stream which implemented readVectored/2 will not have the readVectored/3 call invoking it, unless they override that explicitly too. In this PR, everything in hadoop common does, and I will in S3AInputStream.
I'm just trying to work out the best design for other streams. IF all the implementation are in the hadoop source tree, I can do the overrides there and have a default which does release buffers everywhere else.

Hi @steveloughran, I am working on the vectored read API feature from the ABFS driver team. We are still working on the design part of the feature and will pick up the implementation soon.

Hello @steveloughran !

GCS has an implementation of vectored read, overriding readVectored/2 here:

https://github.com/GoogleCloudDataproc/hadoop-connectors/blob/master/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleHadoopFSInputStream.java#L176

Implementation details here:

https://github.com/GoogleCloudDataproc/hadoop-connectors/blob/master/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/VectoredIOImpl.java

This is on the master branch and 3.0 release line, which is not yet in mainstream Dataproc use. We don't have vectored read in version 2.2 or earlier.

It sounds like once this change is in a Hadoop release, GCS should plan on picking this up and overriding readVectored/3. Do I have it right?

CC: @arunkumarchacko

}

@Override
public void readVectored(final List<? extends FileRange> ranges,
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* @param allocate the function to allocate ByteBuffer
* @param release the function to release a ByteBuffer.
* @throws IOException any IOE.
* @throws IllegalArgumentException if the any of ranges are invalid, or they overlap.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: seems like some words are out of order. Maybe "if any of the ranges..."?

// Set up all of the futures, so that we can use them if things fail
for(FileRange range: sortedRanges) {
// Set up all of the futures, so that the caller can await on
// their competion.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "completion"

* review comments
* S3AInputStream implements overrides the new method API,
  but not any buffer releases.

Change-Id: Ic01d10499924d2efc945436ea2a508a18d361e4e
Copy link
Contributor

@cnauroth cnauroth left a comment

Choose a reason for hiding this comment

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

+1, pending CI.

Thank you, @steveloughran and @mukund-thakur .

@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 32s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+0 🆗 markdownlint 0m 0s markdownlint was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 2 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 6m 51s Maven dependency ordering for branch
+1 💚 mvninstall 31m 15s trunk passed
+1 💚 compile 15m 27s trunk passed with JDK Ubuntu-11.0.26+4-post-Ubuntu-1ubuntu120.04
+1 💚 compile 13m 38s trunk passed with JDK Private Build-1.8.0_442-8u442-b06us1-0ubuntu120.04-b06
+1 💚 checkstyle 4m 9s trunk passed
+1 💚 mvnsite 2m 33s trunk passed
+1 💚 javadoc 2m 11s trunk passed with JDK Ubuntu-11.0.26+4-post-Ubuntu-1ubuntu120.04
+1 💚 javadoc 1m 42s trunk passed with JDK Private Build-1.8.0_442-8u442-b06us1-0ubuntu120.04-b06
+1 💚 spotbugs 3m 50s trunk passed
+1 💚 shadedclient 34m 42s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 33s Maven dependency ordering for patch
+1 💚 mvninstall 1m 26s the patch passed
+1 💚 compile 14m 46s the patch passed with JDK Ubuntu-11.0.26+4-post-Ubuntu-1ubuntu120.04
+1 💚 javac 14m 46s the patch passed
+1 💚 compile 13m 45s the patch passed with JDK Private Build-1.8.0_442-8u442-b06us1-0ubuntu120.04-b06
+1 💚 javac 13m 45s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 4m 9s the patch passed
+1 💚 mvnsite 2m 32s the patch passed
+1 💚 javadoc 2m 4s the patch passed with JDK Ubuntu-11.0.26+4-post-Ubuntu-1ubuntu120.04
+1 💚 javadoc 1m 43s the patch passed with JDK Private Build-1.8.0_442-8u442-b06us1-0ubuntu120.04-b06
+1 💚 spotbugs 4m 10s the patch passed
+1 💚 shadedclient 35m 49s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 14m 51s hadoop-common in the patch passed.
+1 💚 unit 3m 27s hadoop-aws in the patch passed.
+1 💚 asflicense 1m 17s The patch does not generate ASF License warnings.
221m 23s
Subsystem Report/Notes
Docker ClientAPI=1.48 ServerAPI=1.48 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-7418/2/artifact/out/Dockerfile
GITHUB PR #7418
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets markdownlint
uname Linux c95a4129f5fc 5.15.0-126-generic #136-Ubuntu SMP Wed Nov 6 10:38:22 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 68af618
Default Java Private Build-1.8.0_442-8u442-b06us1-0ubuntu120.04-b06
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.26+4-post-Ubuntu-1ubuntu120.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_442-8u442-b06us1-0ubuntu120.04-b06
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-7418/2/testReport/
Max. process+thread count 1287 (vs. ulimit of 5500)
modules C: hadoop-common-project/hadoop-common hadoop-tools/hadoop-aws U: .
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-7418/2/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0 https://yetus.apache.org

This message was automatically generated.

@steveloughran steveloughran merged commit 1c2a92a into apache:trunk Mar 3, 2025
4 checks passed
steveloughran added a commit that referenced this pull request Mar 5, 2025
…#7418)

The PositionedReadable vector IO API has a new readVectored()
method which takes a release operator as its third argument.

readVectored(List<? extends FileRange> ranges,
      IntFunction<ByteBuffer> allocate,
      Consumer<ByteBuffer> release)

This is return buffers to pools even in failures.

The default implementation hands back to readVectored/2,
so that existing custom implementations of that will get
invoked.

Contributed by Steve Loughran
YanivKunda pushed a commit to YanivKunda/hadoop that referenced this pull request Mar 23, 2025
…apache#7418)

The PositionedReadable vector IO API has a new readVectored()
method which takes a release operator as its third argument.

readVectored(List<? extends FileRange> ranges,
      IntFunction<ByteBuffer> allocate,
      Consumer<ByteBuffer> release)

This is return buffers to pools even in failures.

The default implementation hands back to readVectored/2,
so that existing custom implementations of that will get
invoked.

Contributed by Steve Loughran
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants