Re: [HACKERS] don't use MAKE_PTR/OFFSET for shmem pointers

2008-11-03 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes:
> We now have two very similar doubly-linked list implementations.  Should
> we take one of them out?

If you're thinking of dllist, it has considerably different implementation
assumptions.

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] don't use MAKE_PTR/OFFSET for shmem pointers

2008-11-03 Thread Alvaro Herrera
Tom Lane wrote:
> Kris Jurka <[EMAIL PROTECTED]> writes:
> > Since we require every process to map the shared memory region to the same 
> > address, we don't need the MAKE_PTR/OFFSET code that was needed when that
> > was not the case.  This patch makes shared memory pointers just like 
> > regular pointers.
> 
> Applied with minor editorialization --- mainly, I converted a couple of
> "void *" pointer declarations to more specific types, since it seems to
> me the main point of this is to not use nonspecific pointers
> unnecessarily.

We now have two very similar doubly-linked list implementations.  Should
we take one of them out?

-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] don't use MAKE_PTR/OFFSET for shmem pointers

2008-11-02 Thread Tom Lane
Kris Jurka <[EMAIL PROTECTED]> writes:
> Since we require every process to map the shared memory region to the same 
> address, we don't need the MAKE_PTR/OFFSET code that was needed when that
> was not the case.  This patch makes shared memory pointers just like 
> regular pointers.

Applied with minor editorialization --- mainly, I converted a couple of
"void *" pointer declarations to more specific types, since it seems to
me the main point of this is to not use nonspecific pointers
unnecessarily.

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] don't use MAKE_PTR/OFFSET for shmem pointers

2008-10-28 Thread Kris Jurka


Since we require every process to map the shared memory region to the same 
address, we don't need the MAKE_PTR/OFFSET code that was needed when that
was not the case.  This patch makes shared memory pointers just like 
regular pointers.


http://archives.postgresql.org/pgsql-general/2007-08/msg01510.php

Kris Jurka*** a/src/backend/access/transam/twophase.c
--- b/src/backend/access/transam/twophase.c
***
*** 122,128  typedef struct GlobalTransactionData
  typedef struct TwoPhaseStateData
  {
/* Head of linked list of free GlobalTransactionData structs */
!   SHMEM_OFFSET freeGXacts;
  
/* Number of valid prepXacts entries. */
int numPrepXacts;
--- 122,128 
  typedef struct TwoPhaseStateData
  {
/* Head of linked list of free GlobalTransactionData structs */
!   void * freeGXacts;
  
/* Number of valid prepXacts entries. */
int numPrepXacts;
***
*** 184,190  TwoPhaseShmemInit(void)
int i;
  
Assert(!found);
!   TwoPhaseState->freeGXacts = INVALID_OFFSET;
TwoPhaseState->numPrepXacts = 0;
  
/*
--- 184,190 
int i;
  
Assert(!found);
!   TwoPhaseState->freeGXacts = NULL;
TwoPhaseState->numPrepXacts = 0;
  
/*
***
*** 197,203  TwoPhaseShmemInit(void)
for (i = 0; i < max_prepared_xacts; i++)
{
gxacts[i].proc.links.next = TwoPhaseState->freeGXacts;
!   TwoPhaseState->freeGXacts = MAKE_OFFSET(&gxacts[i]);
}
}
else
--- 197,203 
for (i = 0; i < max_prepared_xacts; i++)
{
gxacts[i].proc.links.next = TwoPhaseState->freeGXacts;
!   TwoPhaseState->freeGXacts = &gxacts[i];
}
}
else
***
*** 243,249  MarkAsPreparing(TransactionId xid, const char *gid,
TwoPhaseState->prepXacts[i] = 
TwoPhaseState->prepXacts[TwoPhaseState->numPrepXacts];
/* and put it back in the freelist */
gxact->proc.links.next = TwoPhaseState->freeGXacts;
!   TwoPhaseState->freeGXacts = MAKE_OFFSET(gxact);
/* Back up index count too, so we don't miss scanning 
one */
i--;
}
--- 243,249 
TwoPhaseState->prepXacts[i] = 
TwoPhaseState->prepXacts[TwoPhaseState->numPrepXacts];
/* and put it back in the freelist */
gxact->proc.links.next = TwoPhaseState->freeGXacts;
!   TwoPhaseState->freeGXacts = gxact;
/* Back up index count too, so we don't miss scanning 
one */
i--;
}
***
*** 263,275  MarkAsPreparing(TransactionId xid, const char *gid,
}
  
/* Get a free gxact from the freelist */
!   if (TwoPhaseState->freeGXacts == INVALID_OFFSET)
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
 errmsg("maximum number of prepared 
transactions reached"),
 errhint("Increase max_prepared_transactions 
(currently %d).",
 max_prepared_xacts)));
!   gxact = (GlobalTransaction) MAKE_PTR(TwoPhaseState->freeGXacts);
TwoPhaseState->freeGXacts = gxact->proc.links.next;
  
/* Initialize it */
--- 263,275 
}
  
/* Get a free gxact from the freelist */
!   if (TwoPhaseState->freeGXacts == NULL)
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
 errmsg("maximum number of prepared 
transactions reached"),
 errhint("Increase max_prepared_transactions 
(currently %d).",
 max_prepared_xacts)));
!   gxact = (GlobalTransaction)TwoPhaseState->freeGXacts;
TwoPhaseState->freeGXacts = gxact->proc.links.next;
  
/* Initialize it */
***
*** 452,458  RemoveGXact(GlobalTransaction gxact)
  
/* and put it back in the freelist */
gxact->proc.links.next = TwoPhaseState->freeGXacts;
!   TwoPhaseState->freeGXacts = MAKE_OFFSET(gxact);
  
LWLockRelease(TwoPhaseStateLock);
  
--- 452,458 
  
/* and put it back in the freelist */
gxact->proc.links.next = TwoPhaseState->freeGXacts;
!   TwoPhaseState->freeGXacts = gxact;