Skip to content

Arginfo: add and use known strings for attributes - #19075

Merged
DanielEScherzer merged 3 commits into
php:masterfrom
DanielEScherzer:known-attribs
Jul 15, 2025
Merged

Arginfo: add and use known strings for attributes#19075
DanielEScherzer merged 3 commits into
php:masterfrom
DanielEScherzer:known-attribs

Conversation

@DanielEScherzer

Copy link
Copy Markdown
Member

No description provided.

@DanielEScherzer

Copy link
Copy Markdown
MemberAuthor

This is the first part of my follow-up to #18780 dealing with reducing the work of registering attributes on constants (and other things) - here, if a string is known the known string is used for attribute name and values, and 8.0, 8.1, 8.2, 8.3, 8.4, and 8.5 are all added as known strings.


the same strings are allocated twice

It should probably be safe to just intern them all. They are always allocated on start-up, so the memory will be used either way. Interning should just reduce it, no?

Yes I agree.
If you pinky promise that you're gonna look at it before 8.5's release I'll allow it.

Originally posted by @nielsdos in #18780 (comment)

Comment threadbuild/gen_stub.php
return $result;
}
$include = self::PHP_80_KNOWN;
switch ($minPhp) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no match?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because gen_stub supports running on PHP 7.4, I have a todo to update that eventually

@TimWolla
TimWolla removed their request for review July 9, 2025 06:28
@ndossche

Copy link
Copy Markdown
Member

Looks like this makes a degradation on Symfony's Valgrind instruction count. It'd be interesting to know why.

@DanielEScherzer

DanielEScherzer commented Jul 9, 2025

Copy link
Copy Markdown
MemberAuthor

Looks like this makes a degradation on Symfony's Valgrind instruction count. It'd be interesting to know why.

Hmm, curious

For 64e2832 which is the last commit before this PR, https://github.com/php/php-src/actions/runs/16128700585/job/45511592322 reports

Details
{
"branch": "master",
"Zend\/bench.php": {
"instructions": "2232991601"
},
"Zend\/bench.php JIT": {
"instructions": "600974941"
},
"Symfony Demo 2.2.3": {
"instructions": "39045323"
},
"Symfony Demo 2.2.3 JIT": {
"instructions": "33525633"
},
"Wordpress 6.2": {
"instructions": "122389752"
},
"Wordpress 6.2 JIT": {
"instructions": "93235272"
}
}

But for this PR at 99ec395, https://github.com/php/php-src/actions/runs/16155780300/job/45597800753 reports

Details
{
"branch": "19075\/merge",
"Zend\/bench.php": {
"instructions": "2232998193"
},
"Zend\/bench.php JIT": {
"instructions": "600982807"
},
"Symfony Demo 2.2.3": {
"instructions": "39068192"
},
"Symfony Demo 2.2.3 JIT": {
"instructions": "33683655"
},
"Wordpress 6.2": {
"instructions": "122444747"
},
"Wordpress 6.2 JIT": {
"instructions": "93289268"
}
}

So basically (differences in bold)

BenchmarkOld (master)New (this PR)
Zend/bench.php22329916012232998193
Zend/bench.php JIT600974941600982807
Symfony Demo 2.2.33904532339068192
Symfony Demo 2.2.3 JIT3352563333683655
Wordpress 6.2122389752122444747
Wordpress 6.2 JIT9323527293289268

So this isn't just for symfony, this patch appears to consistently increase the instruction count?

I suspect the reason is that the addition of the new known permanent strings means that any searches for a permanent string now have a couple extra strings to check against - do we care? The memory usage should be lower even if the instruction count is higher

@ndossche

Copy link
Copy Markdown
Member

This could just be startup overhead that is being influenced.
Note btw that the "Symfony Demo 2.2.3 JIT" often fluctuates heavily so that one in particular can likely be ignored.

@DanielEScherzer

Copy link
Copy Markdown
MemberAuthor

Okay - do you consider the instruction count change a blocker?

@ndossche

Copy link
Copy Markdown
Member

Not really, but it would still be good to confirm with php-cgi's -T argument to see if this is actually startup overhead.

@DanielEScherzer

Copy link
Copy Markdown
MemberAuthor

Not really, but it would still be good to confirm with php-cgi's -T argument to see if this is actually startup overhead.

I couldn't figure out how to do this, would you be willing to check?

@ndossche

Copy link
Copy Markdown
Member

I'll check tomorrow

@ndossche

Copy link
Copy Markdown
Member

Conceptually this is okay.
I measured locally on Symfony and obtained (for -T10,50):
Before: 29,953,445,510
After: 29,956,118,247

This difference is 1.00008923x, or 100.008922996%, which is lower than CI reports and I think that this is just noise.
We can check the realtime benchmark after this is merged to see the impact on memory usage and on real time performance

@DanielEScherzer
DanielEScherzer merged commit 142e378 into php:masterJul 15, 2025
8 checks passed
@DanielEScherzer
DanielEScherzer deleted the known-attribs branch July 15, 2025 00:31
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@DanielEScherzer@ndossche@kocsismate@kamil-tekiela