You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/02/20 14:11:23 UTC

[GitHub] [flink] azagrebin opened a new pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

azagrebin opened a new pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160
 
 
   ## What is the purpose of the change
   
   If we use reflection to create a DirectByteBuffer to wrap unsafe native memory allocations, it causes illegal access warnings in Java9+.
   
   This PR changes this to use Unsafe to instantiate a DirectByteBuffer. The address and capacity fields are set by direct unsafe memory operations. Other fields are set by calling ByteBuffer#clear at the end.
   Unsafe operations skips the illegal access verification and do not result in warnings. The same approach is used to get the address field.
   
   This solution still relies on Unsafe which is about to be removed in future Java releases. If it is removed and we still do not want to contribute to direct memory by allocating native managed memory, we will have to find an alternative solution, like e.g. writing a custom native allocator and use JNI API to instantiate the wrapping DirectByteBuffer (NewDirectByteBuffer in C).
   
   ## Verifying this change
   
   unit tests
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot commented on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
flinkbot commented on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#issuecomment-589090746
 
 
   <!--
   Meta data
   Hash:6d106f671d59bbf63b071d48001e40d724796747 Status:UNKNOWN URL:TBD TriggerType:PUSH TriggerID:6d106f671d59bbf63b071d48001e40d724796747
   -->
   ## CI report:
   
   * 6d106f671d59bbf63b071d48001e40d724796747 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot commented on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
flinkbot commented on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#issuecomment-589069247
 
 
   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit 6d106f671d59bbf63b071d48001e40d724796747 (Thu Feb 20 14:15:27 UTC 2020)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] azagrebin commented on a change in pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
azagrebin commented on a change in pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#discussion_r383745874
 
 

 ##########
 File path: flink-core/src/main/java/org/apache/flink/core/memory/MemoryUtils.java
 ##########
 @@ -60,32 +63,31 @@
 		}
 	}
 
