Re: [HACKERS] [GSOC] [Weekly report 2] Eliminate O(N^2) scaling fromrw-conflict tracking in serializable transactions - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: [HACKERS] [GSOC] [Weekly report 2] Eliminate O(N^2) scaling fromrw-conflict tracking in serializable transactions
Date
Msg-id 9d42fe1e-774c-769c-a228-886e58771502@iki.fi
Whole thread Raw
In response to [HACKERS] [GSOC] [Weekly report 2] Eliminate O(N^2) scaling from rw-conflicttracking in serializable transactions  ("Mengxing Liu" <liu-mx15@mails.tsinghua.edu.cn>)
List pgsql-hackers
On 06/15/2017 08:51 AM, Mengxing Liu wrote:
> My design is as follow:
>
> For hash table, key is the pointer of SerializableXact; Value is the RWConflictData object.
> Hashcode is generated based on the SerializableXact pointer.
> So, given a SerializableXact, we can quickly find if it is conflict with another SerializableXact.
>
> Every SerializableXact has two tables: inConflictsTab and outConflictsTab.
> They are allocated and initialized when creating PredXactList (in the function InitPredicateLocks).
> When a SerializableXact object is released, it will release all its RWConflict objects, the hash tables are empty
again.
> Thus They can be reused directly after releasing.
>
> NOTE: I stored RWConflictData in hash tables, instead of RWConflict object allocated by RWConflictPool.
>  After I remove other linked lists, the RWConflictPool can be omitted.

Sounds good!

> My code is on the :
> https://github.com/liumx10/postgresql/commit/3fd9a7488de5ae19ce2ce19eae5f303153a079ff

Once you've ironed out the obvious bugs, make sure to also post it as a 
patch to this mailing list. For the sake of the archives, and to make it 
clear that you're submitting this for inclusion in PostgreSQL, under the 
PostgreSQL license.

Couple of little things caught my eye at a quick glance:

>  * Test whether a hash table is empty.
> + * I didn't find any function in dynamic hash supports the requirement.

You can do: hash_get_num_entries(hashp) == 0

> sprintf(name, "PredXact inConflictsTab %d", i);

Better to use snprintf() instead. sprintf() is safe here, but many 
static analysis tools will complain on any sight of plain sprintf(), so 
better to just never use it.

- Heikki




pgsql-hackers by date:

Previous
From: Mahi Gurram
Date:
Subject: Re: [HACKERS] Regarding Postgres Dynamic Shared Memory (DSA)
Next
From: Petr Jelinek
Date:
Subject: Re: [HACKERS] Refreshing subscription relation state inside atransaction block