Skip to content

Add ZEND_INIT_ICALL instruction #13445

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

Closed
wants to merge 1 commit into from
Closed

Conversation

iluuu1994
Copy link
Member

@iluuu1994 iluuu1994 commented Feb 20, 2024

This avoids (compared to ZEND_INIT_FCALL):

  • A pointer indirection, i.e. (char*)opline + opline->op2.constant vs (char*)execute_data->run_time_cache + opline->result.num
  • A NULL check

Symfony Demo:

300 runs in seconds:

Before: 3.376795, 3.379392, 3.386662, 3.386701, 3.396124
After 3.344498, 3.358200, 3.361117, 3.361300, 3.365647

Fastest: 3.376795 vs 3.344498 = -0.96%
Mean: 3.3851348 vs 3.3581524 = -0.80%

Seems a bit high. 🤷‍♂️

@iluuu1994 iluuu1994 force-pushed the init-icall branch 2 times, most recently from 65fe4ff to 1789c86 Compare February 22, 2024 10:43
Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

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

Nice! This also avoids a hash lookup when the run time cache is not primed yet for a call site.

Could this be generalized to top level functions declared in the same file as the caller? Maybe to preloaded functions as well (not sure about that one).

@iluuu1994
Copy link
Member Author

iluuu1994 commented Feb 22, 2024

This also avoids a hash lookup when the run time cache is not primed yet for a call site.

Right, that too! That's likely the bigger factor that I didn't consider.

Could this be generalized to top level functions declared in the same file as the caller? Maybe to preloaded functions as well (not sure about that one).

Hmm, probably. The pointer will need to be fixed once the function is moved to shm. This might need a second pass, since functions can reference each other. I can have a look when this is merged. In that case though, it might make sense to rename this opcode.

Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

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

I see very slight speed improvement and I think it doesn't cost the current complexity of the patch.

Most probably this complexity may be significantly reduced.
For exampee instead of introduction of a new INIT_ICALL instruction, we may use a specialized handler for existing INIT_FCALL that relays on type of the constant operand (PTR instead of STRING).

May be we should even keep both STRING and additional PTR to reduce the fragmentation with Windows and simplify file cache support (it's missed now).

@iluuu1994
Copy link
Member Author

Closed in favor of #13634.

@iluuu1994 iluuu1994 closed this Mar 8, 2024
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