-	/** Should not be instantiated. */
-	private MemoryUtils() {}
-
-	private static Constructor<? extends ByteBuffer> getDirectBufferPrivateConstructor() {
+	private static long getClassFieldOffset(@SuppressWarnings("SameParameterValue") Class<?> cl, String fieldName) {
+		final String errorMessage = "Could not get field '" + fieldName + "' offset in class '" + cl + "' for unsafe operations";
 		try {
-			Constructor<? extends ByteBuffer> constructor =
-				ByteBuffer.allocateDirect(1).getClass().getDeclaredConstructor(long.class, int.class);
-			constructor.setAccessible(true);
-			return constructor;
-		} catch (NoSuchMethodException e) {
-			throw new Error(
-				"The private constructor java.nio.DirectByteBuffer.<init>(long, int) is not available.",
-				e);
+			return UNSAFE.objectFieldOffset(cl.getDeclaredField(fieldName));
 		} catch (SecurityException e) {
-			throw new Error(
-				"The private constructor java.nio.DirectByteBuffer.<init>(long, int) is not available, " +
-					"permission denied by security manager",
-				e);
+			throw new Error(errorMessage + ", permission denied by security manager.", e);
+		} catch (NoSuchFieldException e) {
+			throw new Error(errorMessage, e);
 		} catch (Throwable t) {
-			throw new Error(
-				"Unclassified error while trying to access private constructor " +
-					"java.nio.DirectByteBuffer.<init>(long, int).",
-				t);
+			throw new Error(errorMessage + ", unclassified error", t);
+		}
+	}
+
+	private static Class<?> getClassByName(@SuppressWarnings("SameParameterValue") String className) {
+		//noinspection OverlyBroadCatchBlock
+		try {
+			return Class.forName(className);
+		} catch (Throwable e) {
 
 Review comment:
   Indeed, I overlooked that while copying

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#issuecomment-589090746
 
 
   <!--
   Meta data
   Hash:6d106f671d59bbf63b071d48001e40d724796747 Status:PENDING URL:https://travis-ci.com/flink-ci/flink/builds/149828412 TriggerType:PUSH TriggerID:6d106f671d59bbf63b071d48001e40d724796747
   Hash:9d19f3425c2f4c3b523681e463ef32a95a44f7e5 Status:UNKNOWN URL:TBD TriggerType:PUSH TriggerID:9d19f3425c2f4c3b523681e463ef32a95a44f7e5
   -->
   ## CI report:
   
   * 6d106f671d59bbf63b071d48001e40d724796747 Travis: [PENDING](https://travis-ci.com/flink-ci/flink/builds/149828412) 
   * 9d19f3425c2f4c3b523681e463ef32a95a44f7e5 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#issuecomment-589090746
 
 
   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "6d106f671d59bbf63b071d48001e40d724796747",
       "status" : "DELETED",
       "url" : "https://travis-ci.com/flink-ci/flink/builds/149828412",
       "triggerID" : "6d106f671d59bbf63b071d48001e40d724796747",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d19f3425c2f4c3b523681e463ef32a95a44f7e5",
       "status" : "SUCCESS",
       "url" : "https://travis-ci.com/flink-ci/flink/builds/149851383",
       "triggerID" : "9d19f3425c2f4c3b523681e463ef32a95a44f7e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d19f3425c2f4c3b523681e463ef32a95a44f7e5",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5383",
       "triggerID" : "9d19f3425c2f4c3b523681e463ef32a95a44f7e5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 9d19f3425c2f4c3b523681e463ef32a95a44f7e5 Travis: [SUCCESS](https://travis-ci.com/flink-ci/flink/builds/149851383) Azure: [SUCCESS](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5383) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] tillrohrmann commented on a change in pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
tillrohrmann commented on a change in pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#discussion_r383185284
 
 

 ##########
 File path: flink-core/src/main/java/org/apache/flink/core/memory/MemoryUtils.java
 ##########
 @@ -60,32 +63,31 @@
 		}
 	}
 
-	/** Should not be instantiated. */
-	private MemoryUtils() {}
-
-	private static Constructor<? extends ByteBuffer> getDirectBufferPrivateConstructor() {
+	private static long getClassFieldOffset(@SuppressWarnings("SameParameterValue") Class<?> cl, String fieldName) {
+		final String errorMessage = "Could not get field '" + fieldName + "' offset in class '" + cl + "' for unsafe operations";
 		try {
-			Constructor<? extends ByteBuffer> constructor =
-				ByteBuffer.allocateDirect(1).getClass().getDeclaredConstructor(long.class, int.class);
-			constructor.setAccessible(true);
-			return constructor;
-		} catch (NoSuchMethodException e) {
-			throw new Error(
-				"The private constructor java.nio.DirectByteBuffer.<init>(long, int) is not available.",
-				e);
+			return UNSAFE.objectFieldOffset(cl.getDeclaredField(fieldName));
 		} catch (SecurityException e) {
-			throw new Error(
-				"The private constructor java.nio.DirectByteBuffer.<init>(long, int) is not available, " +
-					"permission denied by security manager",
-				e);
+			throw new Error(errorMessage + ", permission denied by security manager.", e);
+		} catch (NoSuchFieldException e) {
+			throw new Error(errorMessage, e);
 		} catch (Throwable t) {
-			throw new Error(
-				"Unclassified error while trying to access private constructor " +
-					"java.nio.DirectByteBuffer.<init>(long, int).",
-				t);
+			throw new Error(errorMessage + ", unclassified error", t);
+		}
+	}
+
+	private static Class<?> getClassByName(@SuppressWarnings("SameParameterValue") String className) {
+		//noinspection OverlyBroadCatchBlock
+		try {
+			return Class.forName(className);
+		} catch (Throwable e) {
+			throw new Error("Could not find class '" + className + "' for unsafe operations.", e);
 		}
 	}
 
+	/** Should not be instantiated. */
+	private MemoryUtils() {}
 
 Review comment:
   I would put the constructor at the beginning or the end but not somewhere in the middle.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#issuecomment-589090746
 
 
   <!--
   Meta data
   Hash:6d106f671d59bbf63b071d48001e40d724796747 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/149828412 TriggerType:PUSH TriggerID:6d106f671d59bbf63b071d48001e40d724796747
   Hash:9d19f3425c2f4c3b523681e463ef32a95a44f7e5 Status:PENDING URL:https://travis-ci.com/flink-ci/flink/builds/149851383 TriggerType:PUSH TriggerID:9d19f3425c2f4c3b523681e463ef32a95a44f7e5
   -->
   ## CI report:
   
   * 6d106f671d59bbf63b071d48001e40d724796747 Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/149828412) 
   * 9d19f3425c2f4c3b523681e463ef32a95a44f7e5 Travis: [PENDING](https://travis-ci.com/flink-ci/flink/builds/149851383) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] tillrohrmann commented on a change in pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
tillrohrmann commented on a change in pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#discussion_r383184923
 
 

 ##########
 File path: flink-core/src/main/java/org/apache/flink/core/memory/MemoryUtils.java
 ##########
 @@ -60,32 +63,31 @@
 		}
 	}
 
-	/** Should not be instantiated. */
-	private MemoryUtils() {}
-
-	private static Constructor<? extends ByteBuffer> getDirectBufferPrivateConstructor() {
+	private static long getClassFieldOffset(@SuppressWarnings("SameParameterValue") Class<?> cl, String fieldName) {
+		final String errorMessage = "Could not get field '" + fieldName + "' offset in class '" + cl + "' for unsafe operations";
 		try {
-			Constructor<? extends ByteBuffer> constructor =
-				ByteBuffer.allocateDirect(1).getClass().getDeclaredConstructor(long.class, int.class);
-			constructor.setAccessible(true);
-			return constructor;
-		} catch (NoSuchMethodException e) {
-			throw new Error(
-				"The private constructor java.nio.DirectByteBuffer.<init>(long, int) is not available.",
-				e);
+			return UNSAFE.objectFieldOffset(cl.getDeclaredField(fieldName));
 		} catch (SecurityException e) {
-			throw new Error(
-				"The private constructor java.nio.DirectByteBuffer.<init>(long, int) is not available, " +
-					"permission denied by security manager",
-				e);
+			throw new Error(errorMessage + ", permission denied by security manager.", e);
+		} catch (NoSuchFieldException e) {
+			throw new Error(errorMessage, e);
 		} catch (Throwable t) {
-			throw new Error(
-				"Unclassified error while trying to access private constructor " +
-					"java.nio.DirectByteBuffer.<init>(long, int).",
-				t);
+			throw new Error(errorMessage + ", unclassified error", t);
+		}
+	}
+
+	private static Class<?> getClassByName(@SuppressWarnings("SameParameterValue") String className) {
+		//noinspection OverlyBroadCatchBlock
+		try {
+			return Class.forName(className);
+		} catch (Throwable e) {
 
 Review comment:
   Why don't we only catch `ClassNotFoundException` here?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#issuecomment-589090746
 
 
   <!--
   Meta data
   Hash:6d106f671d59bbf63b071d48001e40d724796747 Status:CANCELED URL:https://travis-ci.com/flink-ci/flink/builds/149828412 TriggerType:PUSH TriggerID:6d106f671d59bbf63b071d48001e40d724796747
   Hash:9d19f3425c2f4c3b523681e463ef32a95a44f7e5 Status:SUCCESS URL:https://travis-ci.com/flink-ci/flink/builds/149851383 TriggerType:PUSH TriggerID:9d19f3425c2f4c3b523681e463ef32a95a44f7e5
   Hash:9d19f3425c2f4c3b523681e463ef32a95a44f7e5 Status:SUCCESS URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5383 TriggerType:PUSH TriggerID:9d19f3425c2f4c3b523681e463ef32a95a44f7e5
   -->
   ## CI report:
   
   * 6d106f671d59bbf63b071d48001e40d724796747 Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/149828412) 
   * 9d19f3425c2f4c3b523681e463ef32a95a44f7e5 Travis: [SUCCESS](https://travis-ci.com/flink-ci/flink/builds/149851383) Azure: [SUCCESS](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5383) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] azagrebin commented on a change in pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
azagrebin commented on a change in pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#discussion_r383747665
 
 

 ##########
 File path: flink-core/src/main/java/org/apache/flink/core/memory/MemoryUtils.java
 ##########
 @@ -60,32 +63,31 @@
 		}
 	}
 
-	/** Should not be instantiated. */
-	private MemoryUtils() {}
-
-	private static Constructor<? extends ByteBuffer> getDirectBufferPrivateConstructor() {
+	private static long getClassFieldOffset(@SuppressWarnings("SameParameterValue") Class<?> cl, String fieldName) {
+		final String errorMessage = "Could not get field '" + fieldName + "' offset in class '" + cl + "' for unsafe operations";
 		try {
-			Constructor<? extends ByteBuffer> constructor =
-				ByteBuffer.allocateDirect(1).getClass().getDeclaredConstructor(long.class, int.class);
-			constructor.setAccessible(true);
-			return constructor;
-		} catch (NoSuchMethodException e) {
-			throw new Error(
-				"The private constructor java.nio.DirectByteBuffer.<init>(long, int) is not available.",
-				e);
+			return UNSAFE.objectFieldOffset(cl.getDeclaredField(fieldName));
 		} catch (SecurityException e) {
-			throw new Error(
-				"The private constructor java.nio.DirectByteBuffer.<init>(long, int) is not available, " +
-					"permission denied by security manager",
-				e);
+			throw new Error(errorMessage + ", permission denied by security manager.", e);
+		} catch (NoSuchFieldException e) {
+			throw new Error(errorMessage, e);
 		} catch (Throwable t) {
-			throw new Error(
-				"Unclassified error while trying to access private constructor " +
-					"java.nio.DirectByteBuffer.<init>(long, int).",
-				t);
+			throw new Error(errorMessage + ", unclassified error", t);
+		}
+	}
+
+	private static Class<?> getClassByName(@SuppressWarnings("SameParameterValue") String className) {
+		//noinspection OverlyBroadCatchBlock
+		try {
+			return Class.forName(className);
+		} catch (Throwable e) {
+			throw new Error("Could not find class '" + className + "' for unsafe operations.", e);
 		}
 	}
 
+	/** Should not be instantiated. */
+	private MemoryUtils() {}
 
 Review comment:
   True, overlooked that, we change the git history of the lines anyways

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#issuecomment-589090746
 
 
   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "6d106f671d59bbf63b071d48001e40d724796747",
       "status" : "CANCELED",
       "url" : "https://travis-ci.com/flink-ci/flink/builds/149828412",
       "triggerID" : "6d106f671d59bbf63b071d48001e40d724796747",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d19f3425c2f4c3b523681e463ef32a95a44f7e5",
       "status" : "SUCCESS",
       "url" : "https://travis-ci.com/flink-ci/flink/builds/149851383",
       "triggerID" : "9d19f3425c2f4c3b523681e463ef32a95a44f7e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d19f3425c2f4c3b523681e463ef32a95a44f7e5",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5383",
       "triggerID" : "9d19f3425c2f4c3b523681e463ef32a95a44f7e5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 6d106f671d59bbf63b071d48001e40d724796747 Travis: [CANCELED](https://travis-ci.com/flink-ci/flink/builds/149828412) 
   * 9d19f3425c2f4c3b523681e463ef32a95a44f7e5 Travis: [SUCCESS](https://travis-ci.com/flink-ci/flink/builds/149851383) Azure: [SUCCESS](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=5383) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] azagrebin commented on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
azagrebin commented on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#issuecomment-590765694
 
 
   Thanks for the review @tillrohrmann 
   I have addressed the comments, merging 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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] azagrebin closed pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
azagrebin closed pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] azagrebin commented on a change in pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
azagrebin commented on a change in pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#discussion_r383744901
 
 

 ##########
 File path: flink-core/src/main/java/org/apache/flink/core/memory/MemoryUtils.java
 ##########
 @@ -60,32 +63,31 @@
 		}
 	}
 
