keith-turner commented on a change in pull request #1187: Log busy tablets by
ingest and query at a configurable time duration
URL: https://github.com/apache/accumulo/pull/1187#discussion_r291645172
##########
File path:
server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
##########
@@ -358,6 +359,60 @@ public TabletServer(ServerConfigurationFactory
confFactory, VolumeManager fs) th
this.logSorter = new LogSorter(instance, fs, aconf);
this.replWorker = new ReplicationWorker(this, fs);
this.statsKeeper = new TabletStatsKeeper();
+ final int numBusyTabletsToLog =
aconf.getCount(Property.TSERV_LOG_BUSY_TABLETS_COUNT);
+ final long logBusyTabletsDelay =
+ aconf.getTimeInMillis(Property.TSERV_LOG_BUSY_TABLETS_INTERVAL);
+
+ // This thread will calculate and log out the busiest tablets based on
ingest count and
+ // query count every #{logBusiestTabletsDelay}
+ if (numBusyTabletsToLog > 0) {
+ SimpleTimer.getInstance(aconf).schedule(new Runnable() {
+ @Override
+ public void run() {
+ Comparator<Pair<String,Long>> busiestTabletComparator =
+ new Comparator<Pair<String,Long>>() {
+ @Override
+ public int compare(Pair<String,Long> first, Pair<String,Long>
second) {
+ return second.getSecond().compareTo(first.getSecond());
+ }
+ };
+ PriorityQueue<Pair<String,Long>> busiestTabletsByIngestCount =
+ new PriorityQueue<>(numBusyTabletsToLog,
busiestTabletComparator);
+ PriorityQueue<Pair<String,Long>> busiestTabletsByQueryCount =
+ new PriorityQueue<>(numBusyTabletsToLog,
busiestTabletComparator);
+ synchronized (onlineTablets) {
+ for (Tablet tablet : onlineTablets.values()) {
+ addToBusiestTablets(tablet.totalIngest(),
busiestTabletsByIngestCount,
+ numBusyTabletsToLog);
+ addToBusiestTablets(tablet.totalQueries(),
busiestTabletsByQueryCount,
+ numBusyTabletsToLog);
+ }
+ logBusyTablets(busiestTabletsByIngestCount, "QUERY",
numBusyTabletsToLog);
Review comment:
Every read and write to Accumuo needs to sync on `onlineTablets`. This can
cause contention between unrelated threads. I fixed this for 2.0 with #1100.
However in 1.9 it would be best to minimize the time spent with the lock held
on onlineTablets. There are two possible ways to do this here, could just move
these logging statements out since logging could do IO. Could take it a step
further and do something like the following, which avoids the O(n log m)
operation of adding the prio queue while the lock is held.
```java
List< Tablet> tablets;
synchronized (onlineTablets) {
tablets = new ArrayList<>(onlineTablets.values);
}
// do all computation that was done in sync block here using tablets list
```
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services