Re: easy way of copying regex_t

From: Artur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Tomas Vondra <tv(at)fuzzy(dot)cz>
Subject: Re: easy way of copying regex_t
Date: 2016-01-24 21:10:02
Message-ID: 56A53DAA.7030406@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Hi all,
>
> I've been working on moving an extension that allows to move the ispell
> dictionaries to shared segment. It's almost complete, the last FIXME is
> about copying regex_t structure (stored in AFFIX).
>
> According to regex.h the structure is fairly complex and not exactly easy
> to understand, so I'd like to know if anyone here already implemented that
> or something that may serve the same purpose. Any ideas?
>
> kind regards
> Tomas

This message is the reply to the message
http://www.postgresql.org/message-id/dd02a31fdeffbf5cb24771e34213b40f.squirrel@sq.gransy.com
Sorry, I can't reply to it directly. I can't get it from archive.

Thank you for your extension shared_ispell. It is very useful. I have
got it from https://github.com/tvondra/shared_ispell
With this message I want to send some patch to your repository with
draft of a code, which allows shared_ispell to copy regex_t.

The main idea of the patch is:
- we doesn't need copy all regex_t structure
- most of fields and structures used only in a compile time
- we need copy structures: guts, colormap, subre, cnfa
- from the subre structure we need only cnfa

colormap represents a directed acyclic graph. cnfa represents a
nondeterministic finite automaton.

In this patch also was done the following:
- added regression tests
- deleted spell.h and spell.c since they have duplicate code
- added shared_ispell.h which declares some structures
- fix an issue when stopFile can be NULL
- fixed countCMPDAffixes since theoretically could be zero affix
- added copyCMPDAffix

Question to hackers. Can such patch be useful as a PostgreSQL patch to
Full-Text search? Is it needed?

shared_ispell loads dictionaries into a shared memory. The main benefits
are:
- saving of memory. Every dictionary is loaded only once. Dictionaries
are not loaded for each backend. In current version of PostgreSQL
dictionaires are loaded for each backend where it was requested.
- saving of time. The first load of a dictionary takes much time. With
this patch dictionaries will be loaded only once.

--
Artur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

Attachment Content-Type Size
regex_t_copy.patch text/x-patch 56.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-01-24 21:17:23 Re: Removing Functionally Dependent GROUP BY Columns
Previous Message David Rowley 2016-01-24 20:53:27 Re: Removing Functionally Dependent GROUP BY Columns