You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uniffle.apache.org by ya...@apache.org on 2022/09/06 10:00:31 UTC

[incubator-uniffle] branch uniffle-144 updated (912b9293 -> 89db9b2a)

This is an automated email from the ASF dual-hosted git repository.

yangjie01 pushed a change to branch uniffle-144
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git


 discard 912b9293 fix
     new 89db9b2a fix

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (912b9293)
            \
             N -- N -- N   refs/heads/uniffle-144 (89db9b2a)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/main/java/org/apache/uniffle/common/RssShuffleUtils.java   | 3 ++-
 .../test/java/org/apache/uniffle/common/RssShuffleUtilsTest.java   | 7 ++++---
 2 files changed, 6 insertions(+), 4 deletions(-)


[incubator-uniffle] 01/01: fix

Posted by ya...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

yangjie01 pushed a commit to branch uniffle-144
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git

commit 89db9b2ab21f5d909a9faf035b89e45b31713382
Author: yangjie01 <ya...@baidu.com>
AuthorDate: Tue Sep 6 17:58:02 2022 +0800

    fix
---
 .../org/apache/uniffle/common/RssShuffleUtils.java | 14 +++-------
 .../apache/uniffle/common/RssShuffleUtilsTest.java | 32 ++++++++++++++++++++--
 2 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/common/src/main/java/org/apache/uniffle/common/RssShuffleUtils.java b/common/src/main/java/org/apache/uniffle/common/RssShuffleUtils.java
index 58db058e..0ad71ae2 100644
--- a/common/src/main/java/org/apache/uniffle/common/RssShuffleUtils.java
+++ b/common/src/main/java/org/apache/uniffle/common/RssShuffleUtils.java
@@ -17,10 +17,10 @@
 
 package org.apache.uniffle.common;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.nio.ByteBuffer;
 
+import sun.nio.ch.DirectBuffer;
+
 import com.google.common.base.Preconditions;
 import net.jpountz.lz4.LZ4Compressor;
 import net.jpountz.lz4.LZ4Factory;
@@ -73,15 +73,9 @@ public class RssShuffleUtils {
    *
    */
   public static void destroyDirectByteBuffer(ByteBuffer toBeDestroyed)
-          throws IllegalArgumentException, IllegalAccessException,
-          InvocationTargetException, SecurityException, NoSuchMethodException {
+          throws IllegalArgumentException, SecurityException {
     Preconditions.checkArgument(toBeDestroyed.isDirect(),
             "toBeDestroyed isn't direct!");
-    Method cleanerMethod = toBeDestroyed.getClass().getMethod("cleaner");
-    cleanerMethod.setAccessible(true);
-    Object cleaner = cleanerMethod.invoke(toBeDestroyed);
-    Method cleanMethod = cleaner.getClass().getMethod("clean");
-    cleanMethod.setAccessible(true);
-    cleanMethod.invoke(cleaner);
+    ((DirectBuffer)toBeDestroyed).cleaner().clean();
   }
 }
diff --git a/common/src/test/java/org/apache/uniffle/common/RssShuffleUtilsTest.java b/common/src/test/java/org/apache/uniffle/common/RssShuffleUtilsTest.java
index 1dd51ebf..c531834f 100644
--- a/common/src/test/java/org/apache/uniffle/common/RssShuffleUtilsTest.java
+++ b/common/src/test/java/org/apache/uniffle/common/RssShuffleUtilsTest.java
@@ -17,15 +17,19 @@
 
 package org.apache.uniffle.common;
 
+import java.lang.reflect.Field;
+import java.nio.Buffer;
 import java.nio.ByteBuffer;
 
+import sun.misc.Unsafe;
+
 import org.apache.commons.lang3.RandomUtils;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.ValueSource;
 
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 
 public class RssShuffleUtilsTest {
 
@@ -57,9 +61,19 @@ public class RssShuffleUtilsTest {
       byteBuffer.put(b);
     }
     byteBuffer.flip();
+
+    // Get valid native pointer through `address` in `DirectByteBuffer`
+    Unsafe unsafe = getUnsafe();
+    long addressInByteBuffer = address(byteBuffer);
+    long originalAddress = unsafe.getAddress(addressInByteBuffer);
+
     RssShuffleUtils.destroyDirectByteBuffer(byteBuffer);
+
     // The memory may not be released fast enough.
-    Thread.sleep(200);
+    // If native pointer changes, `address` in `DirectByteBuffer` is invalid
+    while (unsafe.getAddress(addressInByteBuffer) == originalAddress) {
+      Thread.sleep(200);
+    }
     boolean same = true;
     byte[] read = new byte[size];
     byteBuffer.get(read);
@@ -69,6 +83,18 @@ public class RssShuffleUtilsTest {
         break;
       }
     }
-    assertTrue(!same);
+    assertFalse(same);
+  }
+
+  private Unsafe getUnsafe() throws NoSuchFieldException, IllegalAccessException {
+    Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
+    unsafeField.setAccessible(true);
+    return (sun.misc.Unsafe) unsafeField.get(null);
+  }
+
+  private long address(ByteBuffer buffer) throws NoSuchFieldException, IllegalAccessException {
+    Field addressField = Buffer.class.getDeclaredField("address");
+    addressField.setAccessible(true);
+    return (long) addressField.get(buffer);
   }
 }