Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glb0J-0006MC-Iz for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jan 2019 14:56:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1glb0G-0006XM-JW for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jan 2019 14:56:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glb0G-0006Su-8A for pgsql-hackers@lists.postgresql.org; Mon, 21 Jan 2019 14:56:44 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glb0C-0000qB-Oh for pgsql-hackers@postgresql.org; Mon, 21 Jan 2019 14:56:42 +0000 Received: by mail-wm1-x32f.google.com with SMTP id g67so11047871wmd.2 for ; Mon, 21 Jan 2019 06:56:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=NFegSIcq22JoERJe5uBA0FEO4QHRWczy3S4S3QBZu4M=; b=zV57uCVKcGNG8/GKdgGPmX6eIaTwFP0gh+R8gD1r04lvX9OCaoSm1dIswz0lNx+Q8u gfuVI9k6CKdqM4DvvbkJmnvzHte1fd8Re5fuldVgp/cX1NH+Bbr+hAMNaKzfstHjKi2w eI+DRbjoo59B8p0ijgmSiL1g+TnWRqQZFJKcPuGK7ySWcZIzTf0FgroMhQq249LulNY2 23cuh1fylZmLrN/aIOlGnuLzvsDylguLZB6jNItnBOJdZtkvEhjN960oVE8OkhkAN6/6 aUcDtZ1mjnqK6qcq1qeJExyBPFeact5dGCZiSWxy8JrUXdW4kW1wIlXlltJmP/H0A+Qw i19Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=NFegSIcq22JoERJe5uBA0FEO4QHRWczy3S4S3QBZu4M=; b=aFY3C14ISBiTRIjoS2TrDbmtvbbYxW2fapEJgcx//N/ZDcku5ly/ZtYX9noZgddtAo Ab1YiQ1gtI//AVPuv/aOCBxDyspjDH81VCrObAODnDqj0FEwRHHcSSSeFHz9453iNbV/ 3NPEZpX2SbMtviJ85D1NKDEp5NEwQZlLatdiZWOZS3hMveXqBs4yd3xUuYTTb7jNOspr CHrI2F5Eed9VTQUC0jLp1d3xWH/gmI1VBBzSTnbPAVkKGOnjASEsOJ6pYnSanjFshhaM xv5Q3pt2dP4CxskFowi/KprByM99qiLbyjsyJW3yUfY6RmCf7l7s4BfqhgrTGsckpp+9 8Isg== X-Gm-Message-State: AJcUukfU+jHupNGQvXy6WIw82z1kjB/8o+s/dw1JuPcR9NU0hqOlHrzP oGxIRq8P1u5a9fni/N+IHBd95k+rkCbPJ7uh9JRPOIVM/NI3NYHTNKwYXtFQ+p4+aWD2OcTALEM wIY91Dv29/BhbUyIoVaH9cqYbv/L6MLmC/pBi8UDz885CeqSC++RVTvlJNDmUN4TkyOayyx3SDE BdRvgyjUrG2VM= X-Google-Smtp-Source: ALg8bN56e6G82HtavVTZi8VqGqzRSot+nJGkl0khO4PlmbMSZ+H95rNy9SHfqcXpABzPyXF0S83Wvg== X-Received: by 2002:a1c:63d5:: with SMTP id x204mr24762007wmb.137.1548082598309; Mon, 21 Jan 2019 06:56:38 -0800 (PST) Received: from [10.137.2.19] (ip-86-49-251-50.net.upcbroadband.cz. [86.49.251.50]) by smtp.gmail.com with ESMTPSA id h131sm69342608wmd.17.2019.01.21.06.56.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 06:56:37 -0800 (PST) Subject: Re: [PROPOSAL] Shared Ispell dictionaries To: Arthur Zakirov , Andres Freund Cc: Robert Haas , Tom Lane , Pavel Stehule , pgsql-hackers References: <27296.1522078068@sss.pgh.pa.us> <20180327121954.GA12726@zakirov.localdomain> <20180516113631.GA29544@zakirov.localdomain> <20180614084015.GA12451@zakirov.localdomain> <20181001092204.GA5071@zakirov.localdomain> <68aaaff6-0efe-c14b-7aee-fb110bb97f69@2ndquadrant.com> <337f7a55-58b8-4fcc-a933-5e7799fa6882@postgrespro.ru> <42b1ded6-fd44-5975-77e4-72ada1f134a2@2ndquadrant.com> <20190120222121.ehistvcr4wsu2su5@alap3.anarazel.de> <95aea959-97a1-2ded-c881-eede4e5a1f0c@2ndquadrant.com> From: Tomas Vondra Message-ID: Date: Mon, 21 Jan 2019 15:56:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/21/19 12:51 PM, Arthur Zakirov wrote: > On 21.01.2019 02:43, Tomas Vondra wrote: >> On 1/20/19 11:21 PM, Andres Freund wrote: >>> On 2019-01-20 23:15:35 +0100, Tomas Vondra wrote: >>>> Thanks. I've reviewed v17 today and I haven't discovered any new issues >>>> so far. If everything goes fine and no one protests, I plan to get it >>>> committed over the next week or so. >>> >>> There doesn't seem to be any docs about what's needed to be able to take >>> advantage of shared dicts, and how to prevent them from permanently >>> taking up a significant share of memory. >>> >> >> Yeah, those are good points. I agree the comments might be clearer, but >> essentially ispell dictionaries are shared and everything else is not. >> >> As for the memory consumption / unloading dicts - I agree that's >> something we need to address. There used to be a way to specify memory >> limit and ability to unload dictionaries explicitly, but both features >> have been ditched. The assumption was that UNLOAD would be introduced >> later, but that does not seem to have happened. > > I'll try to implement the syntax, you suggested earlier: > > ALTER TEXT SEARCH DICTIONARY x UNLOAD/RELOAD > > The main point here is that UNLOAD/RELOAD can't release the memory > immediately, because some other backend may pin a DSM. > > The second point we should consider (I think) - how do we know which > dictionary should be unloaded. There was such function earlier, which > was removed. But what about adding an information in the "\dFd" psql's > command output? It could be a column which shows is a dictionary loaded. > The UNLOAD capability is probably a good start, but it's entirely manual and I wonder if it's putting too much burden on the user. I mean, the user has to realize the dictionaries are using a lot of shared memory, has to decide which to unload, and then has to do UNLOAD on it. That's not quite straightforward, especially if there's no way to determine which dictionaries are currently loaded and how much memory they use :-( Of course, the problem is not exactly new - we don't show dictionaries already loaded into private memory. The only thing we have is "unload" capability by closing the connection. OTOH the memory consumption should be much lower thanks to using shared memory. So I think the patch is an improvement even in this regard. I wonder if we could devise some simple cache eviction policy. We don't have any memory limit GUC anymore, but maybe we could use unload dictionaries that were unused for sufficient amount of time (a couple of minutes or so). Of course, the question is when exactly would it happen (it seems far too expensive to invoke on each dict access, and it should happen even when the dicts are not accessed at all). regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services