« first day (4148 days earlier)      last day (815 days later) » 

12:01 AM
that's approximately the same distance from where I'm at to Paris :D
 
12:21 AM
@MarkR Except it's wrong about which page I want to view. :-)
@Tiffany Wait, you're moving?
 
12:44 AM
@MarkR From where I lived in Norway to the northern part of that country, was further then from where I lived to Rome...
 
meanwhile mainland uk is what, a thousand km
drivable from lands end to john'ogrotes in 15 hours
 
700km
1000 miles — 1424km to walk it.
It's tempting to try
@Girgias Que ce-que c'est SUTOM ?
 
1:13 AM
@Crell in about a month... couldn't find a place I was happy with in IL
signed a lease last night :S
 
nice place?
 
@Tiffany Aw. Where are you headed?
 
@Derick very nice :)
@Crell NM, lol
 
North Minnesota?
 
New Mexico
 
1:16 AM
:-þ
that's not close, is it?
 
over 1000 miles :P (1600km or so)
 
Definitely warmer...
 
I know what an ff-ing mile is. This country also stupidly uses it :-þ
 
lol
@Crell if Bloomington wasn't so cliquey and Chicago wasn't so expensive. I was tempted by Springfield, but by that point I wanted to move somewhere I had been considering for several months. IL isn't too bad of a state, but where I live... blech
 
 
7 hours later…
cmb
8:38 AM
@IluTov not 100% sure, since there are almost no builds to be expected; OTOH, it wouldn't hurt
 
moin
 
9:03 AM
@cmb I just tested it quickly yesterday and it seems PHP 7.4 doesn't build with the same configuration so there would need to be some adjustments. I haven't tried PHP 8.0 yet.
 
9:14 AM
Looks like PHP 8.0 also needs some adjustments. I'll take care of those tonight, I'm at work right now.
 
@MarkR Nice 1
 
Wes
10:02 AM
today i learned:

Content-Type: text/html;charset=UTF-8

che charset part is actually part of the mime type string
i thought it was part of http
 
Wes
10:54 AM
instantly hurt
 
cmb
@IluTov thank you! (and if it doesn't work out, maybe just rebase the PR onto PHP-8.0, so others might help :)
 
11:49 AM
G\o/\o/d m\o/rning happy hunchback of notre dame day
Camels are overrated
 
11:59 AM
@cmb If you can wait for 12 more hours it should be fine :)
 
cmb
@IluTov yes, sure :)
 
12:49 PM
The comments on throwing on undefined variables are a bit sparse, does anyone in here have anything they want to add on that they haven't had a chance to post yet? I'd prefer not to launch the vote and only then find issues
 
this becomes a default ? or is it only active on strict types
@MarkR
 
It's nothing to do with strict types
 
so it's a default ?
From now on the idea is that if there's an undefined variable you'll get an exception ?
 
Yes. You may wish to review the RFC it's all covered there.
 
Thanks for pointing me to the link, I agree with the idea, however I can see that this will have a heavy impact
target 9 ok
 
1:11 PM
I'm still not entirely convinced going all the way to errors only 5 years after going to warning is wise. If it were a greenfield language I'd be all for it, but given the billion lines of code out there we've already broken... :-)
3
 
Has to evolve too right ...
I think the community should be the enforcer of strict practices such as this one, perhaps a flag would be a better backwards compatible solution
@MarkR TS which I know you like so much provides strict capabilities, while regular JS doesn't, so perhaps the point I pointed out previously you can agree to.
 
Actually JS does, "use strict" will throw on undefined variables.
 
which to me this translates into declare(strict_types=1);
 
@Crell An error for 5 years, a notice for 15.
 
During which time half the world had notices off. :-)
 
1:20 PM
^
The RFC doesn't covers anything regarding undefined indices on arrays, I would assume that would be a throw case too
 
You assume incorrectly
 
Hm
Then to me it feels incomplete, it should be a case to handle
 
This makes me less supportive due to the inconsistency.
 
When we did this last time wiki.php.net/rfc/engine_warnings undefined variables and undefined indexes were split, the same will be the case here
The same will apply to undefined properties too. They're much harder to detect than undefined variables
 
