Re: [HACKERS] 64-bit pgbench V2

2011-02-06 Thread Euler Taveira de Oliveira

Em 06-02-2011 13:09, Bruce Momjian escreveu:


What happened to this idea/patch?


I refactored the patch [1] to not depend on strtoll.


[1] http://archives.postgresql.org/message-id/4d2cccd9@timbira.com


--
  Euler Taveira de Oliveira
  http://www.timbira.com/

--
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] 64-bit pgbench V2

2011-02-06 Thread Bruce Momjian

What happened to this idea/patch?

---

Greg Smith wrote:
> Tom Lane wrote:
> > Please choose a way that doesn't introduce new portability assumptions.
> > The backend gets along fine without strtoll, and I don't see why pgbench
> > should have to require it.
> >   
> 
> Funny you should mention this...it turns out there is some code already 
> there, I just didn't notice it before because it's only the unsigned 
> 64-bit strtoul used, not the signed one I was looking for, and it's only 
> called in one place I didn't previously check.  
> src/interfaces/ecpg/ecpglib/data.c does this:
> 
> *((unsigned long long int *) (var + offset * act_tuple)) = 
> strtoull(pval, &scan_length, 10);
> 
> The appropriate autoconf magic was in the code all along for both 
> versions, so my bad not noticing it until now.  It even transparently 
> remaps the BSD-ism of calling it strtoq.
> 
> I suspect that this alone isn't sufficient to make the code I'm trying 
> to wedge into pgbench to always work on the platforms I consider must 
> haves, because of the weird names like _strtoi64 that Windows uses:  
> http://msdn.microsoft.com/en-us/library/h80404d3(v=VS.80).aspx  In fact, 
> I wouldn't be surprised to discover the ECPG code above doesn't do the 
> right thing if compiled with a 64-bit MSVC version.  Don't expect that's 
> a popular combination to explicitly test in a way that hits the code 
> path where this line is at.
> 
> The untested (I need to setup for building Windows to really confirm 
> this works) next patch attempt I've attached does what I think is the 
> right general sort of thing here.  It extends the autoconf remapping 
> that was already being done to include the second variation on how the 
> function needed can be named in a MSVC build.  This might improve the 
> ECPG compatibility issue I theorize could be there on that platform.  
> Given the autoconf stuff and use of the unsigned version was already a 
> dependency, I'd rather improve that code (so it's more obvious when it 
> is broken) than do the refactoring work suggested to re-use the server's 
> internal 64-bit parsing method instead.  I could split this into two 
> patches instead--"add 64-bit strtoull/strtoll support for MSVC" on the 
> presumption it's actually broken now (possibly wrong on my part) and 
> "make pgbench use 64-bit values"--but it's not so complicated as one.
> 
> I expect there is almost zero overlap between "needs pgbench setshell to 
> return >32 bit return values" and "not on a platform with a working 
> 64-bit strtoull variation".  What I did to hedge against that was add a 
> little check to pgbench that lets you confirm whether setshell lines are 
> limited to 32 bits or not, depending on whether the appropriate function 
> was found.  It tries to fall back to the existing strtol in that case, 
> and I've put a note when that happens (and matching documentation to 
> look for it) into the debug output of the program.
> 
> I'll continue with testing work here, but what's attached is now the 
> first form I think this could potentially be committed in once it's 
> known to be free of obvious bugs (testing at this database scale takes 
> forever).  I can revisit not using the library function instead if Tom 
> or someone else really opposes this new approach.  Given most of the 
> autoconf bits are already there and the limited number of platforms 
> where this is a problem, I think there's little gain for doing that work 
> though.
> 
> Style/functional suggestions appreciated.
> 
> -- 
> Greg Smith  2ndQuadrant US  Baltimore, MD
> PostgreSQL Training, Services and Support
> g...@2ndquadrant.com   www.2ndQuadrant.us
> 


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

-- 
  Bruce Momjian  http://momjian.us
  EnterpriseDB http://enterprisedb.com

  + It's impossible for everything to be true. +

