Return-Path: X-Original-To: apmail-lucene-solr-user-archive@minotaur.apache.org Delivered-To: apmail-lucene-solr-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 15420D772 for ; Fri, 5 Oct 2012 02:57:05 +0000 (UTC) Received: (qmail 11427 invoked by uid 500); 5 Oct 2012 02:57:02 -0000 Delivered-To: apmail-lucene-solr-user-archive@lucene.apache.org Received: (qmail 11368 invoked by uid 500); 5 Oct 2012 02:57:01 -0000 Mailing-List: contact solr-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-user@lucene.apache.org Delivered-To: mailing list solr-user@lucene.apache.org Received: (qmail 11360 invoked by uid 99); 5 Oct 2012 02:57:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Oct 2012 02:57:01 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of daubman@gmail.com designates 209.85.217.176 as permitted sender) Received: from [209.85.217.176] (HELO mail-lb0-f176.google.com) (209.85.217.176) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Oct 2012 02:56:55 +0000 Received: by mail-lb0-f176.google.com with SMTP id s4so1078260lbc.35 for ; Thu, 04 Oct 2012 19:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=xeMHzKgHVivA4j9aamNUenbA0XJ3qiG1pG7yRbUzc+c=; b=IUf8QqNBOdsftX2KRxxdWbLtckiZ7taQXcrqiUp6zRDRow2IIFCDq2t/JvX3mqfMIC W/iZYhIthFd2gBZExbx6mYgz40x3AL868WqJtG6fOeOEk1PuWU0TRa915dmOP9fR03Kx ObgdyLx7kKDmYwYyuKoJ6ewrjZeGj8ZZ0USYX0Wsmgb4cBeXVn39BsgsuaJmy9G4arS1 RfBzlkPiZu0JHKscKIuEV5Brgo5Do1pGzq/jUUDI4dDWzXDbmxZyvvAgPxvyMPrQkS40 ccw/F9Z1C9sD6HKGFqOtkBFhykiUqcdLvwAKctnlkNcC+R199fKm/wA/OYKdy0kt1LFY BEhQ== MIME-Version: 1.0 Received: by 10.112.47.65 with SMTP id b1mr2412729lbn.32.1349405793844; Thu, 04 Oct 2012 19:56:33 -0700 (PDT) Received: by 10.152.13.7 with HTTP; Thu, 4 Oct 2012 19:56:33 -0700 (PDT) Date: Thu, 4 Oct 2012 22:56:33 -0400 Message-ID: Subject: PriorityQueue:initialize consistently showing up as hot spot while profiling From: Aaron Daubman To: solr-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Greetings, I've been seeing this call chain come up fairly frequently when debugging longer-QTime queries under Solr 3.6.1 but have not been able to understand from the code what is really going on - the call graph and code follow below. Would somebody please explain to me: 1) Why this would show up frequently as a hotspot 2) If it is expected to do so 3) If there is anything I should look in to that may help performance where this frequently shows up as the long pole in the QTime tent 4) What the code is doing and why heap is being allocated as an apparently giant object (which also is apparently not unheard of due to MAX_VALUE wrapping check) ---call-graph--- Filter - SolrDispatchFilter:doFilter (method time = 12 ms, total time = 487 ms) Filter - SolrDispatchFilter:execute:365 (method time = 0 ms, total time = 109 ms) org.apache.solr.core.SolrCore:execute:1376 (method time = 0 ms, total time = 109 ms) org.apache.solr.handler.RequestHandlerBase:handleRequest:129 (method time = 0 ms, total time = 109 ms) org.apache.solr.handler.component.SearchHandler:handleRequestBody:186 (method time = 0 ms, total time = 109 ms) com.echonest.solr.component.EchoArtistGroupingComponent:process:188 (method time = 0 ms, total time = 109 ms) org.apache.solr.search.SolrIndexSearcher:search:375 (method time = 0 ms, total time = 96 ms) org.apache.solr.search.SolrIndexSearcher:getDocListC:1176 (method time = 0 ms, total time = 96 ms) org.apache.solr.search.SolrIndexSearcher:getDocListNC:1209 (method time = 0 ms, total time = 96 ms) org.apache.solr.search.SolrIndexSearcher:getProcessedFilter:796 (method time = 0 ms, total time = 26 ms) org.apache.solr.search.BitDocSet:andNot:185 (method time = 0 ms, total time = 13 ms) org.apache.lucene.util.OpenBitSet:clone:732 (method time = 13 ms, total time = 13 ms) org.apache.solr.search.BitDocSet:intersection:31 (method time = 0 ms, total time = 13 ms) org.apache.solr.search.DocSetBase:intersection:90 (method time = 0 ms, total time = 13 ms) org.apache.lucene.util.OpenBitSet:and:808 (method time = 13 ms, total time = 13 ms) org.apache.lucene.search.TopFieldCollector:create:916 (method time = 0 ms, total time = 46 ms) org.apache.lucene.search.FieldValueHitQueue:create:175 (method time = 0 ms, total time = 46 ms) org.apache.lucene.search.FieldValueHitQueue$MultiComparatorsFieldValueHitQueue::111 (method time = 0 ms, total time = 46 ms) org.apache.lucene.search.SortField:getComparator:409 (method time = 0 ms, total time = 13 ms) org.apache.lucene.search.FieldComparator$FloatComparator::400 (method time = 13 ms, total time = 13 ms) org.apache.lucene.util.PriorityQueue:initialize:108 (method time = 33 ms, total time = 33 ms) ---snip--- org.apache.lucene.util.PriorityQueue:initialize - hotspot is line 108: heap = (T[]) new Object[heapSize]; // T is unbounded type, so this unchecked cast works always ---PriorityQueue.java--- /** Subclass constructors must call this. */ @SuppressWarnings("unchecked") protected final void initialize(int maxSize) { size = 0; int heapSize; if (0 == maxSize) // We allocate 1 extra to avoid if statement in top() heapSize = 2; else { if (maxSize == Integer.MAX_VALUE) { // Don't wrap heapSize to -1, in this case, which // causes a confusing NegativeArraySizeException. // Note that very likely this will simply then hit // an OOME, but at least that's more indicative to // caller that this values is too big. We don't +1 // in this case, but it's very unlikely in practice // one will actually insert this many objects into // the PQ: heapSize = Integer.MAX_VALUE; } else { // NOTE: we add +1 because all access to heap is // 1-based not 0-based. heap[0] is unused. heapSize = maxSize + 1; } } heap = (T[]) new Object[heapSize]; // T is unbounded type, so this unchecked cast works always this.maxSize = maxSize; // If sentinel objects are supported, populate the queue with them T sentinel = getSentinelObject(); if (sentinel != null) { heap[1] = sentinel; for (int i = 2; i < heap.length; i++) { heap[i] = getSentinelObject(); } size = maxSize; } } ---snip--- Thanks, as always! Aaron