-	/** Should not be instantiated. */
-	private MemoryUtils() {}
-
-	private static Constructor<? extends ByteBuffer> getDirectBufferPrivateConstructor() {
+	private static long getClassFieldOffset(@SuppressWarnings("SameParameterValue") Class<?> cl, String fieldName) {
+		final String errorMessage = "Could not get field '" + fieldName + "' offset in class '" + cl + "' for unsafe operations";
 
 Review comment:
   This for readability to have it once, otherwise it cannot be shared by separate catch block scopes.
   I would hope that JVM will execute it only in case of error anyways.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#issuecomment-589090746
 
 
   <!--
   Meta data
   Hash:6d106f671d59bbf63b071d48001e40d724796747 Status:PENDING URL:https://travis-ci.com/flink-ci/flink/builds/149828412 TriggerType:PUSH TriggerID:6d106f671d59bbf63b071d48001e40d724796747
   -->
   ## CI report:
   
   * 6d106f671d59bbf63b071d48001e40d724796747 Travis: [PENDING](https://travis-ci.com/flink-ci/flink/builds/149828412) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] tillrohrmann commented on a change in pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
tillrohrmann commented on a change in pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#discussion_r383183769
 
 

 ##########
 File path: flink-core/src/main/java/org/apache/flink/core/memory/MemoryUtils.java
 ##########
 @@ -60,32 +63,31 @@
 		}
 	}
 
-	/** Should not be instantiated. */
-	private MemoryUtils() {}
-
-	private static Constructor<? extends ByteBuffer> getDirectBufferPrivateConstructor() {
+	private static long getClassFieldOffset(@SuppressWarnings("SameParameterValue") Class<?> cl, String fieldName) {
+		final String errorMessage = "Could not get field '" + fieldName + "' offset in class '" + cl + "' for unsafe operations";
 
 Review comment:
   nit: We only need `errorMessage` in the error case. Hence, no need to create it here.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [flink] azagrebin commented on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer

Posted by GitBox <gi...@apache.org>.
azagrebin commented on issue #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer
URL: https://github.com/apache/flink/pull/11160#issuecomment-590772398
 
 
   merged into master by 74fc20a56ef69046cd8fbdfa9e5ae5e5f6aeea1d
   merged into 1,10 by 02255ed8996a49ce53c605cbc5850921e2d52f6d

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services