Skip to content
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

Implement custom FiberFactory interface #72

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

danog
Copy link
Contributor

@danog danog commented Jan 28, 2023

Create a FiberFactory interface and DefaultFiberFactory/TracingFiberFactory implementations, to allow to easily track the state of all running fibers, simplifying debugging/searching for fiber leaks.

I've also removed the logic that uselessly created a dummy fiber inside of FiberLocal, replacing it with a simple anonymous class instead (since the $localStorage WeakMap property won't be visible or usable from the outside anyway).

@kelunik
Copy link
Member

kelunik commented Jan 28, 2023

IMO this should be solved by using the observer API via an extension or FFI instead.

@danog
Copy link
Contributor Author

danog commented Jan 29, 2023

Hmm, I don't think that bringing in requirements and extensions for what can be easily done via a very simple userland API is appropriate.

This functionality is very useful to debug issues like deadlocks or a low mmap limit in field conditions (ie webhosts), where one might not have access to FFI or observer extensions.

@kelunik
Copy link
Member

kelunik commented Jan 30, 2023

@danog That's kind of the point: It can't be easily done in userland, because you can't control all the places where fibers are created.

@danog
Copy link
Contributor Author

danog commented Jan 30, 2023

But realistically, an application will only ever create fibers in the context of the (only) event loop.
I can't think of any practical reason to use fibers manually outside of the abstractions used by revolt, and even if I were to use them manually, I'd just tack on userland tracking similar to this one.

Arguing that this shouldn't be done in userland is like arguing that the TracingDriver shouldn't exist: sure it may not be the solution to all your issues, but it's a very useful help when debugging both in dev mode and in production.

@kelunik
Copy link
Member

kelunik commented Feb 23, 2023

@danog Do you plan to make the changes we discussed in chat?

@danog
Copy link
Contributor Author

danog commented Jul 24, 2023

I guess I can make them anyway, and then wait until PHP fixes reflectionfibers before using them.
@kelunik forgot what was your proposal, mind reminding me of it? :)

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

Successfully merging this pull request may close these issues.

2 participants