Return-Path: X-Original-To: apmail-tez-issues-archive@minotaur.apache.org Delivered-To: apmail-tez-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6674A18919 for ; Thu, 9 Jul 2015 18:54:07 +0000 (UTC) Received: (qmail 76033 invoked by uid 500); 9 Jul 2015 18:54:07 -0000 Delivered-To: apmail-tez-issues-archive@tez.apache.org Received: (qmail 75983 invoked by uid 500); 9 Jul 2015 18:54:07 -0000 Mailing-List: contact issues-help@tez.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tez.apache.org Delivered-To: mailing list issues@tez.apache.org Received: (qmail 75856 invoked by uid 99); 9 Jul 2015 18:54:07 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jul 2015 18:54:07 +0000 Date: Thu, 9 Jul 2015 18:54:07 +0000 (UTC) From: "Gopal V (JIRA)" To: issues@tez.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (TEZ-2606) Cache-friendly data structure for sorting MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/TEZ-2606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14621065#comment-14621065 ] Gopal V commented on TEZ-2606: ------------------------------ bq. My idea is kvmeta's including new prefix of key's binary. Yes, that's the partition LSB is the prefix of the key's binary, when you run Hive on Tez. The full integer in partition is split into two groups - bits for the partition id and the remaining bits used for the prefix of the key. {code} if(hasher != null) { prefix = hasher.getProxy(key); } prefix = (partition << (32 - partitionBits)) | (prefix >>> partitionBits); {code} The original naive implementation of reading the bytes post-serialization in Tez didn't seem to help at all (due to writables) and broke reverse ordering. In the TezBytesComparator, we read out the key prefix (always as a positive integer to avoid complement bit masks) and special-case it so that PIG or Cascading which needs ordering be different from the byte ordinal comparisons won't be broken. https://github.com/apache/tez/blob/master/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/comparator/TezBytesComparator.java#L59 And even that doesn't really work unless you use TEZ-1288, since for most Writables the first few bytes are the size of the structure, not part of the key. This performance boost has less to do with the cache coherence part of the problem and more to do with the fact that the RawComparator interface thunk/trampoline is more expensive - the partition-a > partition-b check now short-circuits more of those, which is the real win (particularly for Cascading, which does tuple comparisons - not byte). > Cache-friendly data structure for sorting > ----------------------------------------- > > Key: TEZ-2606 > URL: https://issues.apache.org/jira/browse/TEZ-2606 > Project: Apache Tez > Issue Type: Sub-task > Reporter: Tsuyoshi Ozawa > Assignee: Tsuyoshi Ozawa > > Alphasort[1] mentions prefix key sort is effective way. I'd like to suggest to change a layout of ring buffer to include prefix of key in meta data. This can improve the cache hit rate when sorting. > [1] Alphasort: http://dl.acm.org/citation.cfm?id=615237 -- This message was sent by Atlassian JIRA (v6.3.4#6332)