« first day (1528 days earlier)      last day (3402 days later) » 

7:09 PM
@NikiC Just wanna throw an idea off you: Could we add an is_null() macro to Zend? It's not as crazy as it seems.
the problem is stuff like if (UNEXPECTED((a = b(Z_STR_P(c))) == NULL)) {
there's so many brackets it's easy to slip up and make it assign the comparison to a, rather than the function call result
whereas this wouldn't have that issue: if (UNEXPECTED(is_null(a = b(Z_STR_P(c))))) {
@Fabor ikr
 
@AndreaFaulds s/brackets/parenthesis/
 
@LeviMorrison :D
 
Also, I would say the issue here is because of style.
 
string(239) "class Foo
property foo public not-static long 12
property bar public not-static long 13
method public not-static not-final getFoo long
begin
var $1 unknown
propertyfetch foo $this $1
return $1
endmethod public not-static not-final
endclass"
 
Actually, along the same lines, a macro for if (UNEXPECTED()) could go some ways to reducing bracket hell
 
7:13 PM
Just do the assignment on the line before.
 
@LeviMorrison not possible, if/elseif/else
 
You posted an if. It can be done before an if.
 
sure, but it's also done in else ifs :)
 
I'd say that's probably horrible as well.
(Would have to see a specific example)
 
@LeviMorrison grep EG(function_table) in zend_vm_def.h
ifu (is_null(a = b(Z_STR_P(c)))) { ?
 
7:16 PM
Hi, is it faster to do 1 big mysql dump or lots of separate dumps? :)
 
Although, actually
is_null is unnecessary... we could just use !...
if (UNEXPECTED(!(a = b(Z_STR_P(c))))) {
yay
maybe I should make a language with POWER BRACKETS
 
Ugh, I would not want an IFU macro.
 
@LeviMorrison yeah, it doesn't seem like such a good idea
though, god, it'd be so much nicer than if (EXPECTED( everywhere :(
 
I think the EXPECTED and UNEXPECTED macros are horrid
 
Yeah.
 
7:18 PM
Want to know the proper way of doing that? Use your compiler for profile guided optimization...
 
Do our target platforms even support static prediction hints?!
 
It's stuff like this that makes PHP-src just that much less enjoyable.
 
They haven't been in Intel processors since the Pentium 4
@LeviMorrison You know what... kinda tempted to #define them away
 
@AndreaFaulds yes
 
@ircmaxell Oh? I thought modern platforms didn't support hints?
 
7:21 PM
the processor may not
but the compiler does
for example
 
Ah, right
 
If we're going to make the compiler work we should just use profile guided optimizations.
 
to determine which way to branch (jmpz vs jmpnz)
 
I agree with Levi there
 
Also, the cost of getting one of these macros wrong could be quite high.
 
7:22 PM
@LeviMorrison not all of our target compilers support that
 
Though doing a good job of profiling is important
 
@ircmaxell I honestly don't care.
 
Bear in mind that the PHP test suite is not a typical application
@ircmaxell not all of our target compilers support hints either
 
We don't ship binaries.
 
We don't even ship working code.
ducks
 
7:23 PM
@AndreaFaulds precisely why expected/unexpected is actually somewhat reasonable
I'd be curious to see statistics on compilation options
but if you're talking about optimizations, how many people are compiling PHP at -O3, and do we know if PHP is stable at -O3?
 
I test on O3.
Everyone should test O3.
If code doesn't work on O3 you are making some wrong assumptions.
 
We also should compile on -Wall, though we don't.
 
@AndreaFaulds yup
 
-Wall -Wextra
 
@LeviMorrison does travis run the test suite on -03?
 
7:25 PM
-Mauer -Antifaschistischerschutzwall
 
New projects should start with a flags line with something like: -std=<your choice> -Wall -Wextra -Werror
This generates basically the maximum amount of warnings and errors on warning.
You have no idea how worried I get when I build projects and see warnings.
There are legitimate reasons for not erroring on warning; unused arguments are not always an issue, for example.
 
@ircmaxell public $foo, $bar;
 
I know it's not a perfect solution, but could we at least slim down the hint macros a bit?
 
Maybe it's a sign of a design that could be work (emphasis on maybe).
 
EXPECTED() and UNEXPECTED() are pretty long
 
7:28 PM
Would be wonderful if UNEXPECTED was equivalent to !EXPECTED ^^
 
For hints they take up way too much space, a lot of common Zend macros are shorter, e.g. EG(), Z_STR_P()
@LeviMorrison hah
I wonder if it is
In any sane compiler it probably is, right?
 
Someone should test. They might actually be equivalent.
 
hmm
would anyone mind them becoming EXP() and NEXP()?
 
@NikiC I didn't realize that was valid syntax...
@NikiC I didn't realize that was valid syntax...
 
Really?
 
7:30 PM
@ircmaxell I don't get what you mean there
@AndreaFaulds why not just yoda?
if you assign-and-compare always yoda
 
@NikiC ?
 
Yoda, you must.
 
Also, yeah, I figured out earlier that you can just do !()
Do you mean foo = bar(), foo ?
 
I mean NULL == (a = fn())
I left the parens because I'm not sure in C, but in PHP you can write null === $a = fn() this way
 
@NikiC Ah! I see, good thinking.
I wonder why we do == NULL in Zend in places, though. I wonder if it's bad habits from PHP code
Since in PHP !x =/= x === NULL
 
7:35 PM
Some might consider the explicit comparison to be good practice
 
Possibly.
 
Especially those influenced by Java, where it is required
 
What, really? Java sux then rox please don't hurt my family please
:p
 
@AndreaFaulds EXP() is a 'bit' confusing with the exp() math function.
 
I was writing Java yesterday. Always forgot to use a != null (means passing some Object to a place where a boolean is required..., means compile failure)
 
7:41 PM
@Danack Yeah, I did think that might be a problem.
I think you'd easily distinguish them in practice, however ;)
 
Well, most of the time.
 
if (EXP(exp()))
By the way, could we make $_ special?
Completely unrelated, but having a stock, possibly optimised garbage variable might be handy
 
@NikiC well, the namesapce name visitor adds a namespacedName subnode
I'd like to be able to add that at construction time, but I can't
so I have to do things like:
$node = new AstClass("Foo");
$node->namespacedName = new FullyQualified(["Foo"], []);
 
@NikiC } else if (UNEXPECTED(NULL == (fbc = zend_lookup_function(Z_STR_P(function_name))))) { <-- happy? :)
Actually, you know what C needs?
.
 
Hi can someone please tell me if its better to dump large SQL files into a MySQL database in one big go or would it be faster to split the SQL files up and insert them that way?
 
7:49 PM
(== NULL) (fbc = zend_lookup_function Z_STR_P function_name) <-- Haskell-style syntax
@jskidd3 What do you mean by "better"?
 
@AndreaFaulds uh, yeah, no.
 
@AndreaFaulds faster
 
@NikiC ^^
 
If it was one big file it would be 5GB
20-30 million rows
 
@jskidd3 Simple question, probably a complicated answer. The only thing that makes a huge difference is turning off indexes while doing large inserts.......but you should probably be looking at a dedicated program for doing this, not just doing it via sql.
 
7:51 PM
@jskidd3 5GB is not big for a dump. Leave it as one file, and just disable indexes on import
 
e.g. vitobotta.com/… - disclaimer, I have not actually used this.
 
@ircmaxell Fantastic thanks
One other thing
Bearing in mind it's 5 gigabytes worth, would another option be to just insert dynamically while parsing the file?
I have written a script that parses lots of XML files, its either parse and write SQL to large file
Or stream and insert directly into database using PDO driver
 
you haven't said why you're doing this
 
because I need to insert a lot of data into a database
I thought I covered that :P
 
eih
 
7:55 PM
@jskidd3 You can use LOAD DATA INFILE
 
not if your database administrators are competent
 
@Fabor Can you do that with SQL files also? I was under the impression it was only for CSVs
 
By the way
you should do this with the mysql client and not from PHP code
unless it's not one-off
 
@AndreaFaulds s:/would/should/
 
oh, didn't see it was sql
 
7:57 PM
I have access to exec() so can just do a dump like that if its quicker
 
@ircmaxell :s/s:/:s/
 
@ircmaxell Just a tip, you can write new FullyQualified("Foo") there as well ;)
 
