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 72456200C69 for ; Fri, 21 Apr 2017 23:26:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 70D81160B86; Fri, 21 Apr 2017 21:26:09 +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 C06F3160B97 for ; Fri, 21 Apr 2017 23:26:08 +0200 (CEST) Received: (qmail 23900 invoked by uid 500); 21 Apr 2017 21:26:08 -0000 Mailing-List: contact issues-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hive.apache.org Delivered-To: mailing list issues@hive.apache.org Received: (qmail 23891 invoked by uid 99); 21 Apr 2017 21:26:08 -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; Fri, 21 Apr 2017 21:26:07 +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 7FC37C679B for ; Fri, 21 Apr 2017 21:26:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.201 X-Spam-Level: X-Spam-Status: No, score=-99.201 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Qz4meon1m7Yo for ; Fri, 21 Apr 2017 21:26:05 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 60F955FD9A for ; Fri, 21 Apr 2017 21:26:05 +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 DDA13E0D6C for ; Fri, 21 Apr 2017 21:26:04 +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 440E021B5B for ; Fri, 21 Apr 2017 21:26:04 +0000 (UTC) Date: Fri, 21 Apr 2017 21:26:04 +0000 (UTC) From: =?utf-8?Q?Sergio_Pe=C3=B1a_=28JIRA=29?= To: issues@hive.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HIVE-16079) HS2: high memory pressure due to duplicate Properties objects MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 21 Apr 2017 21:26:09 -0000 [ https://issues.apache.org/jira/browse/HIVE-16079?page=3Dcom.atlassian= .jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1597= 9413#comment-15979413 ]=20 Sergio Pe=C3=B1a commented on HIVE-16079: ------------------------------------ The patch looks good [~misha@cloudera.com] +1 I'll wait for the tests before commit it. > HS2: high memory pressure due to duplicate Properties objects > ------------------------------------------------------------- > > Key: HIVE-16079 > URL: https://issues.apache.org/jira/browse/HIVE-16079 > Project: Hive > Issue Type: Improvement > Components: HiveServer2 > Reporter: Misha Dmitriev > Assignee: Misha Dmitriev > Attachments: HIVE-16079.01.patch, HIVE-16079.02.patch, HIVE-16079= .03.patch, hs2-crash-2000p-500m-50q.txt > > > I've created a Hive table with 2000 partitions, each backed by two files,= with one row in each file. When I execute some number of concurrent querie= s against this table, e.g. as follows > {code} > for i in `seq 1 50`; do beeline -u jdbc:hive2://localhost:10000 -n admin = -p admin -e "select count(i_f_1) from misha_table;" & done > {code} > it results in a big memory spike. With 20 queries I caused an OOM in a HS= 2 server with -Xmx200m and with 50 queries - in the one with -Xmx500m. > I am attaching the results of jxray (www.jxray.com) analysis of a heap du= mp that was generated in the 50queries/500m heap scenario. It suggests that= there are several opportunities to reduce memory pressure with not very in= vasive changes to the code. One (duplicate strings) has been addressed in h= ttps://issues.apache.org/jira/browse/HIVE-15882 In this ticket, I am going = to address the fact that almost 20% of memory is used by instances of java.= util.Properties. These objects are highly duplicate, since for each partiti= on each concurrently running query creates its own copy of Partion, Partiti= onDesc and Properties. Thus we have nearly 100,000 (50 queries * 2,000 part= itions) Properties in memory. By interning/deduplicating these objects we m= ay be able to save perhaps 15% of memory. > Note, however, that if there are queries that mutate partitions, the corr= esponding Properties would be mutated as well. Thus we cannot simply use a = single "canonicalized" Properties object at all times for all Partition obj= ects representing the same DB partition. Instead, I am going to introduce a= special CopyOnFirstWriteProperties class. Such an object initially interna= lly references a canonicalized Properties object, and keeps doing so while = only read methods are called. However, once any mutating method is called, = the given CopyOnFirstWriteProperties copies the data into its own table fro= m the canonicalized table, and uses it ever after. -- This message was sent by Atlassian JIRA (v6.3.15#6346)