HBase Profiling
By Lars Hofhansl Modern CPU cores can execute hundreds of instructions in the time it takes to reload the L1 cache. "RAM is the new disk" as a coworker at Salesforce likes to say. The L1-cache is the new RAM I might add. As we add more and
By Lars HofhanslModern CPU cores can execute hundreds of instructions in the time it takes to reload the L1 cache. "RAM is the new disk" as a coworker at Salesforce likes to say. The L1-cache is the new RAM I might add.
As we add more and more CPU cores, we can easily be memory IO bound unless we are a careful.
Many common problems I have seen over the years were related to:
-
concurrency problems
Aside from safety and liveliness considerations, a typical problem is too much synchronization limiting potential parallel execution. -
unneeded or unintended memory barriers
Memory barriers are required in Java by the following language constructs:- synchronized - sets read and write barriers as needed (details depend on JVM, version, and settings)
- volatile - sets a read barrier before a read to a volatile, and write barrier after a write
- final - set a write barrier after the assignment
- AtomicInteger, AtomicLong, etc - uses volatiles and hardware CAS instructions
-
unnecessary, unintended, or repeated memory copy or access
Memory copying is often seen in Java for example because of the lack of in-array pointers, or really just general unawareness and the expectation that "garbage collector will clean up the mess." Well, it does, but not without a price.
Like any software project of reasonable size, HBase has problems of all the above categories.
Profiling in Java has become extremely convenient. Just start jVisualVM which ships with the
Over the past few weeks I did some on and off profiling in HBase, which lead to the following issues:
HBASE-6603 - RegionMetricsStorage.incrNumericMetric is called too often
Ironically here it was the collection of a performance metric that caused a measurable slowdown of up 15%(!) for very wide rows (> 10k columns).The metric was maintained as an AtomicLong, which introduced a memory barrier in one of the hottest code paths in HBase.
The good folks at Facebook have found the same issue at roughly the same time. (It turns that they were also... uhm... the folks who introduced the problem.)
HBASE-6621 - Reduce calls to Bytes.toInt
A KeyValue (the data structure that represents "columns" in HBase) is currently backed by a single byte[]. The sizes of the various parts are encoded in this byte[] and have to read and decoded; each time an extra memory access. In many cases that can be avoided, leading to slight performance improvement.HBASE-6711 - Avoid local results copy in StoreScanner
All references pertaining to a single row (i.e. KeyValue with the same row key) were copied at the StoreScanner layer. Removing this lead to another slight performance increase with wide rows.HBASE-7180 - RegionScannerImpl.next() is inefficient
This introduces a mechanism for coprocessors to access RegionScanners at a lower level, thus allowing skipping of a lot of unnecessary setup for each next() call. In tight loops a coprocessor can make use of this new API to save another 10-15%.HBASE-7279 - Avoid copying the rowkey in RegionScanner, StoreScanner, and ScanQueryMatcher
The row key of KeyValue was copied in the various scan related classes. To reduce that effect the row key was previously cached in the KeyValue class - leading to extra memory required for each KeyValue.This change avoids all copying and hence also obviates the need for caching the row key.
A KeyValue now is hardly more than an array pointer (a byte[], an offset, and a length), and no data is copied any longer all the way from the block loaded from disk or cache to the RPC layer (unless the KeyValues are optionally encoded on disk, in which case they still need to be decoded in memory - we're working on improving that too).
Previously the size of a KeyValue on the scan path was at least 116 bytes + the length of the rowkey (which can be arbitrarily long). Now it is ~60 bytes, flat and including its own reference.
(remember during a course of a large scan we might be creating millions or even billions of KeyValue objects)
This is nice improvement both in term of scan performance (15-20% for small row keys of few bytes, much more for large ones) and in terms of produced garbage.
Since all copying is avoided, scanning now scales almost linearly with the number of cores.
HBASE-6852 - SchemaMetrics.updateOnCacheHit costs too much while full scanning a table with all of its fields
Other folks have been busy too. Here Cheng Hao found another problem with a scan related metric that caused a noticeable slowdown (even though I did not believe him first).This removed another set of unnecessary memory barriers.
HBASE-7336 - HFileBlock.readAtOffset does not work well with multiple threads
This is slightly different issue caused by bad synchronization of the FSReader associated with a Storefile. There is only a single reader per storefile. So if the file's blocks are not cached - possibly because the scan indicated that it wants no caching, because it expects to touch too many blocks - the scanner threads are now competing for read access to the store file. That lead to outright terrible performance, such a scanners timing out even with just two scanners accessing the same file in tight loop.This patch is a stop gap measure: Attempt to acquire the lock on the reader, if that failed switch to HDFS positional reads, which can read at an offset without affecting the state of the stream, and hence requires no locking.
Summary
Together these various changes can lead to ~40-50% scan performance improvement when using a single core. Even more when using multiple cores on the same machines (as is the case with HBase)An entirely unscientific benchmark
20m rows, with two column families just a few dozen bytes each.I performed two tests:
1. A scan that returns rows to the client
2. A scan that touches all rows via a filter but does not return anything to the client.
(This is useful to gauge the actual server side performance).
Further I tested with (1) no caching, all reads from disk (2) all data in the OS cache and (3) all data in HBase's block cache.
I compared 0.94.0 against the current 0.94 branch (what I will soon release as 0.94.4).
Results:
-
Scanning with scanner caching set to 10000:
-
0.94.0
no data in cache: 54s
data in OS cache: 51s
data in block cache: 35s
-
0.94.0
-
0.94.4-snapshot
no data in cache: 50s (IO bound between disk and network)
data in OS cache: 43s
data in block cache: 32s
(limiting factor was shipping the results to the client)
-
all data filtered at the server (with a SingleValueColumnFilter that does not match anything, so each rows is still scanned)
-
0.94.0
no data in cache: 31s
data in OS cache: 25s
data in block cache: 11s
-
0.94.0
-
0.94.4-snapshot
no data in cache: 22s
data in OS cache: 17s
cache in block cache: 6.3s
So as you can see scan performance has significantly improved since 0.94.0.
Salesforce just hired some performance engineers from a well known chip manufacturer, and I plan to get some of their time to analyze HBase in even more details, to track down memory stalls, etc.
原文地址:HBase Profiling, 感谢原作者分享。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック











ビッグデータ時代の到来に伴い、データの処理と保存の重要性がますます高まっており、大量のデータをいかに効率的に管理、分析するかが企業にとっての課題となっています。 Apache Foundation の 2 つのプロジェクトである Hadoop と HBase は、ビッグ データのストレージと分析のためのソリューションを提供します。この記事では、ビッグデータのストレージとクエリのために Beego で Hadoop と HBase を使用する方法を紹介します。 1. Hadoop と HBase の概要 Hadoop は、オープンソースの分散ストレージおよびコンピューティング システムです。

依存関係: org.springframework.dataspring-data-hadoop-hbase2.5.0.RELEASEorg.apache.hbasehbase-client1.1.2org.springframework.dataspring-data-hadoop2.5.0.RELEASE 構成を追加する正式な方法は、xml を使用することです。 simple 書き換えると以下のようになります。 @ConfigurationpublicclassHBaseConfiguration{@Value("${hbase.zooke

ビッグデータ時代の到来により、大量のデータの保存と処理が特に重要になっています。 NoSQL データベースに関しては、HBase が現在広く使用されているソリューションです。 Go 言語は、静的に強く型付けされたプログラミング言語であり、そのシンプルな構文と優れたパフォーマンスにより、クラウド コンピューティング、Web サイト開発、データ サイエンスなどの分野で使用されることが増えています。この記事では、Go 言語で HBase を使用して効率的な NoSQL データベース アプリケーションを実装する方法を紹介します。 HBase の概要 HBase は、拡張性が高く、信頼性が高く、基本的な

Beego フレームワークでのデータ ストレージとクエリに HBase を使用する インターネット時代の継続的な発展に伴い、データ ストレージとクエリはますます重要になってきています。ビッグデータ時代の到来により、さまざまなデータソースがそれぞれの分野で重要な位置を占めていますが、非リレーショナルデータベースはデータストレージとクエリに明らかな利点を備えたデータベースであり、HBaseはHadoopをベースとした分散型非リレーショナルデータベースです。リレーショナル データベース。この記事では、Beego フレームワークでのデータ ストレージとクエリに HBase を使用する方法を紹介します。 1.H

Java を使用して HBase に基づいた NoSQL データベース アプリケーションを開発する方法 はじめに: ビッグ データ時代の到来により、NoSQL データベースは大量のデータを処理するための重要なツールの 1 つになりました。 HBase は、オープンソースの分散型 NoSQL データベース システムとして、ビッグ データの分野で広範なアプリケーションを備えています。この記事では、Java を使用して HBase に基づく NoSQL データベース アプリケーションを開発する方法を紹介し、具体的なコード例を示します。 1. HBase の概要: HBase は、Hadoop に基づく分散システムです。

インターネット アプリケーションとデータ量の継続的な増加に伴い、従来のリレーショナル データベースでは、大量のデータの保存と処理のニーズを満たすことができなくなりました。新しいタイプのデータベース管理システムとして、NoSQL (NotOnlySQL) は大規模なデータの保存と処理において大きな利点があり、ますます注目され、応用されています。 NoSQL データベースの中でも、ApacheHBase は非常に人気のあるオープンソースの分散データベースであり、Google の BigTable のアイデアに基づいて設計されており、

Workerman は、多数の同時接続をホストできる高性能 PHPsocket フレームワークです。従来の PHP フレームワークとは異なり、Workerman は Apache や Nginx などの Web サーバーに依存せず、PHP プロセスを開始することでアプリケーション全体を単独で実行します。 Workerman は非常に高い作業効率と優れた耐荷重性を備えています。同時に、HBase はビッグデータで広く使用されている分散型 NoSQL データベース システムです。

HBase は、大規模な構造化データを保存および処理するために設計された Hadoop ベースの分散ストレージ システムです。読み取りおよび書き込みのパフォーマンスを最適化するために、HBase はさまざまなキャッシュ メカニズムを提供します。これにより、クエリ効率が向上し、適切な構成を通じて読み取りおよび書き込みの遅延が軽減されます。この記事では、HBase キャッシュ テクノロジとその構成方法を紹介します。 HBase のキャッシュ タイプ HBase は、ブロック キャッシュ (BlockCache) と MemStore キャッシュ (書き込みキャッシュとも呼ばれます) という 2 つの基本的なキャッシュ メカニズムを提供します。ブロックキャッシュは次のとおりです