@cmb Took an hour off work, there you go :) github.com/php/php-src/pull/8145
 
1:38 PM
I don't vote, but it's hard to vote when there's no visibility of the bigger picture, perhaps a reference should be added about the array / object topic
 
It does say verrrrry clearly it's about variables
 
Well I can't help myself but to ponder about the other topics
a clarification always helps
NOTE: If you are thinking about other topics such as array / object properties, this will be addressed on different RFC's
Just trying to help your RFC
 
I would expect over time almost all engine warnings will get promoted (because PHP error handling sucks), but that's about 20 things
 
^ I'm just being silly
 
quite.
 
1:50 PM
ColdPHPlay
 
I want to get a t-shirt saying strict_types is not a generic strict mode
 
I'll be re-writing wiki.php.net/rfc/sealed_classes this weekend for PHP 8.2, and opening the discussion again :)
 
I believe Girgias wants to hit a few on the list as well, we have plenty of time before 9.0 but if we miss it, our next opportunity would be 2030
 
@MarkR as I said on the list, an "unaffected functionality" section would be very useful here
 
@IMSoP hey there, the name is quite broad
 
1:53 PM
@ln-s strict_types you mean? yes, it's badly named
 
@Danack i remembered that the rust enums feature you are talking about can be implemented using sealed classes, see: https://3v4l.org/B1uF6, though, not exactly the same, as you can have multiple "Local" instances, while in rust there can be only 1.

( enum Node { Local, Remote(String) } )
 
@IMSoP then don't blame the user (poor me)
 
I clarified that the only things affected would be those with the "Warning: Undefined variable $varname" listing everything it won't affect would be literally everything else PHP does.
 
@ln-s I didn't blame you; I said it's a common misconception that I wish I could fix
 
Yeah it totally is
 
1:55 PM
it should have been called declare(scalar_arguments=throw) and declare(scalar_arguments=coerce) because that's all it does, and all it will ever do
 
I agree
I know you didn't blame me, just kidding
:)
 
i would gladly welcome a new declare(error_promotion=throw) that results in any non suppressed error ( that is, a warning, notice, ... etc ), to throw ErrorException.
 
@SaifEddinGmati hard no
a) you can do that with an error handler already; b) it makes a nonsense of having severities in the first place
 
why so? if it would only apply to that file, i think it's okay.
an error handler will also handle errors outside of my library for example.
 
We're trying to tackle 3 things here 1) That PHP will happily continue executing even after giving a big warning that it's probably broken and 2) Offering security by design, without the user having to opt-in to entirely common sense defaults and 3) Engine cleanup
 
1:59 PM
@SaifEddinGmati it might be quite hard to define what "inside the current file" means for "every possible notice", e.g. code executed by a callback from inside array_map
 
Back in the days of PHP 3 it maybe made sense to try and keep running regardless, but now it's 2022, software is enormously important, bugs have enormous impacts, and errors should be treated as such
 
@IMSoP following the same rules as strict_types=1
 
@SaifEddinGmati I think that already has some unintuitive edge cases with callbacks; and it only has to deal with function boundaries, because it only cares about parameters and return types
@MarkR yes, in general, I'm all for carefully making the language stricter; I don't think "abort the application on every Notice" is a sensible way of doing that, is all
 
