zendframework / zend-servicemanager

ServiceManager component from Zend Framework
BSD 3-Clause "New" or "Revised" License
188 stars 89 forks source link

A word about the immutability-for-performance paradigm #255

Closed fhein closed 6 years ago

fhein commented 6 years ago

Immutability may be a last ressort in order to increase performance. But I am not sure if this property can significantly contribute to performance at all.

Current master, let's assume it was mutable (i.e providing public API's deleteService, deleteFactory et al), this mutability would cause almost no negative performance impact and would cost nothing at all (more or less). That's a statement, I'd be happy to proof that, if there were any demands for a mutable servicemanager.

Current ServiceManager implementation is slow enough, that immutability is not a topic to discuss at all if performance is the issue. Performance gains (by several 100%) can easily get achieved omitting that discussion.

From my user's point of view I'd say: I did never care about ServiceManager being mutable or not. It was set up from some accumulated configs. I always used that only, and never wanted to change it. So immutablity never became an issue,

If there are use cases, where people want to change service manager configurations at runtime, I'd say, this capability could be provided at almost no cost. But I'd recommend to rather review the application design. There might be some flaws. There are flaws, definitely.

Immutability does not improve performance at all. And it does not open areas of 'research' regarding performance. Mutability almost comes for free. Mutability is a requirement which can be satisfied almost trivially.

Ocramius commented 6 years ago

Disagree here: if the map of service definitions is known upfront (and doesn't change), then we can introduce a lot of interesting optimisations.

For example:

Right now, we can't do that because of the extremely messy setup:

Move all bootstrapping to separate named constructors and most of these problems just go away, plus proper service definition design is enforced (post-initialisation overrides are 99.999% a design issue, see https://igor.io/2013/03/31/stateless-services.html )

From my PoV, all public API that leads to internal configurationchanges should be deprecated and dropped.

A much simpler migration path is to work towards immutability, then make these secondary configuration approaches expensive and only optimise the named ctors.

On 8 Feb 2018 07:02, "Frank Hein" notifications@github.com wrote:

Immutability may be a last ressort in order to increase performance. But I am not sure if this property can significantly contribute to performance at all.

Current master, let's assume it was mutable (i.e providing public API's deleteService, deleteFactory et al), this mutability would cause almost no negative performance impact and would cost nothing at all (more or less). That's a statement, I'd be happy to proof that, if there were any demands for a mutable servicemanager.

Current ServiceManager implementation is slow enough, that immutability is not a topic to discuss at all if performance is the issue. Performance gains (by several 100%) can easily get achieved omitting that discussion.

From my user's point of view I'd say: I did never care about ServiceManager being mutable or not. It was set up from some accumulated configs. I always used that only, and never wanted to change it. So immutablity never became an issue,

If there are use cases, where people want to change service manager configurations at runtime, I'd say, this capability could be provided at almost no cost. But I'd recommend to rather review the application design. There might be some flaws.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/zendframework/zend-servicemanager/issues/255, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJakPC15vm72IVoK8tvt2xQz7jrvccoks5tSo3jgaJpZM4R92BC .

Ocramius commented 6 years ago

Good and efficient design examples here are symfony/dependency-injection and php-di/php-di, which will always outperform zendframework/zend-servicemanager if we cannot introduce a clean cut between a bootstrap and a runtime container phase.

On 8 Feb 2018 07:09, "Marco Pivetta" ocramius@gmail.com wrote:

Disagree here: if the map of service definitions is known upfront (and doesn't change), then we can introduce a lot of interesting optimisations.

For example:

  • Compiled containers
  • Hashing config to determine heavy operations only once per deployment
  • Eager service definition validation (cached)

Right now, we can't do that because of the extremely messy setup:

  • set* methods in the public api
  • inheritance-bassd config

Move all bootstrapping to separate named constructors and most of these problems just go away, plus proper service definition design is enforced (post-initialisation overrides are 99.999% a design issue, see https://igor.io/2013/03/31/stateless-services.html )

From my PoV, all public API that leads to internal configurationchanges should be deprecated and dropped.

A much simpler migration path is to work towards immutability, then make these secondary configuration approaches expensive and only optimise the named ctors.

On 8 Feb 2018 07:02, "Frank Hein" notifications@github.com wrote:

Immutability may be a last ressort in order to increase performance. But I am not sure if this property can significantly contribute to performance at all.

Current master, let's assume it was mutable (i.e providing public API's deleteService, deleteFactory et al), this mutability would cause almost no negative performance impact and would cost nothing at all (more or less). That's a statement, I'd be happy to proof that, if there were any demands for a mutable servicemanager.

Current ServiceManager implementation is slow enough, that immutability is not a topic to discuss at all if performance is the issue. Performance gains (by several 100%) can easily get achieved omitting that discussion.

From my user's point of view I'd say: I did never care about ServiceManager being mutable or not. It was set up from some accumulated configs. I always used that only, and never wanted to change it. So immutablity never became an issue,

If there are use cases, where people want to change service manager configurations at runtime, I'd say, this capability could be provided at almost no cost. But I'd recommend to rather review the application design. There might be some flaws.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/zendframework/zend-servicemanager/issues/255, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJakPC15vm72IVoK8tvt2xQz7jrvccoks5tSo3jgaJpZM4R92BC .

fhein commented 6 years ago

Ok. I understand, that this is your opinion. But you do not provide any evidence (as usual, if I am allowed to say that).

I'd appreciate, if you would pay more attention to my Lazy Services question than to this one. I do not like that this pokey scope is more about politics than about anything else.

Ocramius commented 6 years ago

Evidence is mostly provided by @mnapoli, who spent most of his time on PHP-DI 6 trying to outperform all other DICs after measurement.

As for the other issue, it is simply in my backlog.

On 8 Feb 2018 07:17, "Frank Hein" notifications@github.com wrote:

Ok. I understand, that this is your opinion. But you do not provide any evidence (as usual, if I am allowed to say that).

I'd appreciate, if you would pay more attention to my Lazy Services question than to this one. I do not like that this pokey scope is more about politics than anything else.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/zendframework/zend-servicemanager/issues/255#issuecomment-364013779, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJakLoBTbOUkySHMUCAZzceKSuLu7fwks5tSpFjgaJpZM4R92BC .

fhein commented 6 years ago

Sure, direct me to wonderland. One or two sentences to explain, what I am missing, were to much engagement.

fhein commented 6 years ago

I read most of the stuff regarding refactoring of SM, Man, I was not quite amused, I think, you are the one to ask, if I want to get answers to build upon. So please ...

bcremer commented 6 years ago

It's not that hard to find. Please see http://php-di.org/news/21-php-di-6-compiled-container.html as a starting point.

fhein commented 6 years ago

@bcremer; So, what in particular, does that contribute? I assume, this is not a quizz.

Ocramius commented 6 years ago

Thanks @bcremer, that was the link I was looking for 👌

Ocramius commented 6 years ago

Well, it makes PHP-DI quite a lot faster than zend-servicemanager while having almost the same features, for once.

/cc @nicolas-grekas do you by chance have any recent symfony DIC fivures? You did a lot of extremely detailed optimisation work there...

fhein commented 6 years ago

Ok. I read @bcremers link word by word. And I read your last response.

Resume: You seem to don't actually care about Zend\ServiceManager\ServiceManager performance.

Are you the right maintainer of this library 'Zend\ServiceManager'? Really? Do you support progress here as good as you can?

And if you are talking about performance of PHP-DI: Is it as fast as it could be? If there are the same policies in place I assume here (not invented here -> difficult, all progress incorporated is in debt programmed by me), I think not, Maybe they could need some troublemakers also.

What do your statistics say to ServiceManager performing at < 100 microseconde for bulk installation, fully mutable, ...? That's what I am aiming for and that's what I will achieve, once you decide to stop blocking progress?

Ocramius commented 6 years ago

Uhm, no, I just suggested to look at other implementations to support my thesis that a clean runtime and bootstrap separation cut would make things faster and easier to manage/improve.

On 8 Feb 2018 07:42, "Frank Hein" notifications@github.com wrote:

Ok. I read @bcremers link word by word. And I read your last response.

Resume: You seem to don't actually care about Zend\ServiceManager\ServiceManager performance.

Are you the right maintainer of this library 'Zend\ServiceManager'? Really? Do you support progress here as good as you can?

And if you are talking about performance of PHP-DI: Is it as fast as it could be? If there are the same policies in place I assume here (not invented here -> difficult, all progress incorporated is in debt programmed by me), Maybe they could need some troublemakers also.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/zendframework/zend-servicemanager/issues/255#issuecomment-364017552, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJakPGI9Rmx83m5U_03uiyDyY1R14PHks5tSpdZgaJpZM4R92BC .

geerteltink commented 6 years ago

Resume: You seem to don't actually care about Zend\ServiceManager\ServiceManager performance.

Seriously?

Reading that link with PHP-DI 6 improvements and the tests, it seems that the servicemanager is still one of the best performing containers. And improvements can be made at bootstrap time. Using a caching mechanism and compiling closures sounds very interesting.

fhein commented 6 years ago

I completely agree, Who will deliver? I could. @Ocramius: You complain that you have bills to pay. Who has not? You have, I have. Go!

Would delivery be possible without having any political ambitions in this business? What in particular justifies LazyServicesFactoryFactory's insourcing? I actually do not like such 'thingies' hanging around for no value.

fhein commented 6 years ago

Guys, there is not much room to discuss thesises in the dark. I will have a look at PHP-DI or how it's called, but Zend\ServiceManager with all it's BimBam around is just a few lines of code. To less to talk theoretical.

There is nothing you could not just tryout and find out how optimize in a minute. This is at all more or less easy going.

fhein commented 6 years ago

Silence again? So easy, isn't it?

fhein commented 6 years ago

At the end I am happy that people talk to me at all. :+1:

geerteltink commented 6 years ago

Silence again? So easy, isn't it?

Seriously dude, if you want a fast-paced conversation, I suggest to go outside to a public place and start a discussion about the weather.

Ocramius commented 6 years ago

I completely agree, Who will deliver? I could. @Ocramius: You complain that you have bills to pay. Who has not? You have, I have. Go!

In OSS "it will be done when someone has time to do it". That's really all there is to it, unless there's a sponsor.

Would delivery be possible without having any political ambitions in this business? What in particular justifies LazyServicesFactoryFactory's insourcing? I actually do not like such 'thingies' hanging around for no value.

Me neither, but I also didn't get to follow the current WIP in this repo (you opened/closed/re-did a lot of patches, multiple times - I'm mostly waiting for them to settle down before considering them)

Guys, there is not much room to discuss thesises in the dark. I will have a look at PHP-DI or how it's called, but Zend\ServiceManager with all it's BimBam around is just a few lines of code. To less to talk theoretical.

No theory, just practice:

Please do also change the tone of discussion - you really make it hard to give a remote shit about what you do, and I'm really trying hard to keep it cool, because the work is actually valuable.

Ocramius commented 6 years ago

Locked because the comments were starting to become quite ridiculous (deleted some, for everyone's sake).