-- 
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] 64-bit pgbench V2

2010-07-12 Thread Greg Smith

Tom Lane wrote:

Please choose a way that doesn't introduce new portability assumptions.
The backend gets along fine without strtoll, and I don't see why pgbench
should have to require it.
  


Funny you should mention this...it turns out there is some code already 
there, I just didn't notice it before because it's only the unsigned 
64-bit strtoul used, not the signed one I was looking for, and it's only 
called in one place I didn't previously check.  
src/interfaces/ecpg/ecpglib/data.c does this:


*((unsigned long long int *) (var + offset * act_tuple)) = 
strtoull(pval, &scan_length, 10);


The appropriate autoconf magic was in the code all along for both 
versions, so my bad not noticing it until now.  It even transparently 
remaps the BSD-ism of calling it strtoq.


I suspect that this alone isn't sufficient to make the code I'm trying 
to wedge into pgbench to always work on the platforms I consider must 
haves, because of the weird names like _strtoi64 that Windows uses:  
http://msdn.microsoft.com/en-us/library/h80404d3(v=VS.80).aspx  In fact, 
I wouldn't be surprised to discover the ECPG code above doesn't do the 
right thing if compiled with a 64-bit MSVC version.  Don't expect that's 
a popular combination to explicitly test in a way that hits the code 
path where this line is at.


The untested (I need to setup for building Windows to really confirm 
this works) next patch attempt I've attached does what I think is the 
right general sort of thing here.  It extends the autoconf remapping 
that was already being done to include the second variation on how the 
function needed can be named in a MSVC build.  This might improve the 
ECPG compatibility issue I theorize could be there on that platform.  
Given the autoconf stuff and use of the unsigned version was already a 
dependency, I'd rather improve that code (so it's more obvious when it 
is broken) than do the refactoring work suggested to re-use the server's 
internal 64-bit parsing method instead.  I could split this into two 
patches instead--"add 64-bit strtoull/strtoll support for MSVC" on the 
presumption it's actually broken now (possibly wrong on my part) and 
"make pgbench use 64-bit values"--but it's not so complicated as one.


I expect there is almost zero overlap between "needs pgbench setshell to 
return >32 bit return values" and "not on a platform with a working 
64-bit strtoull variation".  What I did to hedge against that was add a 
little check to pgbench that lets you confirm whether setshell lines are 
limited to 32 bits or not, depending on whether the appropriate function 
was found.  It tries to fall back to the existing strtol in that case, 
and I've put a note when that happens (and matching documentation to 
look for it) into the debug output of the program.


I'll continue with testing work here, but what's attached is now the 
first form I think this could potentially be committed in once it's 
known to be free of obvious bugs (testing at this database scale takes 
forever).  I can revisit not using the library function instead if Tom 
or someone else really opposes this new approach.  Given most of the 
autoconf bits are already there and the limited number of platforms 
where this is a problem, I think there's little gain for doing that work 
though.


Style/functional suggestions appreciated.

--
Greg Smith  2ndQuadrant US  Baltimore, MD
PostgreSQL Training, Services and Support
g...@2ndquadrant.com   www.2ndQuadrant.us

diff --git a/configure b/configure
index f6b891e..a5371ba 100755
--- a/configure
+++ b/configure
@@ -21624,7 +21624,8 @@ fi
 
 
 
-for ac_func in strtoll strtoq
+
+for ac_func in strtoll strtoq _strtoi64
 do
 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -21726,7 +21727,8 @@ done
 
 
 
-for ac_func in strtoull strtouq
+
+for ac_func in strtoull strtouq _strtoui64
 do
 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
diff --git a/configure.in b/configure.in
index 0a529fa..cca6453 100644
--- a/configure.in
+++ b/configure.in
@@ -1385,8 +1385,8 @@ if test x"$pgac_cv_var_int_optreset" = x"yes"; then
   AC_DEFINE(HAVE_INT_OPTRESET, 1, [Define to 1 if you have the global variable 'int optreset'.])
 fi
 