@IMSoP yes ( e.g: here we need to wrap the function in order to enforce* strict scalar types: github.com/azjezz/psl/blob/2.0.x/src/Psl/Vec/map.php#L40 ), but using a different set of rules will only bring more inconsistency to the language
 
in a lot of cases, aborting the program unexpectedly is a lot more dangerous than continuing
 
2:03 PM
You're going to have to justify that because I think that's 100% wrong, although " a lot of cases" could mean... like, 10 cases.
 
@IMSoP don't think so, usually I'm glad that the program stopped working due to an error, as oppose to it continuing execution with incorrect result, as it's harder to track where things went wrong.
 
again, for things that are dangerous to continue, errors make sense
 
and I mean it in respect to engine warnings specifically
 
but allowing the run-time to have the concept of a warning, for cases that aren't dangerous, feels like a feature
 
@IMSoP it's hard to define "things that are dangerous to continue", as it always depends on the case.
 
2:07 PM
@SaifEddinGmati right, which is why blindly converting everything to fatal is a flawed idea, IMO
 
Right, and in general we consider anything with a warning as a potentially dangerous / unsafe / unexpected situation.
 
everything can be dangerous, from undefined variable, to incrementing a resource.

the safe bet is to assume everything is dangerous, rather than assuming everything is safe.
 
@MarkR define "we"
 
@IMSoP Internals as a group chose to vote in favour of the 8.0 Engine Warnings RFC, which includes comments such as "This is classified as a warning, because it usually indicates a programming error". And programming errors are dangerous / unsafe / unexpected.
 
Can we pleeeeeease also fix echo [];
 
2:14 PM
^ haha
totally
 
@MarkR that doesn't mean that all existing warnings are for that reason
 
cmb
> echo [];
an empty array
 
@cmb github.com/php/php-src/pull/8145 Can I merge? The relevant builds passed. Then I should really get back to work :P
 
@IMSoP The RFC also removed things which were warnings that didn't fit the criteria
 
a lot of this comes down to the fact that PHP can only catch these things at run-time, by which point it's already too late to do the safe thing
if you have a typo in the middle of your payment processing code, the safe thing to do is not to start processing the payment
but a run-time error will cause you to abort half-way through processing the payment
 
cmb
2:20 PM
@IluTov yes, please go ahead!
 
If you have a typo in the middle of your payment processing code, the safe thing to do is to throw an exception and have your transaction unwind because of it
 
@cmb Done, I'll add testing for the extensions I mentioned and werror later tonight.
 
cmb
take your time (the most urgent thing is done)
 
@MarkR unwinding may not be trivial, or even possible; the best you can do may be to notify someone and manually sort out the broken transaction
and even that requires some careful defensive programming to have considered the different places an error might occur
 
@MarkR ^ but a notice* in the situation can lead to a permanent damage. e.g: 3v4l.org/anriQ
 
2:24 PM
@cmb Ok then, see you later :)
 
@SaifEddinGmati I'd say that's a flaw with us needing to offer better ways of casting ints tbh.
 
@MarkR yea, that's a whole different problem
that's just an example of how continuing execution with an undefined var leads to a a severe problem that can go unnoticed.
 
I'm sure all of us here are quite capable of coming up with convoluted schemes where throwing an engine error within a function can cause additional problems, but we're here to design a language for the masses, not stifle its development to cater to code that was broken or badly written in the first place.
 
yes, I agree
I just don't agree that that means a language with zero warnings, only errors
unless we introduce an official static analyzer (AKA "compile-time errors")
and just to be clear, I'm inclined to vote "Yes" on your current RFC (although I'd still like the list of affected scenarios to be spelled out more explicitly)
 
@IMSoP honestly that would be huge, something that can detect potential errors/warning ahead of execution, like the use of an undefined variable, call to undefined function/methods/classes/enum cases/constants ... etc.
 
2:32 PM
@SaifEddinGmati well, yeah; there's several such tools out there, but none are "official", so no RFC can account for them :(
 
@IMSoP yea, phpstan, psalm, phan ... etc, can detect these errors, but they do way much more things, which honestly i don't think they should be in core ( e.g: type checking, generics .. etc )
 
type checking is definitely in the same category for me
 
There's a lot of benefits to having such things in the core, something that can accurately perform type checking ahead of time can analyse call graphs to perform optimizations that it otherwise wouldn't be able to
 
@IMSoP basic type checking for scalars, yes, but not phpdoc parsing, no generics, no typed arrays.. etc ( unless php gets generics/typed arrays support )
 
but that's the point; if it was official, it would be the typed arrays support
potentially with a hybrid system like some other languages use, where type checks can happen at run-time, but only when they can't be proved statically
 
2:35 PM
official typed arrays support should not be based of comments ( phpdoc )
 
Yeah we'd never do that Saif
Equally psalm / phpstan support adding additional annotations far beyond what PHP would ever support, things like non-empty-strings, ranges etc
 
again, I'd love for those to be native
but yes, with native syntax, not phpdoc
 
