-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HBASE-28837 Introduce row statistics coprocessor example #6327
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@eab148 if you want community eyes on this, I recommend that you send a note to the dev@ mailing list. I think most folks are not watching PRs or Jira issue creation. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@stoty @virajjasani is this something that Phoenix could use to make better query plans? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is a very important contribution, and we should discuss adding it as a core feature of HBase. I do wonder if there's a better solution than writing across-region-servers from within the coprocessor. The LMAX disruptor helps, but I wonder if there's a more scalable architecture would have all statistics populate something region-local. Maybe we add the statistics to the WAL's compaction marker? Or can we write the statistics to a header/trailer value in the resulting HFile?
...mples/src/main/java/org/apache/hadoop/hbase/coprocessor/example/row/stats/RowStatistics.java
Show resolved
Hide resolved
...a/org/apache/hadoop/hbase/coprocessor/example/row/stats/RowStatisticsCompactionObserver.java
Outdated
Show resolved
Hide resolved
...a/org/apache/hadoop/hbase/coprocessor/example/row/stats/RowStatisticsCompactionObserver.java
Outdated
Show resolved
Hide resolved
regionCount += count; | ||
} | ||
if (regionCount == 0) { | ||
regionEnv.getMetricRegistryForRegionServer().remove(ROW_STATISTICS_DROPPED, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to remove metrics? Is this some kind of coprocessor hygiene best practice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a table moves off a RegionServer (or is dropped), we leak the metrics, which hang around forever until the RS restarts. This is really only a problem for clusters that have a lot of table creations/deletions (for example clusters that have acceptance tests run against them), but I felt it made sense to have this cleanup logic everywhere.
...a/org/apache/hadoop/hbase/coprocessor/example/row/stats/RowStatisticsCompactionObserver.java
Show resolved
Hide resolved
...s/src/main/java/org/apache/hadoop/hbase/coprocessor/example/row/stats/RowStatisticsImpl.java
Show resolved
Hide resolved
...g/apache/hadoop/hbase/coprocessor/example/row/stats/recorder/RowStatisticsTableRecorder.java
Outdated
Show resolved
Hide resolved
...main/java/org/apache/hadoop/hbase/coprocessor/example/row/stats/utils/RowStatisticsUtil.java
Outdated
Show resolved
Hide resolved
.../apache/hadoop/hbase/coprocessor/example/row/stats/utils/RowStatisticsConfigurationUtil.java
Outdated
Show resolved
Hide resolved
Since i cannot leave a comment on the design doc, would you mind filling in some detail about how these statistics are queried and used? Thanks @eab148 ! |
Most of these statistics are not particularly relevant for Phoenix, as extreme row/cell sizes are less typical in Phoenix's relational model. However, I think this same infrastructure could be extended for key distribution, cardinality, and other statistics that are relevant for query plan optimization. Those would probably need some kind of pluggalble interface where Phoenix can process the rowkeys as its own PK components as the data is collected. Phoenix doesn't really do optimization based on table contents today, so there is a lot of room for improvement. Unfortunately, my knowledge on optimization techniques is also lacking, so I cannot tell whether this infrastructure has any flaws that would later limit Phoenix's ability to use it. |
As for the data collection, one alternative could be using a special CF for the statistics, instead of a separate table. Phoenix's local indexes use this trick. If write performance is a problem, the rowkey for the statistics table could also be salted. IUC we now have one cell per region per CF, so the the statistics write load might not even be an issue, it's a tradeoff between write and read performance, as usual. |
I think if we were to build this natively into hbase as a feature, it probably shouldn't be a coprocessor. It could be written within the core internals, which would afford us some extra power. Namely, we could store these statistics directly into the HFiles in the metadata. The query layer could handle aggregating across the HFiles of a region. We could provide coprocessor hooks to let users add their own data to the same per-HFile metadata. |
Querying row statistics:We have an API that fetches and performs aggregations/filtering on our row statistics. These results are cached for a duration of time. The available API queries include:
As a reminder, the cells in our internal row statistics table have the following fields:
Using row statistics:At my day job, we've used the row statistics to
Tune Block SizesOur block size tuning job halves the block size for each family of a table if
Tuning the block sizes for sequential read workloads is more complicated as estimating the number of blocks a Scan will require is an ambiguous task when one considers filtered, partial, and full table Scans. Remove Huge Cells
Smarter Compaction Schedules
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@ndimiduk I addressed the static analysis nits. They are now passing with 💚. Everything should be good now. I just rebased my branch off of master to address the |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @eab148 for being patient as we checked off all the boxes.
The |
Co-authored-by: Evie Boland <eboland@hubspot.com> Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
Co-authored-by: Evie Boland <eboland@hubspot.com> Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
Co-authored-by: Evie Boland <eboland@hubspot.com> Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
Signed-off-by: Nick Dimiduk <ndimiduk@apache.org> Co-authored-by: eab148 <54775485+eab148@users.noreply.github.com> Co-authored-by: Evie Boland <eboland@hubspot.com>
Co-authored-by: Evie Boland <eboland@hubspot.com> Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
Design doc
HBase provides many configuration options to help administrators tune their tables and clusters for desired performance and reliability. However, it can be difficult for administrators to leverage these configuration options because they do not have a nuanced understanding of the shape of their data in HBase.
In this PR, we introduce a row statistics coprocessor to the hbase-examples module. This coprocessor allows administrators to collect statistics on the rows in their HBase tables as these rows compact. With more information about the shape of their data in HBase, administrators can leverage the available configuration options to unlock performance and reliability gains for their HBase tables/clusters.
(Thank you to Bryan Beaudreault for collaborating with me on this!)
Jira
cc @hgromer @krconv @rmdmattingly @ndimiduk @bbeaudreault