« first day (3588 days earlier)      last day (1350 days later) » 
00:00 - 21:0021:00 - 00:00

9:00 PM
@mega6382 I didn't know. Thanks. Flattering.
 
Wonder what would happen if it was converted to matrix instead of x, y, z properties
 
Not sure if this wouldn't violate
> but also use the same algorithm to calculate that result.
https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/nbody.html#nbody
 
Minimal it seems
 
9:15 PM
class BaseClass {
    public static function speak() {
        echo "I have spoken.\n";
    }
}

final class ChildClass extends BaseClass {
    public static function speak() {
        parent::speak();
    }
}

ChildClass::speak();
When parent::speak() is called, the fbc has what I want, but consider this one:
class BaseClass {
    public static function speak() {
        echo "I have spoken.\n";
    }
}

final class ChildClass extends BaseClass {}

ChildClass::speak();
Here the fbc will have a scope of BaseClass.
I want the class entry of the thing on the LHS of ::, every time, all cases. Why is that so hard?
Maybe it's not and I'm just too pigeon-holed.
 
@Girgias According to Nikita's talk (youtu.be/JBWgvUrb-q8?t=1593), type declarations sometimes result in better performance (ofc under OPCache).
 
@MateKocsis Yeah I know that talk
Issue is the running under OpCache
 
@LeviMorrison I mean, you essentially want static:: as it would be used in userspace. There must be an API for that.
 
Because these Benchmark only use a minimal build any optimization which technically doesn't even do any caching can't be used
 
That'd be in EG(current_execute_data), I thnk
 
9:25 PM
Also I imagine OpCache would only kick in on the second run
 
Yeah, I saw that the benchmarks are not run on OPCache. It's pretty lame, a proper benchmark should use production settings. :/
 
((VM isn't running at the moment, will take a sec to check))
 
yes, but hopefully they already run the tests multiple times for accuracy :)
 
@MateKocsis I would say both modes have value. Depends on the question you want the stats to answer.
 
@Sara I'm working with PHP 5.4 through PHP 7.4 here, but I can't seem to figure it out on any version lol
PHP 5.4 has EG(scope) and EG(called_scope) which seem to exist to solve this problem, but I can't figure out when to use which one.
 
9:30 PM
EG(called_scope) I should think, but evidently my VM exploded when my computer got hit with a brown out, so.... bigger fish atm
 
@Sara Yes, that's sure, it depends on the question. :) But I think the most interesting question is production performance. Or are there other interesting questions?
 
@Sara EG(called_scope) seems to be right in all cases except the parent:: one.
 
-0.169075164
-0.169059907
php -d opcache.enable_cli=1 ./n-body.php 50000000  244.97s user 0.49s system 99% cpu 4:06.04 total
 
I didn't see a noticeable difference with opcache
 
@IluTov is that one typed?
 
9:37 PM
@Girgias Yes
 
Huh, seemed to have no benefit what so ever
 
@Sara Oh, and if we're talking about benchmarks.... I've already wanted to ask you and others if I could ask AWS (or other cloud providers) on behalf of the PHP project to support setting up an official benchmark for PHP, like what we had a few years before. Is it worth the try?
 
@Girgias Trying JIT now, after that I give up ^^
 
@IluTov Don't you have to store the opcodes in files? I believe OPCache stores them in memory by default (even when cli is enabled), so currently you're back to square 1:)
 
@IluTov Haha so much effort x) I find that surprising cause my PHP code for my Dynamical System plot generator was getting massive gains from OpCache
 
9:41 PM
@MateKocsis True, I think the point was more to run the optimizer (which should still happen)
 
@LeviMorrison Define "right". Is it wrong in that it gives you ChildClass and what you really want is the ultimate calling scope? Or vice-versa?
 
Huh that's interesting, using constants as indexes rather than plain-ol numbers yields around a 10% penalty.
 
@Sara I want the scope that the LHS resolves to in every case.
parent::speak() should resolve to whatever parent is (which is BaseClass).
 
@MarkR On a somewhat related note: github.com/symfony/symfony/pull/25474 :D Since then, Dmitry improved the situation by adding a cache for constant default values :)
 
ChildClass::speak() should resolve to ChildClass; BaseClass::speak() should resolve to BaseClass.
 
9:46 PM
gist.github.com/marandall/abb22a65edc003fc1d1530709d1ac999 might have broken it using find / replace
 
But it doesn't resolve to the same thing in every case: 3v4l.org/hG26I
 
@Sara My current thought is that EG(called_scope) is always right on the inside of the call, but not from zend_execute/zend_execute_ex.
 
Do I need to do anything else other than configure without the debug flag to build php-src for production? master is approximately 3x slower than php7.4.
 
Again, no idea what you mean by "right".
 
> I want the scope that the LHS resolves to in every case.
> parent::speak() should resolve to whatever parent is (which is BaseClass).
> ChildClass::speak() should resolve to ChildClass
> BaseClass::speak() should resolve to BaseClass
(using my examples above)
For the parent:: case it seems I want EG(scope).
I don't know how to know from the engine's perspective that I should choose EG(scope) instead of EG(called_scope), though.
 
9:55 PM
No. parent::speak() should resolve to ChildClass.
ChildClass is the one doing the calling.
 