@MarkR yea, i think that would offer some optimization as well, knowing exactly what data type every variable holds, can allow PHP to allocate space exactly for what is needed, and do less guessing at runtime.
@MarkR i think these can be supported in core, but with their own syntax ( e.g: int[2..32] $base, string[1...] $nonemptystring, array[1...] $nonemptyarray ).
 
it's how a lot of more recent scripting languages work - there's a compile step that does static analysis, and inserts assertions only for the things it can't prove
 
Opcache already does certain checks, but it's confined to a function. It cannot for example use that $foo->bar is an integer, to perform the same optimizations as it would as if $foo was an integer assigned within the function.
 
2:39 PM
whereas in PHP right now, every single type check is a run-time assertion, and the more complex we make them, the more performance we sacrifice
 
Exactly, which comes back to why I think PHP's future lays in the realm of whole-application compiling.
 
definitely
 
lolwat. It's exactly what PHP is not.
It's the "edit", "refresh", "See fix" cycle that makes it so easy to get started with.
 
considering int ranges are supports, function foo defines 1 argument with type `int[2...32] $base`, and i do:
$base = (int) $request->parameter['range'];
foo($base);

where would the assertion be?
 
@Derick Yeah? Tell that to preloading.
I should probably clarify I think that production use would be whole application compiled.
 
2:41 PM
@SaifEddinGmati exactly where it is now for the int type on the parameter; all PHP is really doing is assert(is_int($foo ))
 
I really don't believe preloading is used a lot, let alone known about.
 
I'd agree with that, but I still think it's likely the future. That and long running applications.
 
@IMSoP but when someone passes $base, and PHP knows that it is already int[2..32], wouldn't it be redundant?
 
@SaifEddinGmati yes, that's why you need the static analyser, to decide which assertions are actually needed at run-time, and which are guaranteed to pass
right now, there is no part of PHP that can make that assumption, except OpCache possibly in some restricted cases where it has enough context
 
$base = (int) $request->parameter['range'];
foo($base);
foo(2);

assertion will be enabled for the first call, and disabled for the second, but aren't we losing performance switching assertion on/off here? wouldn't it be better to place the assertion on $base before the foo($base) call?
 
2:45 PM
I'll leave that to the people who know how to write the compiler
 
The problem with it is you have to know foo() ahead of time, and PHP's funky "might include, might not, might include something completely different" makes it complicated. That's why locking it in ahead of time via whole application scanning is the only way to do it properly
type checking on params is on the receiver side
 
I think per-module is probably the future
as in: each of your Composer dependencies is pre-loaded into opcache, with parts able to be marked package-private
 
Yeah potentially module level things too, when we have them
We'll definitely end up with a dev-mode and a production-mode I'd think
 
I guess we already have to some extent: php.net/manual/en/…
 
The closest thing we have at the moment is the assertions config options
 
2:49 PM
in dev, you want opcache to be checking your files for changes; in production, you want it not to touch the file system unless absolutely necessary
 
Even with opcache you can invalidate a file at runtime, a production mode would effectively lock it in similar to preloading.
 
I doubt that's very common in practice, though; I bet mostly people will simply flush the whole thing by restarting apache/fpm after a deployment
 
Hi guys, can anyone help me? I have a code (PHP) that is returning an error.
Resuming, I need to get a value that is in a JSON using foreach and is returning "WARNING Illegal string offset 'NEED' on line number xx"
 
3:04 PM
you are probably using a json string as an array, you need to decode it first.

$array = json_decode($json);
$need = $array['need'];

instead of

$need = $json['need'];
 
im using
json_decode($json, true);
if u need, i send a link with my code. I've been trying to solve this for hours xd
 
@Noss1v you can share the relevant snippet of the code via 3v4l.org
 
@SaifEddinGmati 3v4l.org/OXI9D
 
you are looking for NEED in values of $var, while NEED is a key in $var itself.
 
@SaifEddinGmati because $json is a variable that will change, so, maybe I'll try to use "if" to solve this
sometimes the value "DEBITO" will come more often in the variable $json
 
3:22 PM
yea, in that case you need an if statement :)
 
