Go and TSRM: a marriage in memory management #1090
Replies: 5 comments 9 replies
-
Doing something like this has been on my to-do list since the creation of FrankenPHP, and using function pointers is also what I had in mind. It would be great if we could make progress on this! To get rid of C threads completely, we'll also have to get rid of the signals used by the PHP engine, which are not compatible with the Go execution engine. They are mainly used for timeout management. We'll probably have to create hooks to delegate timeout management to Go's time functions, which don't use signals. Perhaps we should discuss this first on PHP internals, as we'll need to expose a new ABI to enable these extension points. |
Beta Was this translation helpful? Give feedback.
-
What would this look like? Would the thread coming from Caddy's |
Beta Was this translation helpful? Give feedback.
-
Would there be any way to test this without completely recompiling PHP? |
Beta Was this translation helpful? Give feedback.
-
I've started digging into TSRM and it's implementation. Went ahead and implemented the r/w locks: php/php-src#16565 Dunno when that will be merged, though. Soon I will have a list of possibilities (probably early next month). |
Beta Was this translation helpful? Give feedback.
-
I'm currently working on an experimental branch that allows dynamically starting and stopping workers since I think we will need the additional control over PHP from the go side. |
Beta Was this translation helpful? Give feedback.
-
I think after digging into the shenanigans in #1080 and in #1086, it is clear that there are probably some other issues involving memory management between Go and PHP. Ideally, we can somehow "hook into" or even replace TSRM with one that can work collaboratively with Go.
This might even allow us to get rid of C threads altogether, and manage everything in Go.
The main issue is how to implement said "hooks." We could use function pointers in TSRM that can be replaced before booting PHP or when registering the sapi module. That is probably the simplest solution, to be honest.
What are your thoughts?
Beta Was this translation helpful? Give feedback.
All reactions