I'm not sure what you mean; it's not like the class that calls it has any bearing.
 
But I'm not going to understand you better if you keep repeating the same thing, so... good luck.
 
class Orthogonal {
    // calling from Orthogonal doesn't affect either EG(scope) nor EG(called_scope)
    function run() {
        ChildClass::speak();
    }
}
@Sara I'm not sure how else to state it. In the case of parent::speak() the LHS of that :: is not ChildClass; it's parent which is BaseClass.
 
10:09 PM
I think I have no idea from the call point of knowing whether the fbc was reached through static:: or parent:: or something else, which is what's troublesome for me.
I don't think I can know whether I want EG(scope) or EG(called_scope) from the point of the call.
I'd have to look at how they were INIT'd.
 
Finally connected what you mean.
So it's that parent:: basically doesn't update called_scope at all
I'm not sure it's that's a bug, or considered a feature.
I think I'd called it a bug, tbqh.
 
I think it's because from the engine's perspective it only needs to change which function entry it uses.
 
I mean, it still needs a new execute_data stack, because it's a new symbol table
So userspace is probably fucked, but from your perspective, you should be able to walk down the execute data stack and check for scope
Or... wait, no. That won't work.
Judging by 3v4l.org/KUKGD the data is IN there somewhere.
 
Using $LHS::$RHS you can resolve to a scope + function entry, but from a scope + function entry you can't resolve it back to the same $LHS::$RHS?
 
@Sara feature...
 
10:19 PM
I'll look at debug_print_backtrace but I'm guessing on PHP 5.4 I'm hosed because I don't have the execute_data of the call yet, just op_array.
 
EG(current_execute_data) is your friend
 
(I can't be bothered to read the context, maybe that's about something else)
 
@NikiC Nah, that's the topic, and what I kind of expected.
 
@Sara That isn't set until you forward to the execute from zend_execute (see lxr: heap.space/xref/PHP-5.4/Zend/zend_vm_execute.h?r=e030efa4#373)
Anyway, I don't care that much about PHP 5.4. The key finding is that it's not trivial to know; you can't just poke the current state; you'd have to know where you came from.
(I think, will look again with fresh eyes)
 
10:29 PM
What's the goal of what you're trying to do?
And if you haven't executed the function yet, then... where is your code executing?
 
@Sara For PHP 5 it's in a zend_execute/zend_execute_ex override.
So it's like... as the call is partway being made.
 
Like, intercepting ZEND_FCALL ?
 
A bit later than that; we used to do that but it was too error prone on PHP 5. Still do that on PHP 7.
 
Sorry, no, zend_execute() is the other API.
yeah yeah
Right, so we don't have a call frame yet.
 
Well... maybe. PHP 5.5-5.6 do have an execute_data but IIRC it gets remade or something if you push more args than it's expecting. PHP 5.4 doesn't have the call frame yet, correct.
I'm checking if debug_print_backtrace grabs everything I want in every case. So far so good, which means it might technically be possible (though maybe hacky, we'll see).
(as in partial re-implementation of bits of the engine or something)
 
10:35 PM
Yeah. To get the actual scope of the call, you need to look at EX(opline), trace it back to the INIT_FCALL (or related opcode), and parse it out of that.
100% non-trivial and warranty voiding
 
Ah, nope: 3v4l.org/WbHP8
So yeah, we'd have to do trace it back to init opcodes, which I've actually looked at doing before and that's a big NOPE from me.
 
I would "nope" that too.
 
If there is any spare room on the opcode (highly doubtful) it'd be lovely to link them at compile time... lol
So I have to choose: do I use the fbc's value, or the called_scope?
 
Depends on what your ultimate goal is.
 
I have competing requirements if I can't get the scope of the LHS exactly correct :/
There are use cases for both.
Maybe I can figure out a way to know per function of interest if I should trace/hook inheritors, or just the base function. Not sure I can do that because I might need to know that prior to knowing if it's one of interest or not.
 
10:53 PM
I suspect not, because that.
 
I'm terribly indecisive, should I get ice cream? (from one of the places where employees actually wear masks and gloves...)
 
11:10 PM
yes
hopefully my certitude on the matter will help you come to your own conclusion :)
 
Welp I don't know if my reply to some random person on my PR for php-src was too aggresive or not but whatever coming up with dumb solutions and saying something provably false shouldn't need my sympathy
 
11:26 PM
What's the best practice for preventing brute force attacks in a login form. Different companies implement different solutions. Some use captchas some lock you out of the account.
 
IP lockout after <x> failed attempts and mutli factor auth
 
^
Could also just put a timer on attempting to logging as that user for say 5min
 
yup 5 minutes should be plenty to prevent brute force. Going from testing tens of thousands per minute to testing 1 per minute.
 
So after they reach an X amount of login attempts. lock them out for 5 minutes?
 
That's what I do on my commercial work yeah
 
11:30 PM
That's even easier then what I had in mind. I had captchas in mind.
 
I mean, you could... but a lockout and more importantly two factor auth is the better option
 
11:48 PM
What's the best way to get someone's IP. This answer was marked as the best answer. stackoverflow.com/questions/1634782/…
 
Will depend on what you've got in front of it
There's no universal answer
 
00:00 - 21:0021:00 - 00:00

« first day (3588 days earlier)      last day (1350 days later) »