thx, i'll try now :))
 
 
1 hour later…
Wes
4:38 PM
do you think "12" for the microsecond format in DateTime is 0.12 seconds, or is it 0.000012 seconds?
 
4:58 PM
it's 12 microseconds, not .12th of a second
0.12 seconds is 120000 microseconds
 
Wes
i've quite possibly made that mistake in the past as i've never bothered to pad it with zero. sigh
 
cmb
(int) "12"
 
5:50 PM
@Derick French Wordle based on a (now discontinued) TV show called MOTUS
@IMSoP Get me one while you're at it
@SaifEddinGmati I've got a prototype for that as TCM in part hired me to do that
 
I'm looking at documentation for wsdl cache when using SoapClient but it's not exactly clear about what behavior I should expect. If I disable wsdl cache or set caching to WSDL_CACHE_NONE does that mean that it will re-load the WSDL file before each SOAP request is made? Or, does it still load the WSDL file's contents into memory for the lifetime of the SoapClient object?
 
6:07 PM
@Girgias isn't that likely to have bad performance due to the switching required?
 
@Danack Not really, it still uses the exact same code path, just that when that global is set for the file it throws an error instead of emiting a warning:github.com/Girgias/php-src/pull/2/files
But it's been a long while since I've touched it
 
@scorgn no only once during construction of soapclient object
 
@Girgias The Dutch brought back "Lingo" some time ago. Staple of my youth :-)
 
6:25 PM
@Derick IIRC it was based on that show :p
 
@beberlei Okay thanks, that's what I imagined but I wasn't sure if the in-memory cache option meant that it didn't store it in memory to begin with
 
Why don't we have ordinal in enums?
 
is that not covered by being able to associate a value?
 
6:41 PM
No
enum WeekDay: string {
    case Sunday: 'SU';
    case Monday: 'MO';
}
What is the ordinal of WeekDay::Monday ?!
 
what would you use it for?
 
for checking the ordinal of day of week
as is used in calendars
 
why is that a more fundamental property than the English name, or a three-letter rather than two-letter abbreviation?
 
@brzuchal what does php's date functionality do?
 
rfc 5545 uses two letter symbols
 
6:46 PM
personally, I'm not a fan of blessing one "value" for enums in the first place, so I'd probably define getTwoLetterCode(): string, getThreeLetterCode(): string, getOrdinal(): int, etc
and even then, I'd be wary of ambiguity over whether Sunday should be 0 or 7
 
or 1
/me runs
 
function nextDay(): WeekDay { return match($this) => .... } would be useful, and can loop without picking a convention
 
In other cases where enum cases have specific order it'd make comparison easier when enum cases express gradation
That was just an example
 
I think the idea is that enums don't have any properties you don't give them
 
WeekDay::Monday < WeekDay::Tuesday; // not possible without translating to comparable type as for eg. int
 
6:52 PM
well, now we're into operator overloading
 
Java enums have ordinal accessor
 
sure, and C# enums can be silently coerced to integers, but that's just horrible
 
$left = WeekDay::Monday;
$right = WeekDay::Tuesday;
$left->ordinal < $right->ordinal; // would be enough
 
so, make the values ints, or add a method
 
yeah, well will have to
 
6:54 PM
I can see it's useful sometimes, but a lot of enums really are just distinct values, so having extra implicit values is a bit weird
e.g. enum Colour { case RED, GREEN, BLUE; }
 
E_SYNTAX_ERROR expected Color, got Colour
 
£culture = 'British';
 
or make a trait with __get which returns ordinal by reflection
 
🤮
 
@IMSoP Should that not be !culture :p
 
6:58 PM
personally I'd say it's as much usefull as ->name sometimes, but usually not, but ->name exists while ->ordinal not
 
> it's as much usefull as ->name sometimes, but usually not
So it is not as useful as :P
 
why would one need name of enum case ?! dunno, in my use cases ordinal looks as more useful than that
 
I still don't see how ordinal is anything other than a different name for value
 
yes, true, but in rare cases it is, like comparison of ordered cases
 
except for a slight short-hand of not typing out the numbers
arguably true of name as well, I agree, and if I was PHP Dictator I might have left it out
I quite like Java's feature of having instance properties on cases, which can be set with a constructor
so you can write something like case Monday ( 0, 'MO', 'MON', 'Monday', 'Montag' ); and associate as many values as you like
 
