Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/5725#discussion_r29221238
--- Diff:
unsafe/src/main/java/org/apache/spark/unsafe/memory/MemoryManager.java ---
@@ -0,0 +1,176 @@
+/*
+ * 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.spark.unsafe.memory;
+
+import java.util.BitSet;
+
+/**
+ * Manages the lifecycle of data pages exchanged between operators.
+ * <p>
+ * Most of the complexity in this class deals with encoding of off-heap
addresses into 64-bit longs.
+ * In off-heap mode, memory can be directly addressed with 64-bit longs.
In on-heap mode, memory is
+ * addressed by the combination of a base Object reference and a 64-bit
offset within that object.
+ * This is a problem when we want to store pointers to data structures
inside of other structures,
+ * such as record pointers inside hashmaps or sorting buffers. Even if we
decided to use 128 bits
+ * to address memory, we can't just store the address of the base object
since it's not guaranteed
+ * to remain stable as the heap gets reorganized due to GC.
+ * <p>
+ * Instead, we use the following approach to encode record pointers in
64-bit longs: for off-heap
+ * mode, just store the raw address, and for on-heap mode use the upper 13
bits of the address to
+ * store a "page number" and the lower 51 bits to store an offset within
this page. These page
+ * numbers are used to index into a "page table" array inside of the
MemoryManager in order to
+ * retrieve the base object.
+ */
+public final class MemoryManager {
+
+ /**
+ * The number of entries in the page table.
+ */
+ private static final int PAGE_TABLE_SIZE = (int) 1L << 13;
--- End diff --
why not just ```1 << 13``` ?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]