@NikiC fair, but the point was more about the separate initializer
 
@ircmaxell So what you want to do is new AstClass("Foo", ["namespacedName" => new FullyQualified("Foo")]);?
 
yup
and with other subnodes as well
(I annotate type information into nodes as jitType)
 
8:00 PM
Heh, that's what the attributes are for. But I get that that's more to type ^^
 
hello guys,can you help me with this little unix command? I know it's not a php question but i think most of you'd be able to answer this question.
how do i add a mail user from command line in ubuntu? i mean i want to get such email abuse@example.com. so i need to have an abuse user, not for login but for mail
 
hmmm, fair enough
 
$ sapi/cli/php -r 'spl_autoload_register(function ($name) { var_dump($name); include "$name.php"; }, true, false, SPL_AUTOLOAD_FUNCTION); test();'
string(4) "test"
hello, world
$ sapi/cli/php -r 'spl_autoload_register(function ($name) { var_dump($name); include "$name.php"; }, true, false, SPL_AUTOLOAD_FUNCTION); $x = "TEST"; $x();'
string(4) "TEST"
hello, world
$ sapi/cli/php -r 'spl_autoload_register(function ($name) { var_dump($name); include "$name.php"; }, true, false, SPL_AUTOLOAD_FUNCTION); $x = '\test'; $x();'
^^
ES FUNKTIONIERT!!!!!!
PHP 7 will have function autoloading, if all goes well :)
 