7:05 PM
enum WeekDay: string {
    private const ORDINALS = [
        1 => self::Monday,
        2 => self::Tuesday,
    ];
    case Monday = 'MO';
    case Tuesday = 'TU';

    public static function fromInt(int $ordinal): self {
        return self::ORDINALS[$ordinal];
    }

    public function ordinal(): int {
        return \array_search($this, self::ORDINALS);
    }
}

var_dump(WeekDay::fromInt(1), WeekDay::Tuesday->ordinal());
It'll work but it's ugly
@IMSoP same here, I'd like to see that in PHP
 
match is probably tidier than array_search
public function ordinal(): int {
        return match($this) {
            self::Monday => 1,
            self::Tuesday => 2,
        };
    }
 
yes, but then I need two matches for backward transform
 
true
 
while with const array map I define the ordinals once
 
so, right now you get one value for free with a backed enum, and write lookups for the rest; with an implicit ordinal, you'd get an extra value for free based on source code order, but still need lookups for the third value onwards
maybe we could have enums with an array as value, then you could have function twoLetterCode(): string { return $this->value[0]; } function ordinal(): int { return $this->value[1]; }
 
7:15 PM
enum WeekDay: string {
    case Monday = 'MO';
    case Tuesday = 'TU';

    public static function fromInt(int $ordinal): self {
        return self::cases()[$ordinal];
    }

    public function ordinal(): int {
        return \array_search($this, self::cases());
    }
}

var_dump(WeekDay::fromInt(1), WeekDay::Tuesday->ordinal());
improved version
fromInt should be renamed to fromOrdinal and alles klar
 
part of the problem I have with ordinal as a concept is that order of statements doesn't usually affect behaviour, so it all feels a bit magic
it's like being able to say Weekday::Monday->lineNumber
 
I don't know enum implementation where order doesn't mean anything
just like structs have order meaning, I always find enum case order meaning
 
it's not possible to assign a nowdoc as an array value, is it? :/ 3v4l.org/SYK9a
 
follow the error message
 
if someone refactored enum Colour { case RED, GREEN, BLUE; } to enum Colour { case BLUE, GREEN, RED; }, and that broke something, I'd be sad
 
7:20 PM
and remove semicolon
 
o rly
interesting
thanks
 
because to me, an enum is just a bag of values that don't compare to anything
 
we have then different understanding of enums :shrug:
I prefer them to be just like in other languages
 
that's surprisingly varied
Python's enums are a world apart from C's
 
@brzuchal I had assumed there was an engine reason why it wouldn't work, that is, nowdoc couldn't be assigned as an array value, and that the semicolon was implicitly required for it to be parsed at engine-level... TIL it doesn't
 
7:23 PM
@brzuchal Literally no two language has the same way of doing enums
Or what they do, so that statement is kinda...
 
fine, I may not know more than just a couple, fair point
there's way more other features I miss here to add even more like ordinal which has limited use
 
I remember having that discussion 5y ago when with a bunch of friend we were conceiving our own programming language. They are generally two broad categories, and within that they are very diverse sooo
 
thanks for talk, night
 
o/ apologies for argumentativeness
 
7:47 PM
@IMSoP I think order can make sense for some enums, although in that case they should probably have a backed value so you can actually check the order.
 
Wes
8:54 PM
this is not a thing yet, right?
$obj?->toArray()?[2]
 
Nope
?? should work though ritgh?
 
Wes
($arr[2] ?? NULL)?->test() i am hopeful this will work
 
array_key_exists
 
Wes
yes it does work
:O
 
magic.png
 
9:00 PM
to_the_hell_with_magic.png
 
Wes
wasn't it magic.gif
 
no
@Tiffany Swoole is fast
 
9:15 PM
I got insane speeds using swoole in the past, the only reason I moved away from it is because I wanted something purely PHP based for future compatibility
 
 
2 hours later…
10:52 PM
Swoole is okay-ish fast. But ultimately all you are comparing here is running web requests with the heavy startup cost of some frameworks eliminated against requests with the startup cost included
tbf, I have some full blown application which easily runs 90% of requests in less than 17 ms, and 50% in less than 5 ms, with nearly all overhead being attributable to sql queries.
a typical request needing 6 ms has about 700 microseconds cpu time - and everything else is waiting on the mysql backend for about 10-15 queries
(that application is just apache with mod_php and opcache)
 
