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 1glcf1-00043j-4c for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jan 2019 16:42:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1glcez-00013Q-1A for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jan 2019 16:42:53 +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 1glcey-000115-JC for pgsql-hackers@lists.postgresql.org; Mon, 21 Jan 2019 16:42:52 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1glceu-00039c-JK for pgsql-hackers@postgresql.org; Mon, 21 Jan 2019 16:42:51 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 0362021DC89A; Mon, 21 Jan 2019 19:42:46 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.237] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id BA87821DC899; Mon, 21 Jan 2019 19:42:45 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1548088965; bh=Th3CGoyU6adluuB+r/DT7Lk5JZqd1DNMU+JfU/BlaeI=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=aMCEcDoqjEslb25Bzk0W98ah0On1Lb6hWtwnn/AX2XcNPg7WKSLL79OEDGRG21Vfl xZEjywKrWDJCEkfSk/Fz5IIak0a/KHX9lnAis0v/8PM4wjePWcFXibzLDpZCkFlo5D 7Ine9jZNdSp/ZMl+9mdlE/UaoPhtzYcCu6NZ1qyA= Subject: Re: [PROPOSAL] Shared Ispell dictionaries To: Tomas Vondra , 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: Arthur Zakirov Message-ID: <5113daa6-b6e7-59f6-c4a8-96b5b81474fb@postgrespro.ru> Date: Mon, 21 Jan 2019 19:42:45 +0300 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; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 21.01.2019 17:56, Tomas Vondra wrote: > On 1/21/19 12:51 PM, Arthur Zakirov wrote: >> 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 only thing we have is "unload" capability by closing the > connection... BTW, even if the connection was closed and there are no other connections a dictionary still remains "loaded". It is because dsm_pin_segment() is called during loading the dictionary into DSM. > ... > 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). Yes, I thought about such feature too. Agree, it could be expensive since we need to scan pg_ts_dict table to get list of dictionaries (we can't scan dshash_table). I haven't a good solution yet. I just had a thought to return max_shared_dictionaries_size. Then we can unload dictionaries (and scan the pg_ts_dict table) that were accessed a lot time ago if we reached the size limit. We can't set exact size limit since we can't release the memory immediately. So max_shared_dictionaries_size can be renamed to shared_dictionaries_threshold. If it is equal to "0" then PostgreSQL has unlimited space for dictionaries. -- Arthur Zakirov Postgres Professional: http://www.postgrespro.com Russian Postgres Company