-AC_CHECK_FUNCS([strtoll strtoq], [break])
-AC_CHECK_FUNCS([strtoull strtouq], [break])
+AC_CHECK_FUNCS([strtoll strtoq _strtoi64], [break])
+AC_CHECK_FUNCS([strtoull strtouq _strtoui64], [break])
 
 # Check for one of atexit() or on_exit()
 AC_CHECK_FUNCS(atexit, [],
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index c830dee..541510b 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -56,6 +56,15 @@
 #include 		/* for getrlimit */
 #endif
 
+/*
+ * If this platform doesn't have a 64-bit strtoll, fall back to
+ * using the 32-bit version.
+ */
+#ifndef HAVE_STRTOLL
+#define strtoll strtol
+#define LIMITED_STRTOLL
+#endif
+
 #

Re: [HACKERS] 64-bit pgbench V2

2010-07-06 Thread Robert Haas
On Tue, Jul 6, 2010 at 11:01 AM, Greg Smith  wrote:
> Robert Haas wrote:
>>
>> It doesn't seem very palatable to have multiple handwritten integer
>> parsers floating around the code base either.  Maybe we should try to
>> standardize something and ship it in src/port, or somesuch
>
> I was considering at one point making two trips through strtol, each allowed
> to gobble 10 characters, then combining the two--just to cut down a little
> bit on the roll your own parser aspects here.  I hadn't really considered
> how the main server does this job though.  If there's something reasonable
> to expose by refactoring some code that's already there, I could take a stab
> at that.  I'm not exactly sure where the integer parsing code in the server
> that would be appropriate is to break out is at though.

Take a look at int8in.  It's got some backend-specific stuff in it ATM
but maybe it would be reasonable to try to fact that out somehow.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

-- 
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] 64-bit pgbench V2

2010-07-06 Thread Greg Smith

Robert Haas wrote:

It doesn't seem very palatable to have multiple handwritten integer
parsers floating around the code base either.  Maybe we should try to
standardize something and ship it in src/port, or somesuch


I was considering at one point making two trips through strtol, each 
allowed to gobble 10 characters, then combining the two--just to cut 
down a little bit on the roll your own parser aspects here.  I hadn't 
really considered how the main server does this job though.  If there's 
something reasonable to expose by refactoring some code that's already 
there, I could take a stab at that.  I'm not exactly sure where the 
integer parsing code in the server that would be appropriate is to break 
out is at though.


--
Greg Smith  2ndQuadrant US  Baltimore, MD
PostgreSQL Training, Services and Support
g...@2ndquadrant.com   www.2ndQuadrant.us


--
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] 64-bit pgbench V2

2010-07-05 Thread Robert Haas
On Mon, Jul 5, 2010 at 8:17 PM, Tom Lane  wrote:
> Greg Smith  writes:
>> The main tricky part was figuring how to convert the \setshell
>> implementation.  That uses strtol to parse the number that should have
>> been returned by the shell call.  It turns out there are a stack of ways
>> to do something similar but return 64 bits instead:
>
> Please choose a way that doesn't introduce new portability assumptions.
> The backend gets along fine without strtoll, and I don't see why pgbench
> should have to require it.

It doesn't seem very palatable to have multiple handwritten integer
parsers floating around the code base either.  Maybe we should try to
standardize something and ship it in src/port, or somesuch.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

-- 
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] 64-bit pgbench V2

2010-07-05 Thread Tom Lane
Greg Smith  writes:
> The main tricky part was figuring how to convert the \setshell 
> implementation.  That uses strtol to parse the number that should have 
> been returned by the shell call.  It turns out there are a stack of ways 
> to do something similar but return 64 bits instead:

Please choose a way that doesn't introduce new portability assumptions.
The backend gets along fine without strtoll, and I don't see why pgbench
should have to require it.

(BTW, I don't actually believe that the proposed code works at all,
since in general strtoll or other variants aren't going to be macros,
but plain functions.)

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