I ran collaboration APIs using it, running everything in a single process meant I could do enormous levels of caching with zero serialization. I was responding to requests in 1 or 2ms.
At some point im likely to ask Trowski to write a PHP extension for accelerating common amp HTTP / websocket functions and see how much more juice we can squeeze out of it by offloading some of the string parsing and manipulation.
 
@MarkR Well, you basically just need to run it with some profiler
and assume the C code will speed things up tenfold for non I/O functions
 
11:07 PM
We tried. At least with xdebug the overhead from it completely flooded out anything useful.
Our C extension for JSON encoding acceleration yielded some pretty wild improvements so i'm curious what it would do for amp
 
@MarkR using a sampling profiler, not xdebug :-D
@MarkR eih… what do you mean? is ext/json slow?
 
Very. We were encoding hundreds of thousands of JSON payloads per second, most of them were identical but wrapped in other objects, at that scale re-encoding the strings (and keys!) each time was painfully slow.
 
@MarkR so, you were doing partial caching of converted objects?
 
So we cloned the json encode API and added another route before JsonSerializable which allowed it to cache the result from the previous call, re-encoding the same object returned the previously cached string and appended it straight onto the smart_str
It was somewhere in the region of a 5 to 7x speed bump
 
yeah I can totally believe that
@MarkR the problem with these begin though when a single process is not enough anymore and you need to update caches across all endpoints…
 
11:16 PM
We used database values, redis triggers and some very optimized queries. 99.99% of users could be served without any IO on their requests
Now we're using amp for the same job, except rather than discrete requests it's all push based and event driven.
 
@bwoebi The cache invalidation rate isn't an issue for most applications, as there are many, many more reads than writes.
@MarkR You know that you can already install libnghttp2 with FFI for an improved hpack implementation in HTTP/2?
 
@kelunik I didn't, although our use case is all websocket based
 
What we really should add to PHP is a string buffer class, appending another chunk to an already huge buffer will cause a really big allocation.
 
I was wondering if there was a PHP version of smart_str in there somewhere.
 
@kelunik yes, absolutely. It just adds complexity to have a layer of cache update distribution. But is probably easily possible.
 
11:31 PM
We have quite a few places in Amp where we avoid such allocations, e.g. buffer chunks to an array and implode at the end, or avoid substr and use offsets for strpos instead during parsing.
 
I found that joining an array of strings was significantly better than appending too, thanks to it precalculating the length and setting the string buffer ahead of time
 
yup
 
Yeah, I went around replacing a bunch of appending stings with arrays + implode for v3.
 
maybe we should look at exposing a wrapper for smart str in 8.2?
 
@kelunik We're mostly interested in websocket parsing, though an extension that did HTTP request parsing would be great.
http-server is mostly set up for that already. Only need to drop in HttpDriver instances that defer to the extension.
@MarkR Potentially. We can start in an extension and see what the benefits are.
 
11:40 PM
have you been running blackfire against v3 by any chance?
 
I haven't lately, no.
 
@kelunik …which under the hood is just doing a vector with strings, which are joined at the end?
 
This is a good point. I wonder how much difference there would be between a user space buffer of arrays + implode vs. a implementation using smart_str.
@bwoebi symbol not found in flat namespace '_compiler_globals' Ever seen that as an error when trying to load a compiled extension from a .so?
 
@Trowski zts vs nts issue?
 
@bwoebi Likely, I'm running ZTS.
Fatal error: Uncaught InvalidArgumentException: RegexIterator::__construct(): Allocation of JIT memory failed, PCRE JIT will be disabled. This is likely caused by security restrictions. Either grant PHP permission to allocate executable memory, or set pcre.jit=0 in /Users/aaron/Developer/php-src/ext/phar/phar.php:1145
That happens when generating phar.phar
 

« first day (4148 days earlier)      last day (815 days later) »