Skip to content

Commit 0198868

Browse files
authored
HBASE-20060 Add details of off heap memstore into book. (#334)
1 parent b426142 commit 0198868

File tree

3 files changed

+54
-7
lines changed

3 files changed

+54
-7
lines changed

hbase-common/src/main/resources/hbase-default.xml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,30 @@ possible configurations would overwhelm and obscure the important.
696696
Enables the MemStore-Local Allocation Buffer,
697697
a feature which works to prevent heap fragmentation under
698698
heavy write loads. This can reduce the frequency of stop-the-world
699-
GC pauses on large heaps.</description>
699+
GC pauses on large heaps.
700+
</description>
701+
</property>
702+
<property>
703+
<name>hbase.hregion.memstore.mslab.chunksize</name>
704+
<value>2097152</value>
705+
<description>The maximum byte size of a chunk in the MemStoreLAB. Unit: bytes</description>
706+
</property>
707+
<property>
708+
<name>hbase.regionserver.offheap.global.memstore.size</name>
709+
<value>0</value>
710+
<description>The amount of off-heap memory all MemStores in a RegionServer may use.
711+
A value of 0 means that no off-heap memory will be used and all chunks in MSLAB
712+
will be HeapByteBuffer, otherwise the non-zero value means how many megabyte of
713+
off-heap memory will be used for chunks in MSLAB and all chunks in MSLAB will be
714+
DirectByteBuffer. Unit: megabytes.
715+
</description>
716+
</property>
717+
<property>
718+
<name>hbase.hregion.memstore.mslab.max.allocation</name>
719+
<value>262144</value>
720+
<description>The maximal size of one allocation in the MemStoreLAB, if the desired byte
721+
size exceed this threshold then it will be just allocated from JVM heap rather than MemStoreLAB.
722+
</description>
700723
</property>
701724
<property>
702725
<name>hbase.hregion.max.filesize</name>

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DefaultMemStore.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,23 @@ Cell getNextRow(final Cell cell) {
160160
getNextRow(cell, this.snapshot.getCellSet()));
161161
}
162162

163-
@Override public void updateLowestUnflushedSequenceIdInWAL(boolean onlyIfMoreRecent) {
163+
@Override
164+
public void updateLowestUnflushedSequenceIdInWAL(boolean onlyIfMoreRecent) {
164165
}
165166

166-
@Override protected boolean preUpdate(MutableSegment currentActive, Cell cell,
167+
@Override
168+
protected boolean preUpdate(MutableSegment currentActive, Cell cell,
167169
MemStoreSizing memstoreSizing) {
168170
return true;
169171
}
170172

171-
@Override protected void postUpdate(MutableSegment currentActive) {
173+
@Override
174+
protected void postUpdate(MutableSegment currentActive) {
172175
return;
173176
}
174177

175-
@Override protected boolean sizeAddedPreOperation() {
178+
@Override
179+
protected boolean sizeAddedPreOperation() {
176180
return false;
177181
}
178182

@@ -186,7 +190,8 @@ public long preFlushSeqIDEstimation() {
186190
return HConstants.NO_SEQNUM;
187191
}
188192

189-
@Override public boolean isSloppy() {
193+
@Override
194+
public boolean isSloppy() {
190195
return false;
191196
}
192197

src/main/asciidoc/_chapters/offheap_read_write.adoc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,23 @@ Please also see: link:https://issues.apache.org/jira/browse/HBASE-22483[HBASE-22
183183
[[regionserver.offheap.writepath]]
184184
== Offheap write-path
185185
186-
TODO
186+
In HBase 2.0.0, link:https://issues.apache.org/jira/browse/HBASE-15179[HBASE-15179] made the HBase write path to work off-heap. By default, the MemStores use
187+
MSLAB to avoid memory fragmentation. It creates bigger fixed sized chunks and memstore cell's data will get copied into these chunks. These chunks can be pooled
188+
also and from 2.0.0 the MSLAB (MemStore-Local Allocation Buffer) pool is by default ON. Write off-heaping makes use of the MSLAB pool. It creates MSLAB chunks
189+
as Direct ByteBuffers and pools them. HBase defaults to using no off-heap memory for MSLAB which means that cells are copied to heap chunk in MSLAB by default
190+
rather than off-heap chunk.
191+
192+
`hbase.regionserver.offheap.global.memstore.size` is the configuration key which controls the amount of off-heap data whose value is the number of megabytes
193+
of off-heap memory that should be by MSLAB (e.g. `25` would result in 25MB of off-heap). Be sure to increase `HBASE_OFFHEAPSIZE` which will set the JVM's
194+
MaxDirectMemorySize property. Its default value is 0, means MSLAB use heap chunks.
195+
196+
`hbase.hregion.memstore.mslab.chunksize` controls the size of each off-heap chunk, defaulting to `2097152` (2MB).
197+
198+
When a Cell is added to a MemStore, the bytes for that Cell are copied into these off-heap buffers (if set the `hbase.regionserver.offheap.global.memstore.size` to non-zero)
199+
and a Cell POJO will refer to this memory area. This can greatly reduce the on-heap occupancy of the MemStores and reduce the total heap utilization for RegionServers
200+
in a write-heavy workload. On-heap and off-heap memory utiliazation are tracked at multiple levels to implement low level and high level memory management.
201+
The decision to flush a MemStore considers both the on-heap and off-heap usage of that MemStore. At the Region level, the sum of the on-heap and off-heap usages and
202+
compares them against the region flush size (128MB, by default). Globally, on-heap size occupancy of all memstores are tracked as well as off-heap size. When any of
203+
these sizes breaches the lower mark (`hbase.regionserver.global.memstore.size.lower.limit`) or the maximum size `hbase.regionserver.global.memstore.size`), all
204+
regions are selected for forced flushes.
205+

0 commit comments

Comments
 (0)