eaglewatcherwb commented on a change in pull request #8290: [FLINK-12070] 
[network] Implement new bounded blocking subpartitions
URL: https://github.com/apache/flink/pull/8290#discussion_r281906483
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PageSizeUtil.java
 ##########
 @@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.io.network.partition;
+
+import org.apache.flink.util.ExceptionUtils;
+
+import org.apache.flink.shaded.netty4.io.netty.util.internal.PlatformDependent;
+import 
org.apache.flink.shaded.netty4.io.netty.util.internal.shaded.org.jctools.util.UnsafeAccess;
+
+import sun.misc.Unsafe;
+
+import javax.annotation.Nullable;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Utility for accessing the system page size.
+ */
+final class PageSizeUtil {
+
+       /** Value indicating an unknown page size. */
+       public static final int PAGE_SIZE_UNKOWN = -1;
+
+       /** The default page size on most system. */
+       public static final int DEFAULT_PAGE_SIZE = 4 * 1024;
+
+       /** A conservative fallback value (64 KiBytes) that should be a 
multiple of the page size even
+        * in some uncommon cases of servers installations with 
larger-than-usual page sizes. */
+       public static final int CONSERVATIVE_PAGE_SIZE_MULTIPLE = 64 * 1024;
+
+       /**
+        * Tries to get the system page size. If the page size cannot be 
determined, this
+        * returns -1.
+        *
+        * <p>This internally relies on the presence of "unsafe" and the 
resolution via some
+        * Netty utilities.
+        */
+       public static int getSystemPageSize() {
+               try {
+                       return PageSizeUtilInternal.getSystemPageSize();
+               }
+               catch (Throwable t) {
+                       ExceptionUtils.rethrowIfFatalError(t);
+                       return PAGE_SIZE_UNKOWN;
+               }
+       }
+
+       /**
+        * Tries to get the system page size. If the page size cannot be 
determined, this
+        * returns the {@link #DEFAULT_PAGE_SIZE}.
+        */
+       public static int getSystemPageSizeOrDefault() {
 
 Review comment:
   never used function

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to