Hi,
https://wiki.php.net/rfc/size_t_and_int64
The discussion time has come. The work on the feature branch continues. The current patch is stable enough to be discussed.
Regards
Anatol
Hi Anatol
2014/1/10 Anatol Belski ab@php.net:
Hi,
I absolutely love the work, time and effort you have put in to this branch, I've been following it closely on the sideline. There is one thing I'm wondering about, maybe I skipped through some of the sections too fast in the RFC, but what about API BC? I know you propose it for PHP6, but are there gonna be any macros or other helpers for extension developers to ease the use of #ifdefs, I realize things like the parameter parsing one is gonna be tough, but just as a general thought, I think Derick was asking something like this not too long ago?
--
regards,
Kalle Sommer Nielsen
kalle@php.net
Hi Kalle,
Quoted text · 5 lines
Hi Anatol
2014/1/10 Anatol Belski ab@php.net:
Hi,
I absolutely love the work, time and effort you have put in to this branch, I've been following it closely on the sideline. There is one thing I'm wondering about, maybe I skipped through some of the sections too fast in the RFC, but what about API BC? I know you propose it for PHP6, but are there gonna be any macros or other helpers for extension developers to ease the use of #ifdefs, I realize things like the parameter parsing one is gonna be tough, but just as a general thought, I think Derick was asking something like this not too long ago?
thanks for the good words :)
The short answer is: yes. I gonna start with that probably right as next. In plan is the tool for any possible automatic replacements and the header(s) for backward compatibility. That will be a big ease for the first step, though it can of course not replace the manual porting. Parameter parsing is one of the cracky points, but more it will be about the extension code adoption. Especially size_t usage, while being trivial, might get one in a muddle. I personally needed 1-2 hours to habituate size_t, so it works.
Cheers
anatol
Quoted text · 8 lines
Hi Kalle,
Hi Anatol
2014/1/10 Anatol Belski ab@php.net:
Hi,
I absolutely love the work, time and effort you have put in to this branch, I've been following it closely on the sideline. There is one thing I'm wondering about, maybe I skipped through some of the sections too fast in the RFC, but what about API BC? I know you propose it for PHP6, but are there gonna be any macros or other helpers for extension developers to ease the use of #ifdefs, I realize things like the parameter parsing one is gonna be tough, but just as a general thought, I think Derick was asking something like this not too long ago?
thanks for the good words :)
The short answer is: yes. I gonna start with that probably right as next. In plan is the tool for any possible automatic replacements and the header(s) for backward compatibility. That will be a big ease for the first step, though it can of course not replace the manual porting. Parameter parsing is one of the cracky points, but more it will be about the extension code adoption. Especially size_t usage, while being trivial, might get one in a muddle. I personally needed 1-2 hours to habituate size_t, so it works.
Ah, btw it is on the RFC, a couple of sentences under "Migration path for PECL extensions".
Anatol
"Anatol Belski" in php.internals (Fri, 10 Jan 2014 15:58:23 +0100):
https://wiki.php.net/rfc/size_t_and_int64
The discussion time has come. The work on the feature branch continues. The current patch is stable enough to be discussed.
I do not have voting karma, but I can confirm that the current experimental branch is quite stable. I have been testing the experimental builds for Windows (and compiling them myself). In Drupal6, Drupal7, Wordpress and own own code I am getting very few different results compared to the 5.5 releases.
I ran into a segfault with one Drupal7 site (but not with other Drupal7 sites) with opcache enabled. But upon investigating that glitch, I discovered that PHP 5.5 NTS stumbled over the same Drupal7 site with opcache enabled. See the php-windows list for details.
Keep on the good work, Anatol!
Jan
Hi,
https://wiki.php.net/rfc/size_t_and_int64
The discussion time has come. The work on the feature branch continues. The current patch is stable enough to be discussed.
What is the reason behind the renames of IS_LONG to IS_INT (and Z_LVAL to Z_IVAL etc), as well as the renames in zpp (s -> S, etc)? Why can't we keep the old names here? That should reduce the amount of ifndefs involved a lot, as you'd only have to do it for the type declarations themselves, not for every single usage. Or is the point here to intentionally provide a maximum amount of BC breakage, so code doesn't "accidentally" continue to run (e.g. I think that without the renames extensions could continue to run mostly without issue on 32bit.)
Nikita
Hi Nikita,
Quoted text · 5 lines
Hi,
https://wiki.php.net/rfc/size_t_and_int64
The discussion time has come. The work on the feature branch continues. The current patch is stable enough to be discussed.
What is the reason behind the renames of IS_LONG to IS_INT (and Z_LVAL to Z_IVAL etc), as well as the renames in zpp (s -> S, etc)? Why can't we keep the old names here? That should reduce the amount of ifndefs involved a lot, as you'd only have to do it for the type declarations themselves, not for every single usage. Or is the point here to intentionally provide a maximum amount of BC breakage, so code doesn't "accidentally" continue to run (e.g. I think that without the renames extensions could continue to run mostly without issue on 32bit.)
Nikita
the renames you mention like IS_LONG -> IS_INT are thought more for correct semantic, as there is no firm 'long' anymore. The same for Z_STRLEN -> Z_STRSIZE and others. That kind of thing should be done the most obvious way. Well, the max BC reason you gave I like too :)
For the same reason zend_parse_parameters() formats was changed, as it'll issue an error on runtime. However here I still scratch my head as that's a runtime issue, but it should break the compilation as well.
Without semantic replacements many extensions would just continue to compile/run on 32 bit, indeed. Though because of the size_t one could still have some unpleasant surprise in some situation. Besides that, I'd really see that more like a side effect with not very clear use.
With the #ifdef's - there shouldn't be any or should be very few. The compatibility header I've mentioned in one of the previous responses should do it one for all. It can look like
#if PHP_MAJOR_VERSION < 6
define IS_INT IS_LONG
define php_size_t int
.......
#endif
Once included and given an extension is compiled with an older PHP version, that defines should cover the compatibility with older semantics. Some more complicated solution will probably be needed for zpp to replace "i" with "l" and co. for the older PHP. But generally, such a header should make the same ext source in 6.x style compatible with 5.x branch. Of course some exceptions will have to take place, but i think those will be not more than the current mainstream already contains to separate the code for minor versions in 5.x branch.
The migration path is the very next thing I have to do.
Regards
Anatol
Quoted text · 17 lines
Hi Nikita,
Hi,
https://wiki.php.net/rfc/size_t_and_int64
The discussion time has come. The work on the feature branch continues. The current patch is stable enough to be discussed.
What is the reason behind the renames of IS_LONG to IS_INT (and Z_LVAL to Z_IVAL etc), as well as the renames in zpp (s -> S, etc)? Why can't we keep the old names here? That should reduce the amount of ifndefs involved a lot, as you'd only have to do it for the type declarations themselves, not for every single usage. Or is the point here to intentionally provide a maximum amount of BC breakage, so code doesn't "accidentally" continue to run (e.g. I think that without the renames extensions could continue to run mostly without issue on 32bit.)
Nikita
the renames you mention like IS_LONG -> IS_INT are thought more for correct semantic, as there is no firm 'long' anymore. The same for Z_STRLEN -> Z_STRSIZE and others. That kind of thing should be done the most obvious way. Well, the max BC reason you gave I like too :)
For the same reason zend_parse_parameters() formats was changed, as it'll issue an error on runtime. However here I still scratch my head as that's a runtime issue, but it should break the compilation as well.
Without semantic replacements many extensions would just continue to compile/run on 32 bit, indeed. Though because of the size_t one could still have some unpleasant surprise in some situation. Besides that, I'd really see that more like a side effect with not very clear use.
With the #ifdef's - there shouldn't be any or should be very few. The compatibility header I've mentioned in one of the previous responses should do it one for all. It can look like
#if
PHP_MAJOR_VERSION< 6define IS_INT IS_LONG
define php_size_t int
.......
#endifOnce included and given an extension is compiled with an older PHP version, that defines should cover the compatibility with older semantics. Some more complicated solution will probably be needed for zpp to replace "i" with "l" and co. for the older PHP. But generally, such a header should make the same ext source in 6.x style compatible with 5.x branch. Of course some exceptions will have to take place, but i think those will be not more than the current mainstream already contains to separate the code for minor versions in 5.x branch.
The migration path is the very next thing I have to do.
I am really confused on that. How is the compatibility header useful if I still need a ifdef else for zpp and things that boil down to printfs, like error reporting, with 2 different arguments?
Wouldn't it be better to not change them, but maybe force extensions to define a _I_SUPPORT_PHP6, if not defined refuse to build the ext against PHP6?
Then all I have to do in extension is to include the compat header, change some of my types passed to zpp/printfs and define that macro.. and I could support PHP5 and PHP6.
And if I try to build against PHP6 it would result in compiler failure... We'd maybe need to tweak the build system a tiny bit, and phpize, for that to happen - but that seem to be much easier then supporting PHP5 and 6 for extensions in the same codebase with renamed zpp values?
-Hannes
Hi Hannes,
Quoted text · 21 lines
Hi Nikita,
Hi,
https://wiki.php.net/rfc/size_t_and_int64
The discussion time has come. The work on the feature branch continues. The current patch is stable enough to be discussed.
What is the reason behind the renames of IS_LONG to IS_INT (and Z_LVAL to
Z_IVAL etc), as well as the renames in zpp (s -> S, etc)? Why can't we keep the old names here? That should reduce the amount of ifndefs involved a lot, as you'd only have to do it for the type declarations themselves, not for every single usage. Or is the point here to intentionally provide a maximum amount of BC breakage, so code doesn't "accidentally" continue
to run (e.g. I think that without the renames extensions could continue to run mostly without issue on 32bit.)Nikita
the renames you mention like IS_LONG -> IS_INT are thought more for correct semantic, as there is no firm 'long' anymore. The same for Z_STRLEN -> Z_STRSIZE and others. That kind of thing should be done the most obvious way. Well, the max BC reason you gave I like too :)
For the same reason zend_parse_parameters() formats was changed, as it'll issue an error on runtime. However here I still scratch my head as that's a runtime issue, but it should break the compilation as well.
Without semantic replacements many extensions would just continue to compile/run on 32 bit, indeed. Though because of the size_t one could still have some unpleasant surprise in some situation. Besides that, I'd
really see that more like a side effect with not very clear use.With the #ifdef's - there shouldn't be any or should be very few. The compatibility header I've mentioned in one of the previous responses should do it one for all. It can look like
#if
PHP_MAJOR_VERSION< 6define IS_INT IS_LONG
define php_size_t int
.......
#endifOnce included and given an extension is compiled with an older PHP version, that defines should cover the compatibility with older semantics. Some more complicated solution will probably be needed for zpp to replace "i" with "l" and co. for the older PHP. But generally, such a header should make the same ext source in 6.x style compatible with 5.x branch. Of course some exceptions will have to take place, but i think those will be not more than the current mainstream already contains to separate the code for minor versions in 5.x branch.
The migration path is the very next thing I have to do.
I am really confused on that. How is the compatibility header useful if I still need a ifdef else for zpp and things that boil down to printfs, like error reporting, with 2 different arguments? with the php_error_docref() - very good point, the header can't help much. Except to define something like php_error_docref_comp() as a wrapper function in the compat header, so %pd and alike can be replaced on runtime. The code might miss some #ifdefs then, so be cleaner.
Wouldn't it be better to not change them, but maybe force extensions to define a _I_SUPPORT_PHP6, if not defined refuse to build the ext against PHP6?
Yeah, I'd say an explicit define to indicate PHP6 readiness is good point as well.
About zpp I've got a click - the compatibility with 5.x can be integrated into zpp itself in 6.x. I mean look here http://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_API.c;hb=refs/heads/str_size_and_int64#l326
- 'l' and 'L' was replaced with 'i' and 'I', but nothing prevents to turn those formats as aliases in 6.x. That way 'l' and 'i' and another pairs will do the same thing, new implementations can use clean semantics, and the old formats can be removed after 5.x EOL. This solution however won't force the new semantic.
Another way i could suggest for zpp is similarly to docrefs using a wrapper like zend_parse_parameters_comp(), which would replace new for old. Still not very nice but would guarantee semantically correct formats.
Then all I have to do in extension is to include the compat header, change some of my types passed to zpp/printfs and define that macro.. and I could support PHP5 and PHP6.
And if I try to build against PHP6 it would result in compiler failure... We'd maybe need to tweak the build system a tiny bit, and phpize, for that to happen - but that seem to be much easier then supporting PHP5 and 6 for extensions in the same codebase with renamed zpp values?
Sounds plausible to me. Parameters parsing and spprintf are the only cracky places I can think of now, the other macros/function renames should be easy covered with the compat header, so can me machinable replaced with some tool, even sed script.
The _I_SUPPORT_PHP6 def (should be defined before includes) can be checked directly in php.h, where an #error can be thrown. That sounds like a sane migration workflow. Like if I'm not aware of 6.x and try to compile just right on, it'll reject. If I explicitly say, that i'm ready for 6.x, means i've done the porting work before.
So for the migration it'd be like
- run the replacement tool on the sources for simple semantic fixes
- include compat header
- #define PHP6_SUPPORTED
- replace appropriate things with *_compat() wrappers or do some #ifdefs
- fix datatypes for function args
- fix the extension code where appropriate (that might be big or not, as Jan meant some exts he's tried was easy)
- check if it plays good with some lib i link against, do some range checks eventually
Sounds like a plan.
Thanks for the ideas!
Anatol
Hi Anatol,
About zpp I've got a click - the compatibility with 5.x can be integrated into zpp itself in 6.x. I mean look here
http://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_API.c;hb=refs/heads/str_size_and_int64#l326
- 'l' and 'L' was replaced with 'i' and 'I', but nothing prevents to turn those formats as aliases in 6.x. That way 'l' and 'i' and another pairs will do the same thing, new implementations can use clean semantics, and the old formats can be removed after 5.x EOL. This solution however won't force the new semantic.
I agree with keeping old flags ('l', 'p', 's'...). I think that would be good to add range checks to zend_parse_arg_impl for these flags. If the casted value is bigger (LONG_MAX, INT_MAX...), then warning. It would be really helpful and simplify the migration for library wrappers where these checks needs to be usually done...
Thanks
Jakub
Hi Jakub,
Quoted text · 5 lines
Hi Anatol,
About zpp I've got a click - the compatibility with 5.x can be integrated into zpp itself in 6.x. I mean look here
http://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_API.c;hb=refs/head s/str_size_and_int64#l326 - 'l' and 'L' was replaced with 'i' and 'I', but nothing prevents to turn those formats as aliases in 6.x. That way 'l' and 'i' and another pairs
will do the same thing, new implementations can use clean semantics, and the old formats can be removed after 5.x EOL. This solution however won't force the new semantic.I agree with keeping old flags ('l', 'p', 's'...). I think that would be good to add range checks to zend_parse_arg_impl for these flags. If the casted value is bigger (LONG_MAX, INT_MAX...), then warning. It would be really helpful and simplify the migration for library wrappers where these checks needs to be usually done...
the range checks is what 'L' vs 'I' would stand for, the 'L' would be available as alias for 'I', so one don't has to change zpp. A good thing were to add type checks,
with gcc http://gcc.gnu.org/onlinedocs/gcc/Typeof.html , however not sure it's available with Visual Studio.
Regards
Anatol
the range checks is what 'L' vs 'I' would stand for, the 'L' would be available as alias for 'I', so one don't has to change zpp. A good thing were to add type checks,
Oh I see. The only small objection is that these lines could lead to the unexpected result from the user point of view:
if (d > ZEND_INT_MAX) {
*p = ZEND_INT_MAX;
break;
} else if (d < ZEND_INT_MIN) {
*p = ZEND_INT_MIN;
break;
}
I think that would make sense to add warning here
Also similar checks for "s" and "p" length part (size_t -> int) would be great too! ;)
Thanks
Regards
Jakub
Quoted text · 8 lines
the range checks is what 'L' vs 'I' would stand for, the 'L' would be available as alias for 'I', so one don't has to change zpp. A good thing were to add type checks,
Oh I see. The only small objection is that these lines could lead to the unexpected result from the user point of view:
if (d > ZEND_INT_MAX) { *p = ZEND_INT_MAX;
break; } else if (d < ZEND_INT_MIN) {
*p = ZEND_INT_MIN;
break; }I think that would make sense to add warning here
Also similar checks for "s" and "p" length part (size_t -> int) would be great too! ;)
yep, that's exactly how it performs till now in the mainstream, just replace ZEND_INT_MAX with LONG_MAX. Adding a warning to every such case would cause a warning flood in many PHP apps, guaranteed :) Whereby it might be ok for debug mode maybe, I wouldn't do it as I can't remember any WTFs about the behavior.
Cheers
Anatol
yep, that's exactly how it performs till now in the mainstream, just replace ZEND_INT_MAX with LONG_MAX. Adding a warning to every such case would cause a warning flood in many PHP apps, guaranteed :) Whereby it might be ok for debug mode maybe, I wouldn't do it as I can't remember any WTFs about the behavior.
I meant adding warning only for overflow cases. Values in existing apps can't be bigger than LONG_MAX so I don't see how it could cause warning flood in the current PHP apps. I don't even think that users will be often using such a big values after the 64bit changes.
The thing is that if I use value bigger than LONG_MAX after 64bit changes and I pass it to the function defined in extension that does not support it (use "l" in zpp), then I rather see warning than unexpected rounding to LONG_MAX... There is no way how to find out (except looking to the ext sources) that the big values are not supported. If I get warning, I can fix it in the code straight away...
The another thing is that this checking needs to be done by other libraries wrappers after getting parameters because the most libraries using smaller types. That was exactly what I did when I worked on openssl ext for 64bit and I will need to do it in my fann and crypto extension. There are bunch of other extensions that will need to do it too (for example imagick). The difference with openssl changes is that the BC will need to be kept. I am sure that if warnings were already in zend_parse_arg_impl, then the work for supporting 64bit branch would much easier for me and other PECL extension maintainers...
Cheers
Jakub
Hi Jakub,
yep, that's exactly how it performs till now in the mainstream, just replace ZEND_INT_MAX with LONG_MAX. Adding a warning to every such case would cause a warning flood in many PHP apps, guaranteed :) Whereby it might be ok for debug mode maybe, I wouldn't do it as I can't remember any WTFs about the behavior.
I meant adding warning only for overflow cases. Values in existing apps can't be bigger than LONG_MAX so I don't see how it could cause warning flood in the current PHP apps. I don't even think that users will be often using such a big values after the 64bit changes.
The thing is that if I use value bigger than LONG_MAX after 64bit changes and I pass it to the function defined in extension that does not support it (use "l" in zpp), then I rather see warning than unexpected rounding to LONG_MAX... There is no way how to find out (except looking to the ext sources) that the big values are not supported. If I get warning, I can fix it in the code straight away...
But isn't it the exact situation now on ILP32 vs LP64 systems? Like 32 vs 64 bit Linux? I haven't suggested 'l' to handle the param the old way, just it to be an alias for 'i'. In the new code that would be as dynamic as php_int_t is, however 'l' as alias would retain zpp compatibility to the older PHP.
For instance how much sense had such a centralized warding for the snippet is_int(PHP_INT_MAX+1) ? There is a lot of functions accepting an arbitrary numeric value and not depending on any library, why they should throw a warning by default? Why should we throw a warning about 32 bit in the 64 bit build? Furtehrmore, LONG_MAX is 64 bit on LP64 systems, that would be the same as PHP_INT_MAX.
The another thing is that this checking needs to be done by other libraries wrappers after getting parameters because the most libraries using smaller types. That was exactly what I did when I worked on openssl ext for 64bit and I will need to do it in my fann and crypto extension. There are bunch
of other extensions that will need to do it too (for example imagick). The difference with openssl changes is that the BC will need to be kept. I am sure that if warnings were already in zend_parse_arg_impl, then the work for supporting 64bit branch would much easier for me and other PECL extension maintainers...
Yes, that's the case - the range checks have to be done locally according to what the wrapped library needs. If you haven't done them till now, you might have an issue on 64 bit linux anyway. Like say the lib uses int, but 64 bit long is passed. If that checks are already in place in your ext, then it's fine.
The range checks you've done for openssl are the obligatory part, that's what I was doing as well for all the other extensions. Some are still pending as on the progress wiki page. And of course this is to mention in the porting guide. The libraries are different, for instance iconv uses size_t for string length, libxml uses int for string length. zpp cannot know, which library an extension uses. On the other hand - an extension without any library deps but with some math functions should be kept in mind, too.
Regards
anatol
Quoted text · 7 lines
Hi Jakub,
yep, that's exactly how it performs till now in the mainstream, just replace ZEND_INT_MAX with LONG_MAX. Adding a warning to every such case would cause a warning flood in many PHP apps, guaranteed :) Whereby it might be ok for debug mode maybe, I wouldn't do it as I can't remember any WTFs about the behavior.
I meant adding warning only for overflow cases. Values in existing apps can't be bigger than LONG_MAX so I don't see how it could cause warning flood in the current PHP apps. I don't even think that users will be often using such a big values after the 64bit changes.
The thing is that if I use value bigger than LONG_MAX after 64bit changes and I pass it to the function defined in extension that does not support it (use "l" in zpp), then I rather see warning than unexpected rounding to
LONG_MAX... There is no way how to find out (except looking to the ext sources) that the big values are not supported. If I get warning, I can fix it in the code straight away...But isn't it the exact situation now on ILP32 vs LP64 systems? Like 32 vs 64 bit Linux? I haven't suggested 'l' to handle the param the old way, just it to be an alias for 'i'. In the new code that would be as dynamic as php_int_t is, however 'l' as alias would retain zpp compatibility to the older PHP.
For instance how much sense had such a centralized warding for the snippet is_int(PHP_INT_MAX+1) ? There is a lot of functions accepting an arbitrary numeric value and not depending on any library, why they should throw a warning by default? Why should we throw a warning about 32 bit in the 64 bit build? Furtehrmore, LONG_MAX is 64 bit on LP64 systems, that would be the same as PHP_INT_MAX.
This is of course just about LLP64 when the situation has changed. I think that we are talking about slightly different things. Sorry my first example was a bit incorrect (ZEND_INT_MAX = _I64_MAX which is bigger than LONG_MAX on LLP64)
What I was suggesting is keeping BC for code like this: ...
long n;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &n) == FAILURE) {
return; }
...
The warning would be thrown if it's bigger than LONG_MAX or smaller than LONG_MIN.
If I understood correctly you are suggesting using php_int_t for n (defined in compat header as long if not defined in php.h)? The problem is that the type would be dependent on PHP versions and when you need to be sure that it's a long (which might be the case when you pass it to the another lib function), then you need to check PHP_API_VERSION and in case it's not long, you have to do range check.
In general, I think that would be better to keep BC for "l" and use it just for long values (the "l" actually stands for long... :) ). That could be achieved adding range checks with warning if the value is bigger than LONG_MAX or smaller than LONG_MIN in zend_parse_arg_impl (it would probably require small changes in zend_parse_arg [expected_value...]).
Btw. I see your point about the arbitary number. But I also feel that it would be better to keep it as long as it would keep the same behavior when passed to external libs.
Cheers
Jakub
Hi Jakub,
Quoted text · 14 lines
Hi Jakub,
yep, that's exactly how it performs till now in the mainstream, just replace ZEND_INT_MAX with LONG_MAX. Adding a warning to every such case would cause a warning flood in many PHP apps, guaranteed :) Whereby it
might be ok for debug mode maybe, I wouldn't do it as I can't remember any WTFs about the behavior.I meant adding warning only for overflow cases. Values in existing apps can't be bigger than LONG_MAX so I don't see how it could cause warning flood in the current PHP apps. I don't even think that users will be often using such a big values after the 64bit changes.
The thing is that if I use value bigger than LONG_MAX after 64bit changes and I pass it to the function defined in extension that does not support it (use "l" in zpp), then I rather see warning than unexpected rounding
to
LONG_MAX... There is no way how to find out (except looking to the ext sources) that the big values are not supported. If I get warning, I can
fix it in the code straight away...But isn't it the exact situation now on ILP32 vs LP64 systems? Like 32 vs 64 bit Linux? I haven't suggested 'l' to handle the param the old way, just it to be an alias for 'i'. In the new code that would be as dynamic as php_int_t is, however 'l' as alias would retain zpp compatibility to the older PHP.
For instance how much sense had such a centralized warding for the snippet is_int(PHP_INT_MAX+1) ? There is a lot of functions accepting an arbitrary numeric value and not depending on any library, why they should throw a warning by default? Why should we throw a warning about 32 bit in the 64
bit build? Furtehrmore, LONG_MAX is 64 bit on LP64 systems, that would be the same as PHP_INT_MAX.This is of course just about LLP64 when the situation has changed. I think that we are talking about slightly different things. Sorry my first example was a bit incorrect (ZEND_INT_MAX = _I64_MAX which is bigger than LONG_MAX
on LLP64)
well, there's no another chance to understand each other than using some verbal devices :)
Quoted text · 7 lines
What I was suggesting is keeping BC for code like this: ...
long n; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &n) == FAILURE) {
return; } ...
The warning would be thrown if it's bigger than LONG_MAX or smaller than LONG_MIN.If I understood correctly you are suggesting using php_int_t for n (defined
in compat header as long if not defined in php.h)? The problem is that the type would be dependent on PHP versions and when you need to be sure that it's a long (which might be the case when you pass it to the another lib function), then you need to check PHP_API_VERSION and in case it's not long, you have to do range check.
If a library expects long, in the new code that's the issue on 32 bit windows only. So yes, probably the way you describe is plausible, check PHP_WIN32 and PHP_API_VERSION. Honestly, right at the place where I sit, I can't remember any library working with long (well, timeval struct and so on, not really libs). There are int, size_t, int64_t, ... so while the case you describe is of course possible, it's rather an exception. Usually a simple runtime range check will be good enough, if needed at all.
In general, I think that would be better to keep BC for "l" and use it just for long values (the "l" actually stands for long... :) ). That could be achieved adding range checks with warning if the value is bigger than LONG_MAX or smaller than LONG_MIN in zend_parse_arg_impl (it would probably require small changes in zend_parse_arg [expected_value...]).
Just to remind, your very first reply was to the mail about the zpp compatibility, namely so then one wouldn't have to touch zpp calls for migration, only the variables. That's why i've suggested to alias the new formats with old. If we let 'l' to do the old thing, then zpp will have to be touched at many places to be replaced with 'i' with all the corresponding consequences. So retaining the functional compatibliity with 'l', an easier migration way is not possible. Also I'm asking myself, how essential it really is, in the light of how many libs will profit from one or another way.
Regards
anatol
If I understood correctly you are suggesting using php_int_t for n (defined
in compat header as long if not defined in php.h)? The problem is that the type would be dependent on PHP versions and when you need to be sure that it's a long (which might be the case when you pass it to the another lib function), then you need to check PHP_API_VERSION and in case it's not long, you have to do range check. If a library expects long, in the new code that's the issue on 32 bit windows only. So yes, probably the way you describe is plausible, check PHP_WIN32 and PHP_API_VERSION.
Err, it's issue only on windows 64 bit, as php_int_t is __int64 there. So the macros needs check _WIN64 only, not PHP_WIN32.
Regards
Anatol
Hi Anatol,
If a library expects long, in the new code that's the issue on 32 bit windows only. So yes, probably the way you describe is plausible, check PHP_WIN32 and PHP_API_VERSION. Honestly, right at the place where I sit, I can't remember any library working with long (well, timeval struct and so on, not really libs). There are int, size_t, int64_t, ... so while the case you describe is of course possible, it's rather an exception. Usually a simple runtime range check will be good enough, if needed at all.
Actually there is one big library where you can find it. It's OpenSSL which is why I was asking about it.. :) There are quite a few places where it's used. The main ones are following:
- ASN.1 API functions (I plan to completely wrap it :) ) where it's used for data length.
- BIO_ctrl for length parameter (BIO_ctrl is a definition result for many macros like BIO_set_mem_buf, BIO_set_buffer_size, BIO_set_write_buf_size...)
- Big numbers - there is a situation a bit more complicated but unsigned long is used (there will be necessary some other checks anyway so it's not an issue)
I think that would be good to have a look to the other exts and double check if used libs have long parameters for data lengths. If not, then I agree with you that there is no point to do casting to long with warnings just because of OpenSSL.
However it would be good to define in compat header a macro for checking that long != php_int_t . I know that it's currently only _WIN64 but if you implement enabling 64bit on 32bit platform (future scope in the RFC :) ), then there will be an extra definition.
Cheers
Jakub
Quoted text · 9 lines
Hi Anatol,
Jakub
If a library expects long, in the new code that's the issue on 32 bit windows only. So yes, probably the way you describe is plausible, check PHP_WIN32 and PHP_API_VERSION. Honestly, right at the place where I sit, I can't remember any library working with long (well, timeval struct and so on, not really libs). There are int, size_t, int64_t, ... so while the case you describe is of course possible, it's rather an exception. Usually a simple runtime range check will be good enough, if needed at all.
Actually there is one big library where you can find it. It's OpenSSL which is why I was asking about it.. :) There are quite a few places where it's used. The main ones are following:
- ASN.1 API functions (I plan to completely wrap it :) ) where it's used for data length.
- BIO_ctrl for length parameter (BIO_ctrl is a definition result for many macros like BIO_set_mem_buf, BIO_set_buffer_size, BIO_set_write_buf_size...)
- Big numbers - there is a situation a bit more complicated but unsigned long is used (there will be necessary some other checks anyway so it's not an issue)
I think that would be good to have a look to the other exts and double check if used libs have long parameters for data lengths. If not, then I agree with you that there is no point to do casting to long with warnings just because of OpenSSL.
However it would be good to define in compat header a macro for checking that long != php_int_t . I know that it's currently only _WIN64 but if you implement enabling 64bit on 32bit platform (future scope in the RFC :) ), then there will be an extra definition.
I was thinking a bit more what will be the consequences of asn1 and bio in my ext for "l" flag and it won't be such a big issue regarding to zpp. There are just few cases in asn1 (ASN1_INTEGER_set for example) and BIO stuff will probably require mainly string conversions which is a bit different issue...
What's the actually plan for keeping BC for "s" and "p"? Is it gonna be zend_str_size from compat header and "s" and "p" aliases of "S" and "P"?
Something like...
...
char *s;
zend_str_size len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s, &len) == FAILURE) { return; }
...
If so, I think that that would be a slightly bigger issue (size_t vs int)...
There are only two solutions of zpp "s" that I think of:
- check range (INT_MAX) and cast it to int (possibly throw warning if it's out of range) -> that could result too many warning but it's safe
- PHP version variable zend_str_size (see above) -> the same as discussed for long but considerably more places where we will need to find out what the zend_str_size really is.
What do you think?
Cheers
Jakub
Hi,
About zpp I've got a click - the compatibility with 5.x can be integrated into zpp itself in 6.x. I mean look here http://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_API.c;hb=refs/heads/ str_size_and_int64#l326 - 'l' and 'L' was replaced with 'i' and 'I', but nothing prevents to turn those formats as aliases in 6.x. That way 'l' and 'i' and another pairs
will do the same thing, new implementations can use clean semantics, and the old formats can be removed after 5.x EOL. This solution however won't force the new semantic.Another way i could suggest for zpp is similarly to docrefs using a wrapper like zend_parse_parameters_comp(), which would replace new for old. Still not very nice but would guarantee semantically correct formats.
Here's the first worky header and replacement tool variant http://git.php.net/?p=php-src.git;a=tree;f=compat;h=166ac434f01d38119eb12160f2513cfe99c39b42;hb=refs/heads/str_size_and_int64 . The PECL readme is in progress.
After trying some extensions I come to conclusion, that both of the compatibility variants above are not good.
The first one with aliasing gives no good feeling, after trying in practice - it might lead even to more confusion. The second with the *_compat() - technically it's a bit rubbish, as the specs are literals saved in the readonly TEXT segment, so replacing on the fly costs some allocations on the heap. While still doable, the overhead isn't worthy.
The variant I would suggest is using ternary operator, passing both old and new style, like
COMPAT ? "lLps" : "iIPS"
While being simple, this makes the difference good visible, so is clear. Comparing with the breakages we had in the past like literals between 5.3 and 5.4, syntactically no #ifdef needed as it's done in place.
For the printf formats I'd suggest using ZEND_INT_FMT macros concatenated with the format literal. The quirk here is the same as it's in the TEXT segment. But still, with this solution no #ifdef is needed.
The latter solution suggestions are much simpler and don't need to be done much, what do you think?
The readme is still in progress, however if curious, the current replacement tool and header already do the job, so one can try the porting with minimal effort.
Regards
Anatol
Hi,
the usable porting doc is now available
http://git.php.net/?p=php-src.git;a=blob;f=compat/PECL_PORTING;hb=refs/heads/str_size_and_int64
The replacement tool and the header are in the same folder.
Regards
Anatol
Nikita Popov in php.internals (Fri, 10 Jan 2014 22:42:49 +0100):
Or is the point here to intentionally provide amaximum amount of BC breakage, so code doesn't "accidentally" continue to run (e.g. I think that without the renames extensions could continue to run mostly without issue on 32bit.)
Some of the PECL extensions compiled without really complaining with the new experimental branch (on Windows). Anatol's own xmldiff, php_blenc.dll (but it did not work), php_uploadprogress.dll and php_timezonedb.dll.
The BC break should probably be even greater, so that cases like the blenc extension do not occur.
I have converted one of my own extensions (that is not even on PECL): php_ffmpeg.dll. I did not do that (yet) with ifndef's, but just with global searching and replacing. So I have two sources for the same extension right now.
Jan
I completely agree with Nikita.
Why to rename LONG->INT STRLEN->STRSIZE in thousands places? Why not just define zend_long and zend_ulong to be 64-bit on 64-bit platforms and use them instead of int, ulint, zend_int, zend_uint, long, ulong where it's necessary.
Anatol, I understood your point about catching incompatibility code at compile-time, but I'm not sure if the new features cost such huge code base changes.
- 64-bit integers on Windows (they are already 64-bit on other systems)
- 64-bit string length. I don't think many people are interested in that. Fortunately, the patch doesn't change the zval size, so it shouldn't make a lot of harm. However, usage of "zend_size_t" instead of "int" is a bit annoying. I would change it into the same "zend_long" or "zend_ulong".
Thanks. Dmitry.
Quoted text · 5 lines
Hi,
https://wiki.php.net/rfc/size_t_and_int64
The discussion time has come. The work on the feature branch continues. The current patch is stable enough to be discussed.
What is the reason behind the renames of IS_LONG to IS_INT (and Z_LVAL to Z_IVAL etc), as well as the renames in zpp (s -> S, etc)? Why can't we keep the old names here? That should reduce the amount of ifndefs involved a lot, as you'd only have to do it for the type declarations themselves, not for every single usage. Or is the point here to intentionally provide a maximum amount of BC breakage, so code doesn't "accidentally" continue to run (e.g. I think that without the renames extensions could continue to run mostly without issue on 32bit.)
Nikita
I completely agree with Nikita.
Why to rename LONG->INT STRLEN->STRSIZE in thousands places? Why not just define zend_long and zend_ulong to be 64-bit on 64-bit platforms and use them instead of int, ulint, zend_int, zend_uint, long, ulong where it's necessary.Anatol, I understood your point about catching incompatibility code at compile-time, but I'm not sure if the new features cost such huge code base changes.
To catch 64bit issues at compile is immensely valuable. We had so many issues in the past, some of them leading to security issues. It is also a one time job, with a little extra effort for two years. Besides the portability improvements, code review and correctness is one of the goal of this RFC. I can't remember to know any widely known and sane project relying on on other type for buffer length. PHP does not have to be different :)
- 64-bit integers on Windows (they are already 64-bit on other systems)
Almost all :)
- 64-bit string length. I don't think many people are interested in that. Fortunately, the patch doesn't change the zval size, so it shouldn't make a lot of harm. However, usage of "zend_size_t" instead of "int" is a bit annoying. I would change it into the same "zend_long" or "zend_ulong".
It is not about being interested but preventing many security issues as well, by default. The large buffer availability is a good side effect. The implementation correctness is also drastically improved in this case.
Cheers,
Pierre
@pierrejoye | http://www.libgd.org
re,
Quoted text · 8 lines
I completely agree with Nikita.
Why to rename LONG->INT STRLEN->STRSIZE in thousands places? Why not just define zend_long and zend_ulong to be 64-bit on 64-bit platforms and use them instead of int, ulint, zend_int, zend_uint, long, ulong where it's necessary.Anatol, I understood your point about catching incompatibility code at compile-time, but I'm not sure if the new features cost such huge code base changes.
To catch 64bit issues at compile is immensely valuable. We had so many issues in the past, some of them leading to security issues. It is also a one time job, with a little extra effort for two years. Besides the portability improvements, code review and correctness is one of the goal of this RFC. I can't remember to know any widely known and sane project relying on on other type for buffer length. PHP does not have to be different :)
- 64-bit integers on Windows (they are already 64-bit on other systems)
Almost all :)
- 64-bit string length. I don't think many people are interested in that. Fortunately, the patch doesn't change the zval size, so it shouldn't make a lot of harm. However, usage of "zend_size_t" instead of "int" is a bit annoying. I would change it into the same "zend_long" or "zend_ulong".
It is not about being interested but preventing many security issues as well, by default. The large buffer availability is a good side effect. The implementation correctness is also drastically improved in this case.
After a short chat with Dmitry, it seems that the only open questions are:
-
renaming
. pros
. 100% compile time checks, unvaluable
. clarity, no magic as we have now
. code correctness, any 64bit port guides cover things the way we implemented it. cons
. renaming will create extra work for the next 2 years . annoying (while I can live with it given the benefits in the long run) -
SAPIs
We have discussed many times the removal of the dead SAPIs. I think it is time to remove them and keep only those maintained and actually working (some sapis are not even possible to use anymore)
I think we can clear these questions during the vote phases, as options.
If anyone has an idea how to keep the advantage brought by the renaming (compile checks, clarity, code correctness) without actually doing the renaming in extensions, please fire it :)
Cheers,
Pierre
@pierrejoye | http://www.libgd.org
Pierre Joye wrote:
I think we can clear these questions during the vote phases, as options.
If anyone has an idea how to keep the advantage brought by the renaming (compile checks, clarity, code correctness) without actually doing the renaming in extensions, please fire it:)
Is this still being put forward for a PHP5.x build? Surely this along with a tidy up on base modules that support it would be much better used as a base for a new PHP6 plan? Extensions that do not support it can also be left out and we have a clean demarcation.
One thing I would ask is just what 32bit platforms will remain supported. While desktop machines are generally 64bit these days, tablet and mobile devices do still tend to be 32bit. The ITX based systems I'm working with are still 32bit and while they do tend to run as clients to bigger servers, some support their own PHP platform. I already have to support different integer sizes anyway and assuming PHP is 32bit simplifies things but I'm a little unsure how a change to direct support for 64bit might affect that split?
--
Lester Caine - G8HFL
Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
Of course, we are not going to drop 32-bit support :) This patch affects only PHP on 64-bit systems.
Thanks. Dmitry.
Quoted text · 9 lines
Pierre Joye wrote:
I think we can clear these questions during the vote phases, as options.
If anyone has an idea how to keep the advantage brought by the renaming (compile checks, clarity, code correctness) without actually doing the renaming in extensions, please fire it:)
Is this still being put forward for a PHP5.x build? Surely this along with a tidy up on base modules that support it would be much better used as a base for a new PHP6 plan? Extensions that do not support it can also be left out and we have a clean demarcation.
One thing I would ask is just what 32bit platforms will remain supported. While desktop machines are generally 64bit these days, tablet and mobile devices do still tend to be 32bit. The ITX based systems I'm working with are still 32bit and while they do tend to run as clients to bigger servers, some support their own PHP platform. I already have to support different integer sizes anyway and assuming PHP is 32bit simplifies things but I'm a little unsure how a change to direct support for 64bit might affect that split?
--
Lester Caine - G8HFLContact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
Hi Derick,
It would be a significant performance degradation :) Just imagine how to implement 64-bit multiplication and division on 32-bit CPU.
Thanks. Dmitry.
Quoted text · 4 lines
Of course, we are not going to drop 32-bit support :) This patch affects only PHP on 64-bit systems.
Really? I thought it would also make PHP's int type 64-bit even on 32-bit platforms.
cheers,
Derick
Dmitry Stogov wrote:
Hi Derick,
It would be a significant performance degradation :) Just imagine how to implement 64-bit multiplication and division on 32-bit CPU.
My own query was probably more to do with maintaining 32bit results where there is interaction with 32bit only systems. But perhaps the question should rather be 'Just what will be returned as 64bit where it currently is maintained as 32bit?' I was under the impression I got 32bit integers even on 64bit installations and had to use another method to return the 64bit values core to Firebird's generator system.
Thanks. Dmitry.
Of course, we are not going to drop 32-bit support :) This patch affects only PHP on 64-bit systems.
Really? I thought it would also make PHP's int type 64-bit even on 32-bit platforms.
--
Lester Caine - G8HFL
Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
It would be a significant performance degradation :) Just imagine how to implement 64-bit multiplication and division on 32-bit CPU.
I doubt as much. Aren't the vast majority of servers 64-bit anyway? And those that aren't are probably just 32-bit-mode 64-bit CPU servers, which wouldn't be slow, right?
--
Andrea Faulds
http://ajf.me/
It would be a significant performance degradation :) Just imagine how to implement 64-bit multiplication and division on 32-bit CPU.
I doubt as much. Aren't the vast majority of servers 64-bit anyway? And those that aren't are probably just 32-bit-mode 64-bit CPU servers, which wouldn't be slow, right?
RIght, 32bit mode are not slower, at least for basic operations, other ops are slower (couple of more cycles, less registers, etc.). However 64bit mode combined with 64 binaries can be much faster than 32bit binary on the same processor.
Cheers,
Pierre
@pierrejoye | http://www.libgd.org
Unfortunately, my benchmarks on Linux show that 64-bit PHP builds are always a bit slower on real-life applications. It's because 64-bit PHP uses more memory and as result causes more CPU cache misses.
Thanks. Dmitry.
Quoted text · 7 lines
It would be a significant performance degradation :) Just imagine how to implement 64-bit multiplication and division on 32-bit
CPU.I doubt as much. Aren't the vast majority of servers 64-bit anyway? And those that aren't are probably just 32-bit-mode 64-bit CPU servers, which wouldn't be slow, right?
RIght, 32bit mode are not slower, at least for basic operations, other ops are slower (couple of more cycles, less registers, etc.). However 64bit mode combined with 64 binaries can be much faster than 32bit binary on the same processor.
Cheers,
Pierre
@pierrejoye | http://www.libgd.org
Hi Dmitry,
Unfortunately, my benchmarks on Linux show that 64-bit PHP builds are always a bit slower on real-life applications. It's because 64-bit PHP uses more memory and as result causes more CPU cache misses.
i suppose the perf test on windows to be done today.
That topic was also it my mind while worked on str_size_and_int64 branch. What I have seen is that till now PHP code doesn't really care about 64 bit performance. I was reading the "Software Optimization Guide for AMD64 Processors" http://support.amd.com/TechDocs/25112.PDF and comparing with their recomendations one can find many places in PHP code needing some refactoring. Some primitive points to name like use of non contiguous values in switches, 32 bit vars in loops, no homogeneous 64 bit vars usage, etc. - could be improved. One of good moves is usage of the const qualifier lately. Now with the consistent 64 bit support such a refactoring would have base and sense.
Regards
Anatol
I would be glad t see any 64-bit performance related improvements.
BTW: the performance degradation is expected. Each pointer is 64-bit instead of 32-bit => more memory consumption => more CPU cache pressure => more CPU cache misses.
On the other hand x86-64 uses more CPU registers, MMX, SSE, passes arguments in registers, so it's usually faster on small tasks that keep working set in CPU caches.
Thanks. Dmitry.
Quoted text · 7 lines
Hi Dmitry,
Unfortunately, my benchmarks on Linux show that 64-bit PHP builds are always a bit slower on real-life applications. It's because 64-bit PHP uses
more memory and as result causes more CPU cache misses.i suppose the perf test on windows to be done today.
That topic was also it my mind while worked on str_size_and_int64 branch. What I have seen is that till now PHP code doesn't really care about 64 bit performance. I was reading the "Software Optimization Guide for AMD64 Processors" http://support.amd.com/TechDocs/25112.PDF and comparing with their recomendations one can find many places in PHP code needing some refactoring. Some primitive points to name like use of non contiguous values in switches, 32 bit vars in loops, no homogeneous 64 bit vars usage, etc. - could be improved. One of good moves is usage of the const qualifier lately. Now with the consistent 64 bit support such a refactoring would have base and sense.
Regards
Anatol
Hi Dmitry,
I would be glad t see any 64-bit performance related improvements.
BTW: the performance degradation is expected. Each pointer is 64-bit instead of 32-bit => more memory consumption => more CPU cache pressure => more CPU cache misses.
On the other hand x86-64 uses more CPU registers, MMX, SSE, passes arguments in registers, so it's usually faster on small tasks that keep working set in CPU caches.
Wouldn't then the small parts improve the whole? Fixing the small cases laying on the surface like implicit 32 vs 64 bit type conversions, better struct packing and similar measures would already contribute to more efficient processor and memory usage. That would probably turn many things even more upside down though :) As yep, potentially 64 bit should be faster, so it's worth a try to lean PHP towards.
Especially as you welcome it, I would put the topic on my todo after properly finishing this RFC. Besides potential improvement that's also an exciting matter.
Regards
Anatol
Anatol Belski wrote:
Quoted text · 5 lines
I would be glad t see any 64-bit performance related improvements.
BTW: the performance degradation is expected. Each pointer is 64-bit instead of 32-bit => more memory consumption => more CPU cache pressure => more CPU cache misses.
On the other hand x86-64 uses more CPU registers, MMX, SSE, passes arguments in registers, so it's usually faster on small tasks that keep working set in CPU caches.
Wouldn't then the small parts improve the whole? Fixing the small cases laying on the surface like implicit 32 vs 64 bit type conversions, better struct packing and similar measures would already contribute to more efficient processor and memory usage. That would probably turn many things even more upside down though:) As yep, potentially 64 bit should be faster, so it's worth a try to lean PHP towards.
Especially as you welcome it, I would put the topic on my todo after properly finishing this RFC. Besides potential improvement that's also an exciting matter.
Much of the 'improved performance' provided by later versions of windows is down to faster processors to hide the extra bloat created. They have adopted having a 32bit version and a 64bit version. Making PHP super efficient on 64bit processors would be useful, but it still misses the point of being able to fall back gracefully to run on 32bit machines? Or is now the time to introduce the same differentiation in all builds of PHP? It is built for the platform?
The main problem here is that changing things to be more 64bit efficient could then make things even worse on 32bit? Yes we need to be modernising, but telling users to 'read the source code' to find out where functions are now returning 64 bit values rather than 32bit ones is not the right approach?
--
Lester Caine - G8HFL
Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
Hi Lester,
Quoted text · 10 lines
Anatol Belski wrote:
I would be glad t see any 64-bit performance related improvements.
BTW: the performance degradation is expected. Each pointer is 64-bit
instead of 32-bit => more memory consumption => more CPU cache pressure => more CPU cache misses.On the other hand x86-64 uses more CPU registers, MMX, SSE, passes arguments in registers, so it's usually faster on small tasks that keep working set in CPU caches.
Wouldn't then the small parts improve the whole? Fixing the small cases laying on the surface like implicit 32 vs 64 bit type conversions, better struct packing and similar measures would already contribute to more efficient processor and memory usage. That would probably turn many things even more upside down though:) As yep, potentially 64 bit should be faster, so it's worth a try to lean PHP towards.
Especially as you welcome it, I would put the topic on my todo after properly finishing this RFC. Besides potential improvement that's also an exciting matter.
Much of the 'improved performance' provided by later versions of windows is down to faster processors to hide the extra bloat created. They have adopted having a 32bit version and a 64bit version. Making PHP super efficient on 64bit processors would be useful, but it still misses the point of being able to fall back gracefully to run on 32bit machines? Or is now the time to introduce the same differentiation in all builds of PHP? It is built for the platform?
The main problem here is that changing things to be more 64bit efficient could then make things even worse on 32bit? Yes we need to be modernising, but telling users to 'read the source code' to find out where functions are now returning 64 bit values rather than 32bit ones is not the right approach?
this RFC has no plans to discriminate 32-bit platforms, but merely to improve the 64-bit ones. 32-bit platforms are nowadays mature, consistent and well supported, whereas 64-bit platforms have much more non exhausted potential and still luck on proper software ports at many places.
Regards
Anatol
Hi Dmitry,
Hi Dmitry,
Unfortunately, my benchmarks on Linux show that 64-bit PHP builds are always a bit slower on real-life applications. It's because 64-bit PHP uses more memory and as result causes more CPU cache misses.
i suppose the perf test on windows to be done today.
here's the perf test result I got from Steve. All the numbers are test scores, the meaning is the same as one could already have seen in the other perf tests of this art
http://windows.php.net/downloads/snaps/ostc/pftt/perf/ . Below are also the Steve's notes about what he's seen during tesing.
Regards, Anatol
============= FORWARDED =============
PHP Version Wordpress Drupal
Joomla
str_size_and_int64-x86 NoCache: 68 NoCache: 70
NoCache: 53
Cache: 284 Cache: 393
Cache: 127
php-5.5.8-nts-Win32-VC11-x86 NoCache: 67 NoCache: 69
NoCache: 53
Cache: 280 Cache: 390
Cache: 125
str_size_and_int64-x64 NoCache: 58 NoCache: 64
NoCache: 50
Cache: 313* Cache: 348*
Cache: 100*
php-5.5.8-nts-Win32-VC11-x64 NoCache: 59 NoCache: 65
NoCache: 51
Cache: 270* Cache: **
Cache: **
• The x86 build of the str_size_and_int64 is consistent with the x86 build of 5.5.8.
• The x64 build of the str_size_and_int64 branch was a bit slower than the x86 build of any version, as expected.
• * I had some issues with the x64 versions of 5.5.8 and str_size_and_int64 when testing with opcache enabled. Typically the scripts will test each application three times with 16/32/64 virtual clients. For the str_size_and_int64 build I could get 1 or 2 out of the three runs to produce good results, and then the other runs would just return 500 errors.
• The opcache results I could get from the x64 build of str_size_and_int64 were pretty good, and I even saw better perf with Wordpress for some reason.
• The 5.5.8 x64 build was even worse. With the opcache scenario, I was not able to get decent results for Drupal and Joomla after several attempts.
The results look promising and overall very consistent with standard PHP. However, it’s clear we need to resolve these issues with Opcache and the x64 builds on Windows before 5.6.0-final. Otherwise x64 builds on Windows will be a non-starter for production use.
============= END FORWARDED =============
Quoted text · 27 lines
Hi Dmitry,
Hi Dmitry,
Unfortunately, my benchmarks on Linux show that 64-bit PHP builds are always a bit slower on real-life applications. It's because 64-bit PHP
uses more memory and as result causes more CPU cache misses.i suppose the perf test on windows to be done today.
here's the perf test result I got from Steve. All the numbers are test scores, the meaning is the same as one could already have seen in the other perf tests of this art
http://windows.php.net/downloads/snaps/ostc/pftt/perf/ . Below are also the Steve's notes about what he's seen during tesing.Regards, Anatol
============= FORWARDED =============
PHP Version Wordpress DrupalJoomla
str_size_and_int64-x86 NoCache: 68 NoCache: 70 NoCache: 53
Cache: 284 Cache: 393
Cache: 127php-5.5.8-nts-Win32-VC11-x86 NoCache: 67 NoCache: 69 NoCache: 53
Cache: 280 Cache: 390
Cache: 125str_size_and_int64-x64 NoCache: 58 NoCache: 64 NoCache: 50
Cache: 313* Cache: 348*
Cache: 100*php-5.5.8-nts-Win32-VC11-x64 NoCache: 59 NoCache: 65 NoCache: 51
Cache: 270* Cache: **
Cache: **• The x86 build of the str_size_and_int64 is consistent with the x86 build of 5.5.8. • The x64 build of the str_size_and_int64 branch was a bit slower than the x86 build of any version, as expected. • * I had some issues with the x64 versions of 5.5.8 and str_size_and_int64 when testing with opcache enabled. Typically the scripts will test each application three times with 16/32/64 virtual clients. For the str_size_and_int64 build I could get 1 or 2 out of the three runs to produce good results, and then the other runs would just return 500 errors. • The opcache results I could get from the x64 build of str_size_and_int64 were pretty good, and I even saw better perf with Wordpress for some reason. • The 5.5.8 x64 build was even worse. With the opcache scenario, I was
not able to get decent results for Drupal and Joomla after several attempts.The results look promising and overall very consistent with standard PHP. However, it’s clear we need to resolve these issues with Opcache and the x64 builds on Windows before 5.6.0-final. Otherwise x64 builds on Windows
will be a non-starter for production use.============= END FORWARDED =============
Now with hopefully better looking table.
PHP Version Wordpress Drupal Joomla
str_size_and_int64-x86 NoCache: 68 NoCache: 70 NoCache: 53 Cache: 284 Cache: 393 Cache: 127
php-5.5.8-nts-Win32-VC11-x86 NoCache: 67 NoCache: 69 NoCache: 53 Cache: 280 Cache: 390 Cache: 125
str_size_and_int64-x64 NoCache: 58 NoCache: 64 NoCache: 50 Cache: 313* Cache: 348* Cache: 100*
php-5.5.8-nts-Win32-VC11-x64 NoCache: 59 NoCache: 65 NoCache: 51 Cache: 270* Cache: ** Cache: **
Cheers, Anatol
Some clarifications:
• The x86 build of the str_size_and_int64 is consistent with the x86 build of 5.5.8.
Meaning, no delta between patched and standard branch.
• The x64 build of the str_size_and_int64 branch was a bit slower than the x86 build of any version, as expected.
here we refer to the patched version.
• * I had some issues with the x64 versions of 5.5.8 and
In this case we refer to the standard branch build using the x64 mode of the compiler, no patch applied.
str_size_and_int64 when testing with opcache enabled. Typically the scripts will test each application three times with 16/32/64 virtual clients. For the str_size_and_int64 build I could get 1 or 2 out of the three runs to produce good results, and then the other runs would just return 500 errors.
That's the known issue we have with opcache on 64bit using 64bit binaries. It is due to the memory management. The int64/size_t patch is not causing this bug.
• The 5.5.8 x64 build was even worse. With the opcache scenario, I was not able to get decent results for Drupal and Joomla after several attempts.
Again, we have to keep in mind that the x64 is not the int64/size_t.
cheers,
Pierre
@pierrejoye | http://www.libgd.org
Hi Pierre,
Quoted text · 11 lines
Some clarifications:
• The x86 build of the str_size_and_int64 is consistent with the x86 build
of 5.5.8.Meaning, no delta between patched and standard branch.
• The x64 build of the str_size_and_int64 branch was a bit slower than the
x86 build of any version, as expected.here we refer to the patched version.
• * I had some issues with the x64 versions of 5.5.8 and
In this case we refer to the standard branch build using the x64 mode of the compiler, no patch applied.
str_size_and_int64 when testing with opcache enabled. Typically the scripts will test each application three times with 16/32/64 virtual clients. For the str_size_and_int64 build I could get 1 or 2 out of the three runs to produce good results, and then the other runs would just return 500 errors.
That's the known issue we have with opcache on 64bit using 64bit binaries. It is due to the memory management. The int64/size_t patch is not causing this bug.
If you know how to fix it, please provide a patch.
Thanks. Dmitry.
Quoted text · 6 lines
• The 5.5.8 x64 build was even worse. With the opcache scenario, I was
not able to get decent results for Drupal and Joomla after several attempts.Again, we have to keep in mind that the x64 is not the int64/size_t.
cheers,
Pierre
@pierrejoye | http://www.libgd.org
Hi Dmitry,
If you know how to fix it, please provide a patch.
We will happily provide one, but the last attempt was rejected (removed the fixed addresses). Ideally we should port the MM from wincache, as it covers all these issues pretty well.
Cheers,
Pierre
@pierrejoye | http://www.libgd.org
Fixed addresses were proposed as workaround by someone from Microsoft and they worked fine for 32-bit builds.
I'm not sure if removing them would help for 64-bit in general. It may work on some systems/builds and not on the others. It just can't be guaranteed to work with that windows API.
In case wincache uses some different approach to create shared memory, and it may guarantee multiple processes to map shared segment into the same address space, we should use it.
Thanks. Dmitry.
Quoted text · 6 lines
Hi Dmitry,
If you know how to fix it, please provide a patch.
We will happily provide one, but the last attempt was rejected (removed the fixed addresses). Ideally we should port the MM from wincache, as it covers all these issues pretty well.
Cheers,
Pierre
@pierrejoye | http://www.libgd.org
Fixed addresses were proposed as workaround by someone from Microsoft and they worked fine for 32-bit builds.
I'm not sure if removing them would help for 64-bit in general. It may work on some systems/builds and not on the others. It just can't be guaranteed to work with that windows API.In case wincache uses some different approach to create shared memory, and it may guarantee multiple processes to map shared segment into the same address space, we should use it.
I proposed it before 5.5.0, with a cleaner patch than the initial one.
I will go with the wincache port, it is well tested and works on all architectures.
Cheers,
Pierre
@pierrejoye | http://www.libgd.org
Unfortunately, my benchmarks on Linux show that 64-bit PHP builds are always a bit slower on real-life applications.
It's because 64-bit PHP uses more memory and as result causes more CPU cache misses.
That's something we can solve, it does not sound like a stopper to me. It is also about time to focus on 64bit much more widely, while keeping support for x32.
--
Pierre
@pierrejoye | http://www.libgd.org
it's not a stopper. It's just a fact and it's not related to this patch at all. Any performance related improvements are always welcome :)
X32 is not the same as x86. It is a new ABI (not widely used yet) , it's actually executes 64-bit instructions but uses 32-bit pointers. For tasks that don't really need huge amount of memory, it takes advantages from both (x86 and x86-64) ABIs and as result such applications compiled for X32 may run ~10% faster.
Thanks. Dmitry.
Quoted text · 8 lines
Unfortunately, my benchmarks on Linux show that 64-bit PHP builds are always
a bit slower on real-life applications.
It's because 64-bit PHP uses more memory and as result causes more CPU cache
misses.That's something we can solve, it does not sound like a stopper to me. It is also about time to focus on 64bit much more widely, while keeping support for x32.
--
Pierre@pierrejoye | http://www.libgd.org
Andrea Faulds wrote:
It would be a significant performance degradation :) Just imagine how to implement 64-bit multiplication and division on 32-bit CPU.
I doubt as much. Aren't the vast majority of servers 64-bit anyway? And those that aren't are probably just 32-bit-mode 64-bit CPU servers, which wouldn't be slow, right?
Except that PHP is not just used on servers? I doubt figures are available, but it would be interesting to find out how big the minority is who use PHP to run local applications on local hardware? That hardware may well be 32bit still ...
--
Lester Caine - G8HFL
Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
Quoted text · 4 lines
Pierre Joye wrote:
I think we can clear these questions during the vote phases, as options.
If anyone has an idea how to keep the advantage brought by the renaming (compile checks, clarity, code correctness) without actually doing the renaming in extensions, please fire it:)
Is this still being put forward for a PHP5.x build? Surely this along with a tidy up on base modules that support it would be much better used as a base for a new PHP6 plan? Extensions that do not support it can also be left out and we have a clean demarcation.
I agree with Lester (for once ^^). I think this change is too large for PHP 5.6. While the releaseprocess RFC does not guarantee compatibility of our internal APIs, it does say that source compatibility should be preserved for minor versions. Until now we stuck with that rule: Every minor release a few APIs are changed, but "few" usually means something like three or four, not five hundred.
If this patch is included in PHP 5.6 I think it is very likely that many extensions will not be updated or take a long while in updating. It's one thing to add two or three new ifdefs to support a new PHP release and something entirely else to change virtually all types in your code and verify that it is still safe with the new sizes.
I remember how lack of proper APC support was seen as a major problem with adoption of PHP 5.4 - now imagine how lack of support by nearly all extensions would look like...
As such I think that PHP 6 is a better place for this patch. PHP 6 will presumably also clean up / change many other internal APIs, so we can have all the major internal (and external ^^) breakage in one release. At that point it might also make sense for many people to support separate versions of extensions for PHP 5 and 6 to avoid the ifdef-hell.
Nikita
Hi Nikita,
Quoted text · 8 lines
On Thu, Jan 23, 2014 at 11:56 AM, Lester Caine lester@lsces.co.uk wrote:
Pierre Joye wrote:
I think we can clear these questions during the vote phases, as options.
If anyone has an idea how to keep the advantage brought by the renaming (compile checks, clarity, code correctness) without actually doing the renaming in extensions, please fire it:)
Is this still being put forward for a PHP5.x build? Surely this along with a tidy up on base modules that support it would be much better used as a base for a new PHP6 plan? Extensions that do not support it can also be left out and we have a clean demarcation.
I agree with Lester (for once ^^). I think this change is too large for PHP
5.6. While the releaseprocess RFC does not guarantee compatibility of our internal APIs, it does say that source compatibility should be preserved for minor versions. Until now we stuck with that rule: Every minor release a few APIs are changed, but "few" usually means something like three or four, not five hundred.
But the "a few rule" is a subset of "src compatibility should be kept if possible, while breakages are allowed". That just means there was no such big patches yet, and the actual "rule" was never fully exploited.
If this patch is included in PHP 5.6 I think it is very likely that many extensions will not be updated or take a long while in updating. It's one thing to add two or three new ifdefs to support a new PHP release and something entirely else to change virtually all types in your code and verify that it is still safe with the new sizes. I think it depends on how active an extension is supported and developed. For instance on PECL are still some extensions not even been ported to PHP5. From the todays experience, a port to the current patch might take from 3 hours to 3 days, depending on complexity. Say 3 days vs 5 months until final, together with the porting docs and tools, most of the really active and being in demand extensions will be so far or users will tear the devs apart :)
I remember how lack of proper APC support was seen as a major problem with adoption of PHP 5.4 - now imagine how lack of support by nearly all extensions would look like...
It would be interesting to have some data, how much 5.5 is used nowadays. But generally it's not correct comparing APC with all extensions, as APC is a very special case diving so deep into core. Porting of a normal extension wrapping or not a library is much easier.
As such I think that PHP 6 is a better place for this patch. PHP 6 will presumably also clean up / change many other internal APIs, so we can have all the major internal (and external ^^) breakage in one release. At that point it might also make sense for many people to support separate versions of extensions for PHP 5 and 6 to avoid the ifdef-hell.
What I'm really afraid of hearing "PHP6" is the assotiation with the golem of the previous flop :) There are still trails of PHP6 macros in the sources and extensions. Like "in PHP6 everything will be much better", but really and when? PHP6, when it comes, will face the same compatibility and stability issues which will need solutions. Or even more, if it'll have all possible breakages. On the other hand, instead of having just 2 years of merge headaches, it's just moved to some undefined point in time with undefined amount of merge headaches. And at the end, will the golem come to life? IMHO the best way to stabilize a software is by using it. No offense meant, but that's what I'm really afraid of.
Regards
Anatol
If this patch is included in PHP 5.6 I think it is very likely that many extensions will not be updated or take a long while in updating. It's one thing to add two or three new ifdefs to support a new PHP release and something entirely else to change virtually all types in your code and verify that it is still safe with the new sizes. I think it depends on how active an extension is supported and developed. For instance on PECL are still some extensions not even been ported to PHP5. From the todays experience, a port to the current patch might take from 3 hours to 3 days, depending on complexity. Say 3 days vs 5 months until final, together with the porting docs and tools, most of the really active and being in demand extensions will be so far or users will tear the devs apart :)
If zpp/error_docref/*printf compatibility is not kept it will take a long time to update pecl extensions, and risk epic failure in the future when continuing the work on the extensions
zpp (COMPAT ? "zyx" : "xyz", &foo, &bar, &baz) will in 1year turn into zpp (COMPAT ? "zyx|xz" : "xyz|z", &foo, &bar, &baz, &meh) and work just fine.. until you hit the perfect storm
Its easy to migrate php-src exts since they don't have to care about compatibility with multiple php versions, but needing to support 5.3, 5.4, 5.5, 5.6, 5.7, 6.0 in a pecl extension will be nightmare
Also, keep in mind most developers priority is not to work on supporting unreleased versions of PHP, but to keep maintaining the ext and adding features - so even though the guesstimate 5months "until final" is true, the extensions won't be updated until 5months after 5.6.0 is out.
-Hannes
On Thu, Jan 23, 2014 at 7:38 PM, Hannes Magnusson hannes.magnusson@gmail.com wrote:
Quoted text · 5 lines
If this patch is included in PHP 5.6 I think it is very likely that many extensions will not be updated or take a long while in updating. It's one thing to add two or three new ifdefs to support a new PHP release and something entirely else to change virtually all types in your code and verify that it is still safe with the new sizes. I think it depends on how active an extension is supported and developed. For instance on PECL are still some extensions not even been ported to PHP5. From the todays experience, a port to the current patch might take from 3 hours to 3 days, depending on complexity. Say 3 days vs 5 months until final, together with the porting docs and tools, most of the really active and being in demand extensions will be so far or users will tear the devs apart :)
If zpp/error_docref/*printf compatibility is not kept it will take a long time to update pecl extensions, and risk epic failure in the future when continuing the work on the extensions
zpp (COMPAT ? "zyx" : "xyz", &foo, &bar, &baz) will in 1year turn into zpp (COMPAT ? "zyx|xz" : "xyz|z", &foo, &bar, &baz, &meh) and work just fine.. until you hit the perfect storm
Its easy to migrate php-src exts since they don't have to care about compatibility with multiple php versions, but needing to support 5.3, 5.4, 5.5, 5.6, 5.7, 6.0 in a pecl extension will be nightmare
Also, keep in mind most developers priority is not to work on supporting unreleased versions of PHP, but to keep maintaining the ext and adding features - so even though the guesstimate 5months "until final" is true, the extensions won't be updated until 5months after 5.6.0 is out.
We have ported many extensions (all actively used and maintained) for 5.5.0 before it was released. Some bugs appeared when used with 5.5 and was discovered after final, but that's expected and nothing we can do about it but test, test and test :)
That's why I do not really buy this argument to be used against this RFC for 5.6, as if not 5.6, it will be the same with 5.6 and even worst for the hypothetical 6.
--
Pierre
@pierrejoye | http://www.libgd.org
Quoted text · 7 lines
On Thu, Jan 23, 2014 at 7:38 PM, Hannes Magnusson hannes.magnusson@gmail.com wrote:
If this patch is included in PHP 5.6 I think it is very likely that many extensions will not be updated or take a long while in updating. It's one thing to add two or three new ifdefs to support a new PHP release and something entirely else to change virtually all types in your code and verify that it is still safe with the new sizes. I think it depends on how active an extension is supported and developed. For instance on PECL are still some extensions not even been ported to PHP5. From the todays experience, a port to the current patch might take from 3 hours to 3 days, depending on complexity. Say 3 days vs 5 months until final, together with the porting docs and tools, most of the really active and being in demand extensions will be so far or users will tear the devs apart :)
If zpp/error_docref/*printf compatibility is not kept it will take a long time to update pecl extensions, and risk epic failure in the future when continuing the work on the extensions
zpp (COMPAT ? "zyx" : "xyz", &foo, &bar, &baz) will in 1year turn into zpp (COMPAT ? "zyx|xz" : "xyz|z", &foo, &bar, &baz, &meh) and work just fine.. until you hit the perfect storm
Its easy to migrate php-src exts since they don't have to care about compatibility with multiple php versions, but needing to support 5.3, 5.4, 5.5, 5.6, 5.7, 6.0 in a pecl extension will be nightmare
Also, keep in mind most developers priority is not to work on supporting unreleased versions of PHP, but to keep maintaining the ext and adding features - so even though the guesstimate 5months "until final" is true, the extensions won't be updated until 5months after 5.6.0 is out.
We have ported many extensions (all actively used and maintained) for 5.5.0 before it was released. Some bugs appeared when used with 5.5 and was discovered after final, but that's expected and nothing we can do about it but test, test and test :)
Can I see 3 examples of pecl extensions you have ported, out of those many and actively used, that need to support multiple PHP versions? It would help to clearly visualize the full workload.
Also, are you planning on doing this migration for all pecl extensions? If not, then my argument still stands.
Waiiit.. You are talking about 5.5? Not 5.6 with this patch? Yeah, supporting 5.5 wasn't a major deal. It didn't change zpp or *printf() arguments.
-Hannes
Hi,
On Jan 23, 2014 8:35 PM, "Hannes Magnusson" hannes.magnusson@gmail.com wrote:
Quoted text · 18 lines
On Thu, Jan 23, 2014 at 11:16 AM, Pierre Joye pierre.php@gmail.com wrote:
On Thu, Jan 23, 2014 at 7:38 PM, Hannes Magnusson hannes.magnusson@gmail.com wrote:
If this patch is included in PHP 5.6 I think it is very likely that many
extensions will not be updated or take a long while in updating. It's one
thing to add two or three new ifdefs to support a new PHP release and something entirely else to change virtually all types in your code and
verify that it is still safe with the new sizes. I think it depends on how active an extension is supported and developed.
For instance on PECL are still some extensions not even been ported to PHP5. From the todays experience, a port to the current patch might take
from 3 hours to 3 days, depending on complexity. Say 3 days vs 5 months
until final, together with the porting docs and tools, most of the really
active and being in demand extensions will be so far or users will tear
the devs apart :)If zpp/error_docref/*printf compatibility is not kept it will take a long time to update pecl extensions, and risk epic failure in the future when continuing the work on the extensions
zpp (COMPAT ? "zyx" : "xyz", &foo, &bar, &baz) will in 1year turn into zpp (COMPAT ? "zyx|xz" : "xyz|z", &foo, &bar, &baz, &meh) and work just fine.. until you hit the perfect storm
Its easy to migrate php-src exts since they don't have to care about compatibility with multiple php versions, but needing to support 5.3, 5.4, 5.5, 5.6, 5.7, 6.0 in a pecl extension will be nightmare
Also, keep in mind most developers priority is not to work on supporting unreleased versions of PHP, but to keep maintaining the ext and adding features - so even though the guesstimate 5months "until final" is true, the extensions won't be updated until 5months after 5.6.0 is out.
We have ported many extensions (all actively used and maintained) for 5.5.0 before it was released. Some bugs appeared when used with 5.5 and was discovered after final, but that's expected and nothing we can do about it but test, test and test :)
Can I see 3 examples of pecl extensions you have ported, out of those many and actively used, that need to support multiple PHP versions? It would help to clearly visualize the full workload.
Also, are you planning on doing this migration for all pecl extensions? If not, then my argument still stands.
Check Anatol or my commits or PRs. And yes we keep contribute to many extensions in core and pecl, and yes we keep report bugs, and yes we test these exts too.
Waiiit.. You are talking about 5.5? Not 5.6 with this patch? Yeah, supporting 5.5 wasn't a major deal. It didn't change zpp or *printf() arguments.
5.5 was a piece of cake but for APC (same with 5.4).
And again, zpp is one of the open questions.
Printf changes are necessary for 64bit integer. There is no big problem to deal with that.
Cheers,
Pierre
Quoted text · 15 lines
Hi,
On Jan 23, 2014 8:35 PM, "Hannes Magnusson" hannes.magnusson@gmail.com wrote:
On Thu, Jan 23, 2014 at 11:16 AM, Pierre Joye pierre.php@gmail.com wrote:
On Thu, Jan 23, 2014 at 7:38 PM, Hannes Magnusson hannes.magnusson@gmail.com wrote:
If this patch is included in PHP 5.6 I think it is very likely that many
extensions will not be updated or take a long while in updating. It's one
thing to add two or three new ifdefs to support a new PHP release and something entirely else to change virtually all types in your code and
verify that it is still safe with the new sizes. I think it depends on how active an extension is supported and developed.
For instance on PECL are still some extensions not even been ported to PHP5. From the todays experience, a port to the current patch might take
from 3 hours to 3 days, depending on complexity. Say 3 days vs 5 months
until final, together with the porting docs and tools, most of the really
active and being in demand extensions will be so far or users will tear
the devs apart :)If zpp/error_docref/*printf compatibility is not kept it will take a long time to update pecl extensions, and risk epic failure in the future when continuing the work on the extensions
zpp (COMPAT ? "zyx" : "xyz", &foo, &bar, &baz) will in 1year turn into zpp (COMPAT ? "zyx|xz" : "xyz|z", &foo, &bar, &baz, &meh) and work just fine.. until you hit the perfect storm
^^^^^^^ look at this ^^^^^
Its easy to migrate php-src exts since they don't have to care about compatibility with multiple php versions, but needing to support 5.3, 5.4, 5.5, 5.6, 5.7, 6.0 in a pecl extension will be nightmare
Also, keep in mind most developers priority is not to work on supporting unreleased versions of PHP, but to keep maintaining the ext and adding features - so even though the guesstimate 5months "until final" is true, the extensions won't be updated until 5months after 5.6.0 is out.
We have ported many extensions (all actively used and maintained) for 5.5.0 before it was released. Some bugs appeared when used with 5.5 and was discovered after final, but that's expected and nothing we can do about it but test, test and test :)
How is this related to zpp migrations? You worked on 5.5? Great! But we are not talking about 5.5
We are talking about migration approaches for 5.6 and zpp.
Quoted text · 6 lines
Can I see 3 examples of pecl extensions you have ported, out of those many and actively used, that need to support multiple PHP versions? It would help to clearly visualize the full workload.
Also, are you planning on doing this migration for all pecl extensions? If not, then my argument still stands.
Check Anatol or my commits or PRs. And yes we keep contribute to many extensions in core and pecl, and yes we keep report bugs, and yes we test these exts too.
Waiiit.. You are talking about 5.5? Not 5.6 with this patch? Yeah, supporting 5.5 wasn't a major deal. It didn't change zpp or *printf() arguments.
5.5 was a piece of cake but for APC (same with 5.4).
And again, zpp is one of the open questions.
Maybe you should read my initial reply again. Thats exactly what we are discussing. How dangerous COMPAT ? foo : bar can be in zpp. And zillions of ifdefs are no better.
bc needs to be kept as suggested by Nikita, Dmitry, Chris.. Rather then trying to press through bc break there.
You then make two completely out of the blue unrelated replies.. To make what point exactly? That you worked on some extension for PHP 5.5? Awesome! I appreciate that!
Please stay on point and if you have nothing to say then don't reply. It is OK to not reply to every single mail ever.
-Hannes
Hi Hannes,
Quoted text · 4 lines
If this patch is included in PHP 5.6 I think it is very likely that many extensions will not be updated or take a long while in updating. It's one
thing to add two or three new ifdefs to support a new PHP release and something entirely else to change virtually all types in your code and verify that it is still safe with the new sizes. I think it depends on how active an extension is supported and developed. For instance on PECL are still some extensions not even been ported to PHP5. From the todays experience, a port to the current patch might take from 3 hours to 3 days, depending on complexity. Say 3 days vs 5 months until final, together with the porting docs and tools, most of the really active and being in demand extensions will be so far or users will tear the devs apart :)If zpp/error_docref/*printf compatibility is not kept it will take a long time to update pecl extensions, and risk epic failure in the future when continuing the work on the extensions
zpp (COMPAT ? "zyx" : "xyz", &foo, &bar, &baz) will in 1year turn into zpp (COMPAT ? "zyx|xz" : "xyz|z", &foo, &bar, &baz, &meh) and work just fine.. until you hit the perfect storm
it's up to vote now, RFC updated (multiple votes in the same RFC). I've prepared a change to zpp for any case http://pastie.org/8662202 .
The spprinf and derivatives - keeping %d working with real int and %ld with real long looks unavoidable, as those will need to be used at some places. Here the portable way would be still using ZEND_INT_FMT instead of %pd and co. But this is actually primitive, like in vim
:%s,%ld," ZEND_INT_FMT ",g
Maybe some place will need to be cleaned after that, still it will do the job.
Its easy to migrate php-src exts since they don't have to care about compatibility with multiple php versions, but needing to support 5.3, 5.4, 5.5, 5.6, 5.7, 6.0 in a pecl extension will be nightmare
Also, keep in mind most developers priority is not to work on supporting unreleased versions of PHP, but to keep maintaining the ext and adding features - so even though the guesstimate 5months "until final" is true, the extensions won't be updated until 5months after 5.6.0 is out.
The compat issues between 5.4 and 5.5 are less than now. Even the amout of breakage between 5.3 and 5.5 is less than now. However I'd really suggest you to try the porting guide, if you couldn't get an average extension compile in 1 hour or even less - too bad. Clear, some tricky places may come after that, that's where one would need to spend more time than on the routine "replace" task. Of course not talking about the calibre of exts like ext\intl and similar, that's not an average case. From what I saw now, the routine replacement task to just get an extension compiling with older codebase might be 10-20% of the whole porting time. In some cases it'll be everything one needs.
The routine is always annoying, that's true :) But it might be not the worst issue one need to fix, if ever. I believe to have appropriately reflected the current concerns with the voting options. So then the direction of the porting process can be affected by everyone.
Regards
Anatol
Hi Nikita,
If this patch is included in PHP 5.6 I think it is very likely that many extensions will not be updated or take a long while in updating. It's one thing to add two or three new ifdefs to support a new PHP release and something entirely else to change virtually all types in your code and verify that it is still safe with the new sizes. I think it depends on how active an extension is supported and developed. For instance on PECL are still some extensions not even been ported to PHP5. From the todays experience, a port to the current patch might take from 3 hours to 3 days, depending on complexity. Say 3 days vs 5 months until final, together with the porting docs and tools, most of the really active and being in demand extensions will be so far or users will tear the devs apart :)
It will take time for extensions to catch up, regardless of which release the 64 bit changes are merged. This will have a short or medium term negative effect on PHP but I believe the type cleanup is an overall step forward. I recall the 5.4 changes took some time to filter down to various extensions, and also took effort from people who were not the current maintainers. The 64 bit project should attempt to minimize the scope of code changes needed, and be released when suitable user and extension maintainer expectations have been set.
For reference, here is Anatol's mapping that allows extensions using the new types etc to compile with older PHP releases: https://github.com/php/php-src/blob/str_size_and_int64/compat/compat.h I would have leaned towards not requiring macro name changes, but I wouldn't vote against the RFC because of them.
The current extension migration process is:
- change the code to the new types and macros
- update ssprintf formats
- update ZPP formats
- review and update any signed<->unsigned comparisons
- review and update library type casts, range checks etc
To allow the extension to also build with older PHP versions then:
- compat.h is required
- some #ifdefs are needed, e.g. for ZPP.
Chris
--
christopher.jones@oracle.com http://twitter.com/ghrd Free PHP & Oracle book:
http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html
For reference, here is Anatol's mapping that allows extensions using the new types etc to compile with older PHP releases: https://github.com/php/php-src/blob/str_size_and_int64/compat/compat.h I would have leaned towards not requiring macro name changes, but I wouldn't vote against the RFC because of them.
Anatol: what about creating the inverse of the compat.h #defines? Old code can include those definitions and wouldn't need as many changes?
Chris
--
christopher.jones@oracle.com http://twitter.com/ghrd Free PHP & Oracle book:
http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html
Hi Chris,
For reference, here is Anatol's mapping that allows extensions using the new types etc to compile with older PHP releases: https://github.com/php/php-src/blob/str_size_and_int64/compat/compat.h I would have leaned towards not requiring macro name changes, but I wouldn't vote against the RFC because of them.
Anatol: what about creating the inverse of the compat.h #defines? Old code can include those definitions and wouldn't need as many changes?
The macros are easy done of course, but the long/int keywords would conflict with the built-in types, wouldn't they? Well, if zpp var datatypes were still replaced, it should work. Is that what you mean?
Regards
Anatol
Quoted text · 6 lines
Hi Chris,
For reference, here is Anatol's mapping that allows extensions using the new types etc to compile with older PHP releases: https://github.com/php/php-src/blob/str_size_and_int64/compat/compat.h I would have leaned towards not requiring macro name changes, but I wouldn't vote against the RFC because of them.
Anatol: what about creating the inverse of the compat.h #defines? Old code can include those definitions and wouldn't need as many changes?
The macros are easy done of course, but the long/int keywords would conflict with the built-in types, wouldn't they? Well, if zpp var datatypes were still replaced, it should work. Is that what you mean?
Regards
Anatol
Have as much as can be done via macros to minimize the number of lines that need to be modified in a file.
Chris
--
christopher.jones@oracle.com http://twitter.com/ghrd Free PHP & Oracle book:
http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html
Hi Dmitry,
greateful thanks for taking a look at this patch.
Quoted text · 4 lines
I completely agree with Nikita.
Why to rename LONG->INT STRLEN->STRSIZE in thousands places? Why not just define zend_long and zend_ulong to be 64-bit on 64-bit platforms and use them instead of int, ulint, zend_int, zend_uint, long, ulong where it's necessary.Anatol, I understood your point about catching incompatibility code at compile-time, but I'm not sure if the new features cost such huge code base changes.
Firstly it's the historical reason as while porting it "had" to break so one could easy see the relevant places. After that - it's also a transformation in the mind, as that int placeholders do not depend on a fixed datatype anymore.
- 64-bit integers on Windows (they are already 64-bit on other systems)
- 64-bit string length. I don't think many people are interested in that. Fortunately, the patch doesn't change the zval size, so it shouldn't make a lot of harm. However, usage of "zend_size_t" instead of "int" is a bit annoying. I would change it into the same "zend_long" or "zend_ulong".
The original patch was for size_t only. With only that it were Linux/Unix only improvement, as size_t is 64 bit on Windows so it'd have to stay int or become just unsigned. Omitting the size_t change and doing int64 were only improvement on Windows. Adding both is the three-way improvement - Linux and Windows with biggest possible strings, Windows with 64 bit integers. So in fact, doing only one of those wouldn't IMHO justify all the effort.
Additional Windows improvement "for free" is the whole file API exhausting, so large file objects and offsets.
That's true, the possibility to process gigabytes of data in memory will not be needed every day, however the presence of it is something else. Like, why should I be interested on something not available anyway?
Keeping size_t separated semantically is good for several reasons. It's clean with the specification. Should it come to 64 bit integer on 32 bit platform, it's easier to continue (merging size_t and ulong would break this option). And, one day it can come to 128 bit integers (for what reasons ever). I know, it's science fiction now, but wasn't a RAM size of 1Gb so 10 years ago? You never know. So size_t separated from unsigned int is a good thing imho and keeps some interesting options open for the future.
At the end line, the new vs. old names is the last thing I personally would ultimately hang on, given the essential modification is in place. However the code clearly expressing what happens is something I'd call more appropriate with such a big substantial change.
Best regards
Anatol
Hi Anatol,
Quoted text · 6 lines
Hi Dmitry,
greateful thanks for taking a look at this patch.
I completely agree with Nikita.
Why to rename LONG->INT STRLEN->STRSIZE in thousands places? Why not just define zend_long and zend_ulong to be 64-bit on 64-bit platforms and use them instead of int, ulint, zend_int, zend_uint, long, ulong where it's necessary.Anatol, I understood your point about catching incompatibility code at compile-time, but I'm not sure if the new features cost such huge code base changes.
Firstly it's the historical reason as while porting it "had" to break so one could easy see the relevant places. After that - it's also a transformation in the mind, as that int placeholders do not depend on a fixed datatype anymore.
historical reason of the patch itself doesn't matter :) If there's no significant reason to introduce new names lets use old ones.
Even with new names anyone is able to change macros but not types. It's better to use some smarter compile-time protection. I would try to play with "compile time assert" (in GCC it must be even possible to use __builtin_types_compatible_b()). For example:
#define CONCAT_TOKENS(a, b) a ## b
#define EXPAND_THEN_CONCAT(a, b) CONCAT_TOKENS(a, b) #define COMPILE_TIME_ASSERT(expr) do {
enum { EXPAND_THEN_CONCAT(ASSERT_line_,LINE) = 1 / !!(expr) };
} while(0)
int main()
{
int a;
COMPILE_TIME_ASSERT(__builtin_types_compatible_p(typeof(a), long));
COMPILE_TIME_ASSERT(sizeof(a) == 8);
return 0;
}
Quoted text · 4 lines
- 64-bit integers on Windows (they are already 64-bit on other systems)
- 64-bit string length. I don't think many people are interested in that.
Fortunately, the patch doesn't change the zval size, so it shouldn't make a lot of harm. However, usage of "zend_size_t" instead of "int" is a bit annoying. I would change it into the same "zend_long" or "zend_ulong".The original patch was for size_t only. With only that it were Linux/Unix only improvement, as size_t is 64 bit on Windows so it'd have to stay int or become just unsigned. Omitting the size_t change and doing int64 were only improvement on Windows. Adding both is the three-way improvement - Linux and Windows with biggest possible strings, Windows with 64 bit integers. So in fact, doing only one of those wouldn't IMHO justify all the effort.
After some thoughts I think that usage of "size_t" is a good thing for the future support of X32 ABI.
X86: sizeof(int)=4 sizeof(long)=4 sizeof(sizet_t)=4 X86-64 (Linux): sizeof(int)=4 sizeof(long)=8 sizeof(sizet_t)=8 X86-64 (Win64): sizeof(int)=4 sizeof(long)=4 sizeof(sizet_t)=8 X32: sizeof(int)=4 sizeof(long)=8 sizeof(sizet_t)=4
Additional Windows improvement "for free" is the whole file API exhausting, so large file objects and offsets.
That's true, the possibility to process gigabytes of data in memory will not be needed every day, however the presence of it is something else. Like, why should I be interested on something not available anyway?
Keeping size_t separated semantically is good for several reasons. It's clean with the specification. Should it come to 64 bit integer on 32 bit platform, it's easier to continue (merging size_t and ulong would break this option). And, one day it can come to 128 bit integers (for what reasons ever). I know, it's science fiction now, but wasn't a RAM size of 1Gb so 10 years ago? You never know. So size_t separated from unsigned int is a good thing imho and keeps some interesting options open for the future.
Agreed.
At the end line, the new vs. old names is the last thing I personally would ultimately hang on, given the essential modification is in place. However the code clearly expressing what happens is something I'd call more appropriate with such a big substantial change.
It's questionable. I' mot sure what names are better but big changes are always annoying.
May be it makes sense to extend votiing with options ("with renaming" and "without renaming")
Thanks. Dmitry.
Best regards
Anatol
Hi Dmitry,
Quoted text · 11 lines
historical reason of the patch itself doesn't matter :) If there's no significant reason to introduce new names lets use old ones.
Even with new names anyone is able to change macros but not types. It's better to use some smarter compile-time protection. I would try to play with "compile time assert" (in GCC it must be even possible to use __builtin_types_compatible_b()). For example:
#define CONCAT_TOKENS(a, b) a ## b
#define EXPAND_THEN_CONCAT(a, b) CONCAT_TOKENS(a, b) #define COMPILE_TIME_ASSERT(expr) do {
enum { EXPAND_THEN_CONCAT(ASSERT_line_,LINE) = 1 / !!(expr) };
} while(0)int main() {
int a;COMPILE_TIME_ASSERT(__builtin_types_compatible_p(typeof(a), long));
COMPILE_TIME_ASSERT(sizeof(a) == 8);
return 0; }
That is what also Gopal pointed me to with this live example https://github.com/bagder/curl/blob/master/include/curl/typecheck-gcc.h There's a similar functionality with Visual C++ http://msdn.microsoft.com/en-us/library/dd537655.aspx but I'm not sure it's C++ only. Will have to try. Generally why I left the idea - as it were only clean for new implementation, with the old implementation (that compat.h stuff) one would need to use #undef which looks like a hack. Another thing is that iterating through the param spec and comparing it with the passed args on compile time were another tricky job. Now where you say it, I think that check is at least worth a try and even being in the new PHP only it would be a great thing. So putting on the TODO, as the most stuff is ported now.
Quoted text · 7 lines
- 64-bit integers on Windows (they are already 64-bit on other systems) 2) 64-bit string length. I don't think many people are interested in
that.
Fortunately, the patch doesn't change the zval size, so it shouldn't make a lot of harm. However, usage of "zend_size_t" instead of "int" is a bit annoying. I would change it into the same "zend_long" or "zend_ulong".The original patch was for size_t only. With only that it were Linux/Unix
only improvement, as size_t is 64 bit on Windows so it'd have to stay int or become just unsigned. Omitting the size_t change and doing int64 were only improvement on Windows. Adding both is the three-way improvement - Linux and Windows with biggest possible strings, Windows with 64 bit integers. So in fact, doing only one of those wouldn't IMHO justify all the effort.After some thoughts I think that usage of "size_t" is a good thing for the future support of X32 ABI.
X86: sizeof(int)=4 sizeof(long)=4 sizeof(sizet_t)=4 X86-64 (Linux): sizeof(int)=4 sizeof(long)=8 sizeof(sizet_t)=8 X86-64 (Win64): sizeof(int)=4 sizeof(long)=4 sizeof(sizet_t)=8 X32: sizeof(int)=4 sizeof(long)=8 sizeof(sizet_t)=4
Ok, there is even more platform mess out here :)
Quoted text · 7 lines
Additional Windows improvement "for free" is the whole file API exhausting, so large file objects and offsets.
That's true, the possibility to process gigabytes of data in memory will not be needed every day, however the presence of it is something else. Like, why should I be interested on something not available anyway?
Keeping size_t separated semantically is good for several reasons. It's clean with the specification. Should it come to 64 bit integer on 32 bit platform, it's easier to continue (merging size_t and ulong would break this option). And, one day it can come to 128 bit integers (for what reasons ever). I know, it's science fiction now, but wasn't a RAM size of 1Gb so 10 years ago? You never know. So size_t separated from unsigned int is a good thing imho and keeps some interesting options open for the future.
Agreed.
At the end line, the new vs. old names is the last thing I personally would ultimately hang on, given the essential modification is in place. However the code clearly expressing what happens is something I'd call more appropriate with such a big substantial change.
It's questionable. I' mot sure what names are better but big changes are always annoying. May be it makes sense to extend votiing with options ("with renaming" and
"without renaming")
Yeah, independent from the concrete names, it's about keeping balance between the real functionality and annoyance. I've split options in the RFC into 4 separate votes so far. All yes/no options about the patch itself, zpp, renamed macros and SAPIs. As all that zend_t and php_t types didn't exist before, would you like suggest other names? Please see the RFC, there are also type replacements for off_t and struct stat.
Thanks
Anatol
Hi,
Hi,
https://wiki.php.net/rfc/size_t_and_int64
The discussion time has come. The work on the feature branch continues. The current patch is stable enough to be discussed.
For the record, we actually like to target 5.6 for this change. There was a little confusion due to the 5.6 timetable having been slightly shifted.
Also the various changes we introduce has been discussed intensively (on this list on irc) to minimize the amount of changes required to support 64bit integer.
Cheers,
Pierre
Quoted text · 6 lines
Hi,
Hi,
https://wiki.php.net/rfc/size_t_and_int64
The discussion time has come. The work on the feature branch continues. The current patch is stable enough to be discussed.
For the record, we actually like to target 5.6 for this change. There was a little confusion due to the 5.6 timetable having been slightly shifted.
Also the various changes we introduce has been discussed intensively (on this list on irc) to minimize the amount of changes required to support 64bit integer.
I've updated the RFC accordingly, also the possible vote choices.
Regards
Anatol
Quoted text · 4 lines
For the record, we actually like to target 5.6 for this change. There was a little confusion due to the 5.6 timetable having been slightly shifted.
Also the various changes we introduce has been discussed intensively (on
this list on irc) to minimize the amount of changes required to support 64bit integer.I've updated the RFC accordingly, also the possible vote choices.
One note yet - as we target 5.6, not to conceal were the hard test process running in background. Both x64 and x86 builds are tested involving CLI, Apache and opcache. The test summary is available under http://131.107.220.66/PFTT-Results/STR_SIZE_AND_INT64/
Regards
Anatol
Hi Anatol,
https://wiki.php.net/rfc/size_t_and_int64
The discussion time has come. The work on the feature branch continues. The current patch is stable enough to be discussed.
I haven't dive into details of this improvement, so I'm assuming the improvement is only for 64bit platforms from the title.
There are number of subsystems that supports 64bit int. e.g. file system, PostgreSQL large object, time, etc. It's nicer if 64bit int is supported on 32bit platforms.
What's the reason not to introduce larger int for 32bit platforms? Too much performance impact?
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
What's the reason not to introduce larger int for 32bit platforms? Too much performance impact?
I've wondered this myself. It makes me also wonder if it's the case using 64-bit on 32-bit platforms is a little too slow, couldn't you just transparently store 32-bit and then switch to 64-bit if necessary?
--
Andrea Faulds
http://ajf.me/
Hi Andrea,
On Mon, 2014-01-13 at 22:03 +0000, Andrea Faulds wrote:
What's the reason not to introduce larger int for 32bit platforms? Too much performance impact?
I've wondered this myself. It makes me also wonder if it's the case using 64-bit on 32-bit platforms is a little too slow, couldn't you just transparently store 32-bit and then switch to 64-bit if necessary?
thanks for the idea, but it might be much more complex as one thinks. If one has to switch between 32 vs 64 bit in zval, it screams for API breach. For example with functions accepting integers by reference. Anyway, just a speculation right now :)
Regards
Anatol
Hi Yasuo,
On Tue, 2014-01-14 at 06:57 +0900, Yasuo Ohgaki wrote:
Quoted text · 6 lines
Hi Anatol,
https://wiki.php.net/rfc/size_t_and_int64
The discussion time has come. The work on the feature branch continues. The current patch is stable enough to be discussed.
I haven't dive into details of this improvement, so I'm assuming the improvement is only for 64bit platforms from the title.
There are number of subsystems that supports 64bit int. e.g. file system, PostgreSQL large object, time, etc. It's nicer if 64bit int is supported on 32bit platforms.
What's the reason not to introduce larger int for 32bit platforms? Too much performance impact?
thanks for the interest on this. Such an idea existed at the start among others, as well as introducing a new zval member for 'int64' besides 'long'. The reasons for not doing it (now), also from the todays point of view:
- much higher patch complexity
- with more complexity the risk of not finishing the patch grows
- worse compatibility with libraries
- worse compatibility with existing extensions
- 64 bit processors are widely available
- well, the slowliness you mention, whereby i've no benchmarks at hand
I would describe the current patch already as a quantum jump for PHP, whereby small steps are much safer. Having placeholders instead of fixed types is a good base to do 64 bit int available on 32 bit platform. However I guess bringing it up will take not less amount of woman/hours, if not more. One can see the current state as an intermediate goal, where it leads is another question.
What comes with the patch now:
- 64 bit int support across windows/linux
- 64 bit file operations across windows/linux
- size_t support for string length, that means string length can be handled with userspace integers
- open perspectives for things like you mention
I've read your Postgres approach and that's doable even currently inside 32 bit, too. There is such functionality here and there, like ext/date.
Regards
Anatol
Hi Anatol,
Quoted text · 7 lines
thanks for the interest on this. Such an idea existed at the start among others, as well as introducing a new zval member for 'int64' besides 'long'. The reasons for not doing it (now), also from the todays point of view:
- much higher patch complexity
- with more complexity the risk of not finishing the patch grows
- worse compatibility with libraries
- worse compatibility with existing extensions
- 64 bit processors are widely available
- well, the slowliness you mention, whereby i've no benchmarks at hand
Thank you for your explanations.
These are understandable reasons.
Let's finish current proposal, then we may try to extend int type. If I finished my todo list for PHP, I'll join your project!
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net