aweisberg commented on code in PR #4179:
URL: https://github.com/apache/cassandra/pull/4179#discussion_r2112799553


##########
src/java/org/apache/cassandra/io/util/FileUtils.java:
##########
@@ -360,30 +325,7 @@ public static boolean isContained(File folder, File file)
 
     public static void clean(ByteBuffer buffer)
     {
-        if (buffer == null || !buffer.isDirect())
-            return;
-
-        // TODO Once we can get rid of Java 8, it's simpler to call 
sun.misc.Unsafe.invokeCleaner(ByteBuffer),
-        // but need to take care of the attachment handling (i.e. whether 
'buf' is a duplicate or slice) - that
-        // is different in sun.misc.Unsafe.invokeCleaner and this 
implementation.
-
-        try
-        {
-            Object cleaner = mhDirectBufferCleaner.bindTo(buffer).invoke();
-            if (cleaner != null)
-            {
-                // ((DirectBuffer) buf).cleaner().clean();
-                mhCleanerClean.bindTo(cleaner).invoke();
-            }
-        }
-        catch (RuntimeException e)
-        {
-            throw e;
-        }
-        catch (Throwable e)
-        {
-            throw new RuntimeException(e);
-        }
+        MemoryUtil.clean(buffer);

Review Comment:
   Can you refactor the 42 usages to use `MemoryUtil`? I think it makes more 
sense since `ByteBuffer` is not inherently file related. Not very valuable for 
cleaning `ByteBuffers` but removing indirection also makes inlining work better 
because the budget is calculated based off compiled byte code not post 
optimization/compilation after inlining.



-- 
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: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to