Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 44429200C38 for ; Wed, 15 Mar 2017 18:02:49 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 4305B160B8A; Wed, 15 Mar 2017 17:02:49 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9441B160B60 for ; Wed, 15 Mar 2017 18:02:48 +0100 (CET) Received: (qmail 60893 invoked by uid 500); 15 Mar 2017 17:02:46 -0000 Mailing-List: contact issues-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list issues@ignite.apache.org Received: (qmail 60884 invoked by uid 99); 15 Mar 2017 17:02:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Mar 2017 17:02:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 734E9C0B57 for ; Wed, 15 Mar 2017 17:02:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.764 X-Spam-Level: ** X-Spam-Status: No, score=2.764 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_NEUTRAL=0.652, URI_HEX=1.313] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id mOL8EMj9Kz2a for ; Wed, 15 Mar 2017 17:02:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id C1F165F23A for ; Wed, 15 Mar 2017 17:02:42 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id DB76AE05C1 for ; Wed, 15 Mar 2017 17:02:41 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 97E1A243A6 for ; Wed, 15 Mar 2017 17:02:41 +0000 (UTC) Date: Wed, 15 Mar 2017 17:02:41 +0000 (UTC) From: "Dmitriy Setrakyan (JIRA)" To: issues@ignite.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (IGNITE-4828) Improve the distribution of keys within partitions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 15 Mar 2017 17:02:49 -0000 [ https://issues.apache.org/jira/browse/IGNITE-4828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15926573#comment-15926573 ] Dmitriy Setrakyan commented on IGNITE-4828: ------------------------------------------- Here is the link to the dev list discussion: http://apache-ignite-developers.2346864.n4.nabble.com/Distribution-of-keys-to-partitions-td15455.html > Improve the distribution of keys within partitions > -------------------------------------------------- > > Key: IGNITE-4828 > URL: https://issues.apache.org/jira/browse/IGNITE-4828 > Project: Ignite > Issue Type: Improvement > Affects Versions: 1.9 > Reporter: Michael Griggs > Fix For: 2.0 > > > An issue has been found when inserting several million string keys in to a cache. Each string key was approximately 22-characters in length. When I exported the partition counts (via GG Visor) I was able to see an unusual periodicity in the number of keys allocated to partitions. I charted this in Excel (1). > After further investigation, it appears that there is a relationship > between the number of keys being inserted, the number of partitions > assigned to the cache and amount of apparent periodicity: a small number ofpartitions will cause periodicity to appear with a lower number of keys. > The {{RendezvousAffinityFunction#partition}} function performs a simple > calculation of key hashcode modulo partition-count: > {{U.safeAbs(key.hashCode() % parts)}} > Digging further I was led to the fact that this is how the Java HashMap > *used* to behave (2), but was upgraded around Java 1.4 to perform the > following: > {{key.hashCode() & (parts - 1)}} > which performs more efficiently. It was then updated further to do the > following: > {{(h = key.hashCode()) ^ (h >>> 16);}} > with the bit-shift performed to > bq. incorporate impact of the highest bits that would otherwise never be used in index calculations because of table bounds > When using this function, rather than our > {{RendezvousAffinityFunction#partition}} implementation, I also saw a > significant decrease in the periodicity and a better distribution of keys > amongst partitions (3). > (1): https://i.imgur.com/0FtCZ2A.png > (2): https://www.quora.com/Why-does-Java-use-a-mediocre-hashCode-implementation-for-strings > (3): https://i.imgur.com/8ZuCSA3.png -- This message was sent by Atlassian JIRA (v6.3.15#6346)