You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by "richardantal (via GitHub)" <gi...@apache.org> on 2023/05/17 12:19:05 UTC

[GitHub] [phoenix] richardantal commented on a diff in pull request #1596: PHOENIX-6944 Randomize mapper task ordering for MR tools

richardantal commented on code in PR #1596:
URL: https://github.com/apache/phoenix/pull/1596#discussion_r1196421593


##########
phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixInputFormat.java:
##########
@@ -87,74 +88,106 @@ public List<InputSplit> getSplits(JobContext context) throws IOException, Interr
         return generateSplits(queryPlan, configuration);
     }
 
-    protected List<InputSplit> generateSplits(final QueryPlan qplan, Configuration config) throws IOException {
+    /**
+     * Randomise the length parameter of the splits to ensure random execution order.
+     * Yarn orders splits by size before execution.
+     *
+     * @param splits
+     */
+    protected void randomizeSplitLength(List<InputSplit> splits) {
+        LOGGER.info("Randomizing split size");
+        if (splits.size() == 0) {
+            return;
+        }
+        double defaultLength = 1000000d;
+        double totalLength = splits.stream().mapToDouble(s -> {
+            try {
+                return (double) s.getLength();
+            } catch (IOException | InterruptedException e1) {
+                return defaultLength;
+            }
+        }).sum();
+        long avgLength = (long) (totalLength / splits.size());
+        splits.stream().forEach(s -> ((PhoenixInputSplit) s)
+                .setLength(avgLength + ThreadLocalRandom.current().nextInt(10000)));

Review Comment:
   I assume that it performs better because there aren't big differences in the split lengths, right?
   
   The sum of the new split lengths will be bigger than the original, why this isn't it a problem?



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org