so you've got code that I had running 2 years ago... :-P
also, strong -1 on true, false
 
@ircmaxell :p
@ircmaxell That's the existing API, I can't do much about it. I want to avoid adding yet another set of functions
We already have TWO autoloading APIs
 
8:06 PM
also: did you patch function autoloading in, or did you refactor that god-aweful shitshow of an implementation of spl_autoload?
@AndreaFaulds which is why my original patch refactored them to one implemenation under the hood, not two as it is today
 
@ircmaxell More the former than the latter. It shares some of the implementation with SPL.
 
@AndreaFaulds Drop the old one.
 
after looking at the SPL implementation, it needs to go
 
Btw, I finished up an old HT post earlier: nikic.github.io/2014/05/23/…
 
Not really.
 
8:07 PM
it's a miracle it works as is
 
The SPL implementation isn't that bad...
 
yes it is
 
And spent an inordinate amount of time fighting Jekyll and Disqus again :(
 
Basically, it works like this. I made zend_lookup_function, equivalent to zend_lookup_class and very similar. It then calls a C function containing the guts of spl_autoload_call.
 
yes, and spl_autoload_call is where all the horror was
 
8:08 PM
spl_autoload_call is the nicest-looking part of the SPL autoloading implementation
 
to autoload, it calls a C function, which calls a PHP function which calls a C function, whcih then calls an array of PHP functions in sequence
 
l_autoload_running = SPL_G(autoload_running);
SPL_G(autoload_running) = 1;
ZEND_HASH_FOREACH_STR_KEY_PTR(functions_table, func_name, alfi) {
    zend_call_method(Z_ISUNDEF(alfi->obj)? NULL : &alfi->obj, alfi->ce, &alfi->func_ptr, func_name->val, func_name->len, retval, 1, name, NULL);
    zend_exception_save();
    if (retval) {
        zval_ptr_dtor(retval);
        retval = NULL;
    }
    if (zend_hash_exists(symbol_table, lc_name)) {
        break;
    }
} ZEND_HASH_FOREACH_END();
zend_exception_restore();
That's the main bit that's shared
That and _autoload_(un)register (though most of what it does is skipped for functions since functions don't use the __autoload standin, but rather go straight to an array of PHP functions)
 
mine was 128 lines of code more than the current implementation, and includes a full refactor: github.com/ircmaxell/php-src/compare/function-autoloading
 
zend_autoload.c sure is pretty
 
@ircmaxell eek
 
8:14 PM
Basically, the way I've done it, functions are all nice, classes are just as horrid as before
 
@NikiC that's how it's worked since 5.2 included spl_autoload_register
 
But you could quite easily scrap __autoload
spl_autoload_register is a gigantic hack, it's pretty amusing
It's weird that it's internal at all, you could implement it in userland.
 
the only part you can't implement in userland is compatibility with an existing __autoload
 
@ircmaxell Only if you lack runkit! :p
But yes.
 
8:17 PM
@ircmaxell spl_autoload_call isn't horrifying at all
It's how it gets called that is.
 
that it's a php function is
 
the PHP function to call is cached in EG(autoload_func): lxr.php.net/xref/PHP_5_6/Zend/zend_execute_API.c#998
the whole thing is just...
 
it's very roundabout
 
There were 2 main gripes with my implementation last time it was proposed:
1. That I namespaced the new autoloader inside php (which who cares, move it out if people don't like it).
2. That I allowed declaring autoloader callbacks that could deal with multiple types (functions, classes and constants) rather than requiring a one-callback-to-one-type relationship
 
8:24 PM
I have no problem with 2, but I didn't (and don't) like adding a new set of functions to handle autoloading
The existing API isn't really broken
 
1. pls namespace oh pls
 
yes it is
you're adding a 4th constant parameter to a argument list that's preceeded by 2 booleans
spl_autoload_list <-- how do you plan on implementing that so that end-users know what type of autoloader they get back (whether it's a class, function, etc)
also: the api is in SPL. It's not a SPL functionality, it's engine functionality (and should be better hooked into it)
the current API works for classes
but when you add in functions and constants, it really doesn't work. You can shoe-horn it in, and make it work, but that doesn't mean it's clean
I'm definitely not saying my implementation is perfect
 
I agree with Anthony on this one.
 
but the current one is worse IMHO
 
It's not really SPL, and the current API sucks.
 
8:29 PM
@ircmaxell Do you mean spl_autoload_functions? I solved that.
 
@AndreaFaulds how?
 
spl_autoload_functions(SPL_AUTOLOAD_FUNCTION);
 
so you only return one type of autoloader in the list
 
Each type of autoloader has its own list
 
fair
 
8:30 PM
Obviously it'd break things if it started returning function autoloaders. So it doesn't, it continues to only return class autoloaders unless you ask otherwise
I realise that spl_autoload_register($foo, true, false, SPL_AUTOLOAD_FUNCTION); isn't the nicest. But it's a function typically called only once in an application by automatically-generated code.
 
if I cleaned up the implementation that I have (make it ready for 7, and test it), would someone want to revive and run with the RFC?
 
We've done rand() and mt_rand() before, mysql_escape_string() and mysql_real_escape_string() before... I'd rather not have __autoload, spl_autoload_register and php\autoload_register.
 
@AndreaFaulds both were because of underlying library changes tho
 
@ircmaxell So were mysql_ and mysqli_, but I don't think it really justifies it.
 
I'd add a deprecated flag to __autoload
and eventually deprecate spl_autoload_register, which would only exist for legacy reasons
@AndreaFaulds I still don't think that's the same comparison
 
8:34 PM
Yeah, true
 
then again, just using spl_autoload_register does keep with php's spirit of "just hack it in and make it work"
 
The other thing is that named parameters would solve the only real problem with this approach
 
spl_autoload_register($foo, type: SPL_AUTOLOAD_FUNCTION);
@ircmaxell It doesn't really excuse it, I know...
 
As I've always said, named parameters are a solution to needing to use shitty APIs. so let's just define sane APIs in the first place
 
8:36 PM
Yeah, I agree with that
 
@AndreaFaulds I doubt the validity of this statement.
 
I just don't think that two boolean parameters are enough to justify a new set of functions. ^^
@LeviMorrison It's probably only true for Composer users, yes ^^
@ircmaxell By the way, the patch as I described it is only how I've implemented it just now. I'll probably do the same thing you did and move the spl stuff into Zend for neatness and clean up classes a bit.
Short-circuiting the whole spl_autoload_call malarkey for classes would be a one-line change with my WIP code :D
 
@AndreaFaulds this is the only chance in maybe the next 5 years we have to introduce a nice API ... that's enough to justify almost anything ...
 
The existing API really isn't that horrible.
 
it's in the wrong place, implementation is strange, it's incomplete ... name another thing that could be wrong with it ?
 
8:45 PM
@JoeWatkins Wrong place is cosmetic, can be moved to Zend. Implementation fixing doesn't require API changes. It can be trivially "completed", as I've done.
 
but you just said 5 minutes ago that "it's not the nicest" ... we could have the nicest, possibly the only time we can have it in the next 5 years, maybe more ...
 
It's not bad enough to justify a new API
But this is bikeshedding ultimately, changing the existing API and adding a new one are equally simple
 
bc is trivial as far as I can see, if you made a better api it wouldn't be a hassle to retain bc, which is the only real concern ...
 
"FAST_ZPP" made it into master?
 
yeah
 
8:48 PM
I actually like the FAST_ZPP API better. It's much more descriptive.
 
@LeviMorrison but horrible to write…
 
yeah is nice, haven't used it yet ...
 
(especially for types like functions which have two values)
@bwoebi I still like it better.
It's more verbose but I actually like that verbosity in this particular case.
 
@LeviMorrison ditto
 
hmh
 
8:50 PM
@ircmaxell The RFC didn't pass yet, so it can be "disabled"
Never mind that disabling it sometimes breaks the build because nobody ever bothers testing with it turned off.
 
@AndreaFaulds WTF is code that didn't pass doing committed?
seriously
 
@ircmaxell performance
 
@AndreaFaulds THE VOTE ON THE RFC
 
@ircmaxell performance :p
 
now you're just going to cause merge headaches and potential sources of bugs
 
8:52 PM
(no seriously, I don't even either)
 
seriously, this is fubar
 
pretty strange actually ...
 
@ircmaxell it's not like it didn't pass, it just was not voted on…
 
@bwoebi doesn't matter
 
why wasn't it voted on ?
 
8:54 PM
because it never reached that stage
Dmitry just merged it
 
yay to cowboy committing, as long as you're a special person!
 
:/
@bwoebi You're an author of that RFC, put it to a vote.
 
bit late isn't it ?
 
Should still be voted on.
If it's rejected, we can still remove it, and quite easily too.
 
"quite easily"
 
8:57 PM
Yes.
With sed, even.
 
yay! more merge conflicts
jesus.
fuck it, I retract my offer to get my patch up to speed for 7
 
ooooh I see what happened ... my portal to backwards land finally works ...
 
@ircmaxell Why?
 
there are cases that there doesn't need to be an rfc, self contained mm updates being the last example that comes to mind but this was being discussed, it's a bit strange that the remainder of due process was skipped just because dmitry ...
 
@AndreaFaulds well, Dmitry is the main auther, please let him do it.
 
9:01 PM
@bwoebi OK, get Dmitry to put it to a vote.
 
mernin'
 
moin @PaulCrovella
 
doctrine y u so empty()? -_-
 
are we supposed to answer ?
 
9:06 PM
How a query which joins a few tables and a big one (with hundreds of millions of rows) can block all the connections to mysql…
 
assuming innodb, buffers not large enough most likely, creating temp tables and locks ...
 
myisam, but yes.
 
myisam only has table level locks ...
a large query is bound to block other connections using same table ...
 
which is not a problem generally. Until you have inserts which are waiting to lock and subsequent selects which are waiting for unlocking…
and somewhen max connection limit is exceeded…
 
maybe not, but can see that it could be a problem when trying to select hundreds of millions of rows at a time ...
 
9:18 PM
also: yay to not being able to build PHP from git since we depend on old versions of libraries
 
@JoeWatkins yup, we were trying a query and didn't manually kill it later…
If we test, we test with a few rows… and then bad queries are really bad on the hundreds of millions of rows table…
 
innodb and suitable configuration ftw @bwoebi
 
@JoeWatkins if the query does a full-table scan, innodb doesn't help here either…
 
find someone who knows how to tune queries
basically, find a DBA
 
yeah that ... I don't do databases really ...
 
9:22 PM
@ircmaxell Which ones?
 
@NikiC bison
 
@ircmaxell You building master?
If so, please drop the version check from configure and see if it works
It should work
If it does work, commit :)
 
@ircmaxell I regularly build software from source as part of my day job. I guess I'm just used to hand-installing dependencies.
 
I can't build either ...
 
(Though I agree we should support latest stable release for each dependency)
 
9:24 PM
@LeviMorrison I cannot install packages from non-trusted sources
so I'm stuck with repo-provided bison
 
You can always install things to your home directory.
As long as you have write access somewhere you can install your own versions of things.
 
I'd need to compile it by hand
and while that's definitely possible, no thanks
 
That's what I'm saying. I do that for my day job.
 
feels like that might violate agreement not to install software from non-trusted sources ?
 
@JoeWatkins precisely
@NikiC worked fine
 
9:25 PM
k
 
also, I'm not committing that :-P
 
bison 3 only was a problem because of tsrmls
 
gimme the diff, I'll do it ...
 
it aint a problem no more
 
w00t for that ...
 
9:27 PM
yay
can we fix asap in master?
 
@JoeWatkins I literally just commented it in the generated configure
 
@bwoebi Guessing randomly, index locks - google.co.uk/search?q=index+locks+innodb but you really need to analyze it.
 
I'll have a go at removing nicely ...
 
@JoeWatkins thx
I'd have done it myself, but my php vm is from the stone age and doesn't have bison 3 to test ^^
 
9:32 PM
done
 
@Danack well, yeah, it was just a bad query we forgot to kill while testing on production data
 
I think that's okay, there might be some future version we need to exclude ?
 
'while testing on production data' - ah not production, though right.
 
@Danack well, we queried the production database ;-)
form our test env
 
︵ヽ(`Д´)ノ︵ ┻━┻
 
9:35 PM
@bwoebi lol
 
@NikiC well, to test a select query… what can go wrong… except forgetting to stop it later :-D
 
$iDontAlwaysTestMyQueriesMeme->render("when I do, I use production data")
 
@NikiC best practice for zend_string's that are used internally for things like special function names, etc?
 
@ircmaxell I allocate them as globals during minit
 
in the engine?
 
9:40 PM
maybe I misunderstood the question
 
lxr.php.net/xref/PHP_TRUNK/Zend/zend_compile.h#874 <-- that list, converting a defined "string" into a zend_string for use in internal APIs
 
which internal api are we talking about ??
 
in general
 
well, hash has _str_ API for constant strings I guess, there is zend_string_literal_equals or something like that for comparison with zend_string passed from userland, maybe the answer is don't store zend_strings if you're not intended to return them to userland ? or else you'll have to have them in some globals I guess ?
 
I'm talking about APIs that are designed to work with userland strings, like lxr.php.net/xref/PHP_TRUNK/Zend/zend_execute_API.c#1038
 
9:48 PM
@ircmaxell Well, you got three options: Preallocate a global, init+release on call or alloca on call
 
Hey @ircmaxell: github.com/TazeTSchnitzel/php-src/compare/function_autoloading (WIP function autoloading, very initial patch)
 
preallocate it is...
eih
 
Ooh
Add constant zend_strings.
Surely can't be that hard to implement...
 
@AndreaFaulds -1
 
i.e. zend_string foobar = ZEND_STRING_CONSTANT("blah");
@ircmaxell why so negative ;_;
 
9:50 PM
@AndreaFaulds go for it
 
I'm unlikely to actually implement that, but it's always a possibility.
Do bear in mind that patch was very quickly written, no way that monstrosity will actually be the "end product"
For starters, I should move the autoloading stuff to Zend like you did.
I should also add tests, and handle constants.
I should probably get rid of autoload_func too...
In the end it'll probably not be that different from your patch.
 
er .... urm ...
 
@JoeWatkins ... mru .... re?
 
@AndreaFaulds lolwut
 
@NikiC ...why the lolwut, I'm scared
 
9:59 PM
@AndreaFaulds just seems the wrong way round, why not start at the beginning, why not provide the nice API you are going to somehow end up with and then worry about bc with the old SPL stuff after, if that's a worry ...
 
If you come up with a way that works in C89 and C++ and for static allocation, I'll be seriously impressed
 

« first day (1528 days earlier)      last day (3402 days later) »