Skip to content

Shim standard property handlers, in an attempt to move ThreadSafe behaviour closer to regular objects #149

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 10 commits into
base: php/8.4
Choose a base branch
from

Conversation

dktapps
Copy link
Member

@dktapps dktapps commented Apr 14, 2025

This wasn't entirely successful and it does mean that ThreadSafe objects pay a performance penalty for reading & writing properties. I haven't attempted to optimise this yet. However this change means that we get PHP 8.4 property hooks without having to copy-paste a bunch of core logic from php-src.

This works by pushing values from shared storage to local cache on read,
and then letting std handlers operate on the local property table.
Vice versa for write.

This allows us to get support for stuff like 8.4 property hooks without
copy pasting lots of code and having inconsistencies.

this isn't fully stable yet, but should be working.
the std handlers will already generate these warnings anyway, so we're
just duplicating them.
@dktapps
Copy link
Member Author

dktapps commented May 3, 2025

Main performance considerations:

  • Double property info hashtable access - we could probably use fake caches for the std property handlers to avoid this, but it'll make the code more fragile
  • Not able to cache property info because Zend would skip our custom handler
  • Defined properties can't be optimized to array accesses within thread-safe objects because we can't guarantee that the class used for the object will be the same on all threads (because of autoloading). However, this should be a very rare edge case, so it's possible we might be able to optimise this if we verify the destination thread's class properties match and bail if they don't (or possibly have some kind of translation layer, but this seems like a lot of hassle for a rare edge case).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant