-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Revert "more fiber notifications" #7442
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
Conversation
hm ... if a fiber is destroyed as the last reference to it is removed, won't it not do a fiber switch and thus not invoke the observer at all? |
@bwoebi The fiber is switched into during destruction, so the watcher will still be triggered. @morrisonlevi What is suggested here is how I originally described the observer API to you in R11. There is of course a timing difference: creation notifications are not available until the first switch, and destroy notifications come on the last switch rather than when memory is alloc/dealloc. Will that work for you? If so, we can drop these extra observers. |
Not sure what the motivation for changing this is. |
@krakjoe If we can achieve our goals in a simpler way, why do we need more? |
https://github.com/xdebug/xdebug/blob/master/src/base/base.c#L1098 |
#7292 and #7293 came about as a result of conversations with consumers of the observer API, and in the interest of completeness and flexibility. If you look at #7293 you will notice that several consumers of the API approved these changes. That you don't understand why they are here, when there is other ways to achieve the same thing is not a good reason to revert commits approved by several other contributors. You also said:
There doesn't seem to be a problem. |
It seems that other contributors agreed without knowing the other way :)
Yeah, I just want to make you happy. |
If possible, I would like to ask you to explain how more APIs bring completeness and flexibility, I can't find the answer in the content you quoted. What @trowski said also shows that these things may be redundant. |
Not every observer will be interested in having their callback executed for every switch. It so happens that the use cases we have in front of us today are interested in every switch. Having a "one callback to rule them all" approach in an API that is supposed to have minimal impact on performance doesn't make sense. We are designing an API, not catering to specific use cases although specific use cases can guide us. |
Thank you for your reply, but I am still confused. If a use case does not care about the switch, only care about creation and destruction, what is the point of it doing this? The core of fibers is switching, If we drop the switch, it is nothing more than allocating memory and freeing memory, observers didn't even know whether the fiber has ever run. Almost all observers will affect the performance of the application, and they usually work during debugging and are closed in the production environment, If we skip events we don’t care about by checking the status, it will hardly have an unacceptable performance impact. But the other way around, when we don’t use debug tools (when no one cares about these events), fibers need to trigger more notifications. Why don't you think more about this situation? At the very least, if your consideration is correct, so should you consider splitting resume and suspend into two notifications? So, I can't agree with you here. |
There are two things going on here, the design of fibers and the design of the observer API. Of course, central to fibers is switching, but central to observers is the ability to observe discreet points in execution with a minimal overhead. Your assertion that observers are only or mostly used at debug time is wrong: Observers must be suitable for observing production environments, that is how they are deployed today in APM applications.
Everything is a compromise, the original changes seemed to add a little bit of the kind of flexibility we desire in the observer API without complicating fibers too much. |
I don't think you answered my questions about this part...
And I can not see minimal overhead, I just see more overhead, 1 callback -> 3 callbacks.
I know that, I've said something about it (and I use @morrisonlevi @SammyK @trowski @bwoebi |
For the most immediate need I have for observing fibers, I don't care about switch events at all. For this use-case, having to inspect all "switch" events to check a status of init/destroy would add more overhead than subscribing only to init and destroy. If you want to handle everything inside of switch event, then your observer can do that. It seems that fiber observers only pay for what they are interested in, which is one of the core principles. Does that make sense, @twose ? Unless I've missed something, the design seems to be working as intended. |
@morrisonlevi Thanks for your reply! I suddenly understood why we can't understand each other... And the key is the name of In our implementation, So the event name should not be However, we need something like |
Let me talk something about the other part... These two observers do make sense to you, but I also have reasons not to like them so much. Fiber observers are not like the PHP fiber has a heavier context switch than C fiber, it is many times slower than pure C fiber switching. And the fiber switch is always accompanied by IO operations or syscalls, syscall is so expensive that it makes all other optimizations seem trivial. And I am not willing to say that fiber can also be used in mathematical calculations such as Fibonacci, which is a very common example. For mathematical programs, fiber's switching performance is so poor that it performs much worse than conventional programming modes, it's like a toy in this context. So I think you probably don't have to worry too much about the extra cost of switch event callbacks, but anyway, you deserve more, thank you again for your reply :) |
Sorry i just saw this change now, and I have not seen the context of the discussion about it for the time being.
I don’t think we need more notify API, the status should be checked instead.
Correct me if I am wrong.
This revert 848b545 (#7293)