Re: [PHP-DEV] About optimization

2010-01-13 Thread Rasmus Lerdorf
Tim Starling wrote: > For Mr. "everyone has 8GB of memory and tiny little data sets" Lerdorf, > I could point out that reducing the average zend_op size and placing > strings close to other op data will also make execution faster, due to > the improved CPU cache hit rate. Nice twist there. I simp

Re: [PHP-DEV] About optimization

2010-01-13 Thread Tim Starling
Stanislav Malyshev wrote: > > opcodes can be cached (bytecode caches do it) but op_array can't > really be cached between requests because it contains dynamic > structures. Unlike Java, PHP does full cleanup after each request, > which means no preserving dynamic data. APC deep-copies the whole ze

Re: [PHP-DEV] About optimization

2010-01-13 Thread Stanislav Malyshev
Hi! class C { var $v1, $v2, $v3, $v4, $v5, $v6, $v7, $v8, $v9, $v10; } $m = memory_get_usage(); $a = array(); for ( $i = 0; $i< 1; $i++ ) { $a[] = new C; } print ((memory_get_usage() - $m) / 1) . "\n"; ?> 1927 bytes (I'll use 64-bit from now on since it gives the most shocki

Re: [PHP-DEV] About optimization

2010-01-13 Thread Rasmus Lerdorf
Tim Starling wrote: > class C { > var $v1, $v2, $v3, $v4, $v5, $v6, $v7, $v8, $v9, $v10; > } > > $m = memory_get_usage(); > $a = array(); > for ( $i = 0; $i < 1; $i++ ) { > $a[] = new C; > } > print ((memory_get_usage() - $m) / 1) . "\n"; > ?> > > 1927 bytes (I'll use 64-bit from

Re: [PHP-DEV] About optimization

2010-01-13 Thread Rasmus Lerdorf
Tim Starling wrote: > Some other operations, like deleting items from the middle of the array > or adding items past the end (leaving gaps) would also have to trigger > conversion. The point would be to optimise the most common use cases for > integer-indexed arrays. I still say this isn't somethi

Re: [PHP-DEV] About optimization

2010-01-13 Thread Tim Starling
Stanislav Malyshev wrote: > Hi! > >> > $m = memory_get_usage(); >> $a = explode(',', str_repeat(',', 10)); >> print (memory_get_usage() - $m)/10; > > Says 93.2482 for me. Should be even less since string generated by > str_repead itself also is counted as overhead (without it it's > 92.2474

Re: [PHP-DEV] About optimization

2010-01-13 Thread Rasmus Lerdorf
Stanislav Malyshev wrote: > Hi! > >> Says 93.2482 for me. Should be even less since string generated by > > On 64-bit I get about 170 bytes for 5.2, don't have 5.3 build handy on > 64-bit. 178.4972 5.3 non-debug 64-bit Linux -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To u

Re: [PHP-DEV] About optimization

2010-01-13 Thread Derick Rethans
On Wed, 13 Jan 2010, Stanislav Malyshev wrote: > > Says 93.2482 for me. Should be even less since string generated by > > On 64-bit I get about 170 bytes for 5.2, don't have 5.3 build handy on 64-bit. On 64bit (debug builds): der...@kossu:~$ pe 5.3dev der...@kossu:~$ php 378.54448 der...@kos

[PHP-DEV] Int to float precision loss in 64bit environment

2010-01-13 Thread Ralph Schindler
Hey list: I noticed an issue today running our ZF unit tests, it primarily came down to this issue: On 32 bit environments .. ~# php -r "var_dump(PHP_INT_MAX+1 > PHP_INT_MAX);" .. will return true, whereas in 64bit environments, this returns false. In talking with Stas, it seems that since

Re: [PHP-DEV] About optimization

2010-01-13 Thread Stanislav Malyshev
Hi! Says 93.2482 for me. Should be even less since string generated by On 64-bit I get about 170 bytes for 5.2, don't have 5.3 build handy on 64-bit. -- Stanislav Malyshev, Zend Software Architect s...@zend.com http://www.zend.com/ (408)253-8829 MSN: s...@zend.com -- PHP Internals - PHP

Re: [PHP-DEV] mcrypt & streams

2010-01-13 Thread Pierre Joye
On Thu, Jan 14, 2010 at 1:16 AM, Stanislav Malyshev wrote: > Hi! > >> It makes no difference between PECL and core. Unlike the main >> extension page, the filters do not containt the PECL section/notice. >> SSH2 is another example of this problem. > > Yes, but the problem is people actually instal

Re: [PHP-DEV] mcrypt & streams

2010-01-13 Thread Stanislav Malyshev
Hi! It makes no difference between PECL and core. Unlike the main extension page, the filters do not containt the PECL section/notice. SSH2 is another example of this problem. Yes, but the problem is people actually install mcrypt (which is in source so everybody supposed to have it) and expe

Re: [PHP-DEV] About optimization

2010-01-13 Thread Derick Rethans
On Thu, 14 Jan 2010, Tim Starling wrote: > * Exposing strongly-typed list and vector data structures to the user, > that don't have massive hashtable overheads I'm actually working on a few things here.. some more efficient sets and hashes. Expect more to see soon. regards, Derick -- http://d

Re: [PHP-DEV] About optimization

2010-01-13 Thread Rasmus Lerdorf
Tim Starling wrote: > Rasmus Lerdorf wrote: >> For me, working in super high-load environments, this was never an issue >> because memory was always way more plentiful than cpu. You can only >> slice a cpu in so many slices. Even if you could run 1024 concurrent >> Apache/PHP processes, you would

Re: [PHP-DEV] mcrypt & streams

2010-01-13 Thread Pierre Joye
On Wed, Jan 13, 2010 at 11:48 PM, Stanislav Malyshev wrote: > Hi! > > We have mcrypt streams documented here: > http://www.php.net/manual/en/filters.encryption.php > however contrary to what the manual says, I do not see any implementation of > mcrypt.* filters in mcrypt extension. There's some co

[PHP-DEV] Apache has two versions on my extension loaded!

2010-01-13 Thread Bruce Bailey
Help! I was patching out a new version of my PHP extension, with a different version as part of the name: libmyext.so.1.0 is now libmyext.so.2.0 I updated php.ini (extension=libmyext.so.2.0) and restarted apache with the graceful option. For some reason, both extensions were loaded simultane

Re: [PHP-DEV] About optimization

2010-01-13 Thread Stanislav Malyshev
Hi! Says 93.2482 for me. Should be even less since string generated by str_repead itself also is counted as overhead (without it it's 92.2474). Aren't you perchance using debug build? Debug build gives 196 for me. -- Stanislav Malyshev, Zend Software Architect s...@zend.com http://www.zen

Re: [PHP-DEV] About optimization

2010-01-13 Thread Stanislav Malyshev
Hi! Given this, sometimes it's easy to forget that PHP is pathologically memory hungry, to the point of making simple tasks difficult or impossible to perform in limited environments. It's the worst language I've ever encountered in this respect. An array of small strings will use on the order o

Re: [PHP-DEV] About optimization

2010-01-13 Thread Tim Starling
Rasmus Lerdorf wrote: > Tim Starling wrote: > >> Given this, sometimes it's easy to forget that PHP is pathologically >> memory hungry, to the point of making simple tasks difficult or >> impossible to perform in limited environments. It's the worst language >> I've ever encountered in this resp

[PHP-DEV] mcrypt & streams

2010-01-13 Thread Stanislav Malyshev
Hi! We have mcrypt streams documented here: http://www.php.net/manual/en/filters.encryption.php however contrary to what the manual says, I do not see any implementation of mcrypt.* filters in mcrypt extension. There's some code in PECL mcrypt_filters extension, which is never mentioned in the

Re: [PHP-DEV] 5.3 release schedule and other bits

2010-01-13 Thread Daniel Convissor
Hi Raphael: > What patch do you want to know more about? None. I am wondering if there is a resource for lay-people interested in installing PHP via packages so they can know any eccentricities they will encounter when compared to compiling it themselves. For example, you discussed changing s

Re: [PHP-DEV] Throwing an E_DEPRECATED for short_open_tag

2010-01-13 Thread Rasmus Lerdorf
Raphael Geissert wrote: > Rasmus Lerdorf wrote: > >> Raphael Geissert wrote: >>> However, we would like to contribute in the quest to make applications >>> stop using short_open_tag. To do so, we have decided to throw an >>> E_DEPRECATED warning when an application makes use of short_open_tag. The

Re: [PHP-DEV] Throwing an E_DEPRECATED for short_open_tag

2010-01-13 Thread Raphael Geissert
Rasmus Lerdorf wrote: > Raphael Geissert wrote: >> However, we would like to contribute in the quest to make applications >> stop using short_open_tag. To do so, we have decided to throw an >> E_DEPRECATED warning when an application makes use of short_open_tag. The >> current implementation can b

Re: [PHP-DEV] 5.3 release schedule and other bits

2010-01-13 Thread Raphael Geissert
Daniel Convissor wrote: > Hi Raphael: > > On Tue, Jan 12, 2010 at 02:48:38PM -0600, Raphael Geissert wrote: >> As a first step I'll be trying to forward most of our >> patches so that there's a minor divergence. > > Is there a document somewhere that explains the changes the Debian team > has ma

Re: [PHP-DEV] About optimization

2010-01-13 Thread Rasmus Lerdorf
Alain Williams wrote: > On Wed, Jan 13, 2010 at 07:48:17AM -0800, Rasmus Lerdorf wrote: >> Alain Williams wrote: > >>> Unfortunately: APC does not work with PHP 5.3 -- I have a site where I would >>> love to use it but I cannot. I use APC to great effect elsewhere. >> The svn version works ok with

Re: [PHP-DEV] About optimization

2010-01-13 Thread Rasmus Lerdorf
Tim Starling wrote: > Given this, sometimes it's easy to forget that PHP is pathologically > memory hungry, to the point of making simple tasks difficult or > impossible to perform in limited environments. It's the worst language > I've ever encountered in this respect. An array of small strings wi

Re: [PHP-DEV] 5.3 release schedule and other bits

2010-01-13 Thread Raphael Geissert
Johannes Schlüter wrote: > Hi, > > On Tue, 2010-01-12 at 14:48 -0600, Raphael Geissert wrote: >> Hello, >> >> At Debian we are planning to include PHP 5.3 in Squeeze, the next stable >> release. As such, I would like to know for example when we could expect >> 5.3.2 and 5.3.3 to be released. >

Re: [PHP-DEV] About optimization

2010-01-13 Thread Alain Williams
On Wed, Jan 13, 2010 at 07:48:17AM -0800, Rasmus Lerdorf wrote: > Alain Williams wrote: > > Unfortunately: APC does not work with PHP 5.3 -- I have a site where I would > > love to use it but I cannot. I use APC to great effect elsewhere. > > The svn version works ok with 5.3. Turn off gc though

Re: [PHP-DEV] Numerical string comparison - octal and hex.

2010-01-13 Thread Richard Quadling
2010/1/13 Rasmus Lerdorf : > Richard Quadling wrote: >> Hello. >> >> In looking at numer vs string comparison, I think I've found an oddity. >> >> You can successfully compare hex strings ... >> >> var_dump(255 == '0xff'); >> >> but not octal strings ... >> >> var_dump(63 == '077'); >> >> >> Is thi

Re: [PHP-DEV] Numerical string comparison - octal and hex.

2010-01-13 Thread Rasmus Lerdorf
Richard Quadling wrote: > Hello. > > In looking at numer vs string comparison, I think I've found an oddity. > > You can successfully compare hex strings ... > > var_dump(255 == '0xff'); > > but not octal strings ... > > var_dump(63 == '077'); > > > Is this a bug (lack of octal support) or a

Re: [PHP-DEV] Numerical string comparison - octal and hex.

2010-01-13 Thread Richard Quadling
2010/1/13 hack988 hack988 : > I think it's not an but! > you must read carefuly about "Single quoted" and "Double quoted" > > 2010/1/14 Richard Quadling : >> Hello. >> >> In looking at numer vs string comparison, I think I've found an oddity. >> >> You can successfully compare hex strings ... >> >>

Re: [PHP-DEV] Numerical string comparison - octal and hex.

2010-01-13 Thread hack988 hack988
I think it's not an but! you must read carefuly about "Single quoted" and "Double quoted" 2010/1/14 Richard Quadling : > Hello. > > In looking at numer vs string comparison, I think I've found an oddity. > > You can successfully compare hex strings ... > > var_dump(255 == '0xff'); > > but not octa

Re: [PHP-DEV] 5.3 release schedule and other bits

2010-01-13 Thread Raphael Geissert
Alexey Zakhlestin wrote: > > Great news! > Does it mean, that 5.3 will move to "unstable" branch soon? > (currently, Debian has 5.3 only in "testing") > It is currently in "experimental," but yes, we will soon be uploading it to unstable so that it later migrates to testing. Cheers, -- Rapha

Re: [PHP-DEV] About optimization

2010-01-13 Thread Tim Starling
Graham Kelly wrote: > Overall though, more often than not PHP is not the bottleneck of your > program and thus optimization wont get you too much. In a lot of ways, PHP is already well-optimised. The hash tables are fast, the executor is decent, as executors for weakly-typed languages go. Many int

[PHP-DEV] Numerical string comparison - octal and hex.

2010-01-13 Thread Richard Quadling
Hello. In looking at numer vs string comparison, I think I've found an oddity. You can successfully compare hex strings ... var_dump(255 == '0xff'); but not octal strings ... var_dump(63 == '077'); Is this a bug (lack of octal support) or an unexpected feature (hex support)? Neither format

Re: [PHP-DEV] About optimization

2010-01-13 Thread Rasmus Lerdorf
Alain Williams wrote: > On Wed, Jan 13, 2010 at 10:25:01AM -0500, Graham Kelly wrote: >> Hi, >> >> Optimizations such as 5+7 into 13 really don't get you much. ZEND_ADD (and >> other basic opcodes) are not in any way a slow point in a program. And >> unfortunately to be able to optimize these you w

Re: [PHP-DEV] 5.3 release schedule and other bits

2010-01-13 Thread Daniel Convissor
Hi Raphael: On Tue, Jan 12, 2010 at 02:48:38PM -0600, Raphael Geissert wrote: > As a first step I'll be trying to forward most of our > patches so that there's a minor divergence. Is there a document somewhere that explains the changes the Debian team has made? (Other than reading a 600 kb dif

Re: [PHP-DEV] About optimization

2010-01-13 Thread Alain Williams
On Wed, Jan 13, 2010 at 10:25:01AM -0500, Graham Kelly wrote: > Hi, > > Optimizations such as 5+7 into 13 really don't get you much. ZEND_ADD (and > other basic opcodes) are not in any way a slow point in a program. And > unfortunately to be able to optimize these you would probably need to put in

Re: [PHP-DEV] About optimization

2010-01-13 Thread Graham Kelly
Hi, Optimizations such as 5+7 into 13 really don't get you much. ZEND_ADD (and other basic opcodes) are not in any way a slow point in a program. And unfortunately to be able to optimize these you would probably need to put in an extra pass in the compiler which would probably just slow things dow

Re: [PHP-DEV] Inconsistency redesign

2010-01-13 Thread mathieu.suen
Etienne Kneuss wrote: Hello, On Wed, Jan 13, 2010 at 2:36 PM, mathieu.suen wrote: Hi, I came across this: echo sizeof(array()); echo sizeof(""); $a = ""; php.net/count: "If var is not an array or an object with implemented Countable interface, 1 will be returned. There is one excep

Re: [PHP-DEV] Inconsistency redesign

2010-01-13 Thread Jille Timmermans
var_dump((array)""); Results in: array(1) { [0]=> string(0) "" } And 'array("")' is not empty. -- Jille Op 13-1-2010 14:50, Etienne Kneuss schreef: Hello, On Wed, Jan 13, 2010 at 2:36 PM, mathieu.suen wrote: Hi, I came across this: echo sizeof(array()); echo sizeof(""); $a =

Re: [PHP-DEV] 5.3 release schedule and other bits

2010-01-13 Thread Johannes Schlüter
Hi, On Tue, 2010-01-12 at 14:48 -0600, Raphael Geissert wrote: > Hello, > > At Debian we are planning to include PHP 5.3 in Squeeze, the next stable > release. As such, I would like to know for example when we could expect > 5.3.2 and 5.3.3 to be released. I hope that the new release branch me

Re: [PHP-DEV] About optimization

2010-01-13 Thread Dave Ingram
mathieu.suen wrote: Sebastian Bergmann wrote: Am 13.01.2010 12:18, schrieb mathieu.suen: Because any optimization, even very simple ones, impose a performance penalty in the default execution model of PHP which does not use a bytecode cache. For simple optimization I don't think so.

Re: [PHP-DEV] Inconsistency redesign

2010-01-13 Thread Etienne Kneuss
Hello, On Wed, Jan 13, 2010 at 2:36 PM, mathieu.suen wrote: > Hi, > > I came across this: > > echo sizeof(array()); > echo sizeof(""); > $a = ""; php.net/count: "If var is not an array or an object with implemented Countable interface, 1 will be returned. There is one exception, if var is NULL,

[PHP-DEV] Inconsistency redesign

2010-01-13 Thread mathieu.suen
Hi, I came across this: echo sizeof(array()); echo sizeof(""); $a = ""; var_dump( empty($a)); $a = array(); var_dump(empty($a)); So funny! How something can have a size greater than 0 but still be empty? I think PHP is reinventing the inconsistency word. But then let assume that empty is just

Re: [PHP-DEV] __toString(), __toArray()

2010-01-13 Thread Clint Priest
Etienne Kneuss wrote: Hello, On Tue, Jan 12, 2010 at 11:40 PM, Chris Stockton wrote: Hello, On Mon, Jan 11, 2010 at 8:32 PM, mm w <0xcafef...@gmail.com> wrote: cast is not needed in PHP i 'd rather be more interesting in class Obj { function __catch($data, $type) { //$type

Re: [PHP-DEV] 5.3 release schedule and other bits

2010-01-13 Thread Jani Taskinen
On 01/12/2010 10:48 PM, Raphael Geissert wrote: Hello, At Debian we are planning to include PHP 5.3 in Squeeze, the next stable release. As such, I would like to know for example when we could expect 5.3.2 and 5.3.3 to be released. Wouldn't we all. Haven't seen any merges to the release branch

Re: [PHP-DEV] About optimization

2010-01-13 Thread mathieu.suen
Sebastian Bergmann wrote: Am 13.01.2010 12:18, schrieb mathieu.suen: I would like to know why the opcode is not optimized. Because any optimization, even very simple ones, impose a performance penalty in the default execution model of PHP which does not use a bytecode cache.

Re: [PHP-DEV] 5.3 release schedule and other bits

2010-01-13 Thread Ferenc Kovacs
the path is like unstable -> testing -> stable so the testing will be the new stable. http://en.wikipedia.org/wiki/File:Debian-package-cycle.png Tyrael On Wed, Jan 13, 2010 at 11:00 AM, Alexey Zakhlestin wrote: > > On 12.01.2010, at 23:48, Raphael Geissert wrote: > >> Hello, >> >> At Debian we a

Re: [PHP-DEV] About optimization

2010-01-13 Thread Sebastian Bergmann
Am 13.01.2010 12:18, schrieb mathieu.suen: > I would like to know why the opcode is not optimized. Because any optimization, even very simple ones, impose a performance penalty in the default execution model of PHP which does not use a bytecode cache. Only when the bytecode is not regenerated

[PHP-DEV] About optimization

2010-01-13 Thread mathieu.suen
Hi, I would like to know why the opcode is not optimized. Even for some very simple optimization like constant folding. For exemple: line # op fetch ext return operands ---

Re: [PHP-DEV] Throwing an E_DEPRECATED for short_open_tag

2010-01-13 Thread Derick Rethans
On Tue, 12 Jan 2010, Raphael Geissert wrote: > As mentioned on my other post, at Debian we are planning to include > 5.3 in Squeeze. Given that the development and production php.ini > files both turn short_open_tag by default but many applications > shipped by Debian itself still require it to

Re: [PHP-DEV] __toString(), __toArray()

2010-01-13 Thread Ionut G. Stan
It appears that, mm w is talking about some aspect oriented feature. I would welcome a magic method that would intercept calls/access to existing methods/properties (not only inaccessible ones), in the same sense that __getattribute__ works in Python for example IIRC. It may also be a good tim

Re: [PHP-DEV] __toString(), __toArray()

2010-01-13 Thread Etienne Kneuss
Hello, On Tue, Jan 12, 2010 at 11:40 PM, Chris Stockton wrote: > Hello, > > On Mon, Jan 11, 2010 at 8:32 PM, mm w <0xcafef...@gmail.com> wrote: >> cast is not needed in PHP >> >> i 'd rather be more interesting in >> >> class Obj { >>     function __catch($data, $type) { >>            //$type [ s

Re: [PHP-DEV] 5.3 release schedule and other bits

2010-01-13 Thread Alexey Zakhlestin
On 12.01.2010, at 23:48, Raphael Geissert wrote: > Hello, > > At Debian we are planning to include PHP 5.3 in Squeeze, the next stable > release. As such, I would like to know for example when we could expect > 5.3.2 and 5.3.3 to be released. Great news! Does it mean, that 5.3 will move to "u