Skip to content

Arginfo: add and use known strings for attributes #19075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

DanielEScherzer
Copy link
Member

No description provided.

@DanielEScherzer
Copy link
Member Author

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)

return $result;
}
$include = self::PHP_80_KNOWN;
switch ($minPhp) {
Copy link
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
Member Author

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
@nielsdos
Copy link
Member

nielsdos commented Jul 9, 2025

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

@DanielEScherzer
Copy link
Member Author

DanielEScherzer commented Jul 9, 2025

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

{
    "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

{
    "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)

Benchmark Old (master) New (this PR)
Zend/bench.php 2232991601 2232998193
Zend/bench.php JIT 600974941 600982807
Symfony Demo 2.2.3 39045323 39068192
Symfony Demo 2.2.3 JIT 33525633 33683655
Wordpress 6.2 122389752 122444747
Wordpress 6.2 JIT 93235272 93289268

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

@nielsdos
Copy link
Member

nielsdos commented Jul 9, 2025

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
Member Author

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

@nielsdos
Copy link
Member

nielsdos commented Jul 9, 2025

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

Sign up for free to 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.

3 participants