Feature: Optimize DBConfigurableConsumer with a slow mode after a cer…#28
Conversation
10909b8 to
8ca5f16
Compare
| if ($this->logger) { | ||
| $now = \DateTime::createFromFormat('U.u', microtime(true)); | ||
| $this->logger->info('A message was consumed on '.$now->format('Y-m-d H:i:s.u')); | ||
| $this->logger->info('A message was consumed on {date}', ['date' => date('Y-m-d H:i:s.u')]); |
There was a problem hiding this comment.
If you do like this you won't have the microseconds petit padawan ;-).
Try this :
`<?php
echo date('Y-m-d H:i:s.u');
$now = \DateTime::createFromFormat('U.u', microtime(true));
echo $now->format('Y-m-d H:i:s.u');`
| $resolver->setDefaults([ | ||
| self::OPTION_STOP_ON_NO_RESULTS => false, | ||
| self::OPTION_DB_CONNECTION_NAME => '', | ||
| self::OPTION_SLEEP_TIME => 100, |
There was a problem hiding this comment.
Maybe by default we don't want the behaviour to change... So it would be a very high value for OPTION_INACTIVITY_TRIGGER...
There was a problem hiding this comment.
We can keep it like this, because without sleep time it is so bad and he will be tired.
| @@ -41,11 +43,13 @@ public function configureOptionsResolver(OptionsResolver $resolver) | |||
| $resolver->setDefaults([ | |||
| self::OPTION_STOP_ON_NO_RESULTS => false, | |||
| self::OPTION_DB_CONNECTION_NAME => '', | |||
There was a problem hiding this comment.
I saw that you changed OPTION_DB_CONNECTION_NAME to be a numeric. So why the default value is ''?
There was a problem hiding this comment.
I saw you fixed it.
| $options = [ | ||
| ConfigurableDbalProtocol::OPTION_METHOD => 'myMethod', | ||
| ConfigurableDbalProtocol::OPTION_STOP_ON_NO_RESULTS => true, | ||
| ConfigurableDbalProtocol::OPTION_SLEEP_TIME => 10000, |
There was a problem hiding this comment.
Is it possible to have a lower sleep time, because it means that this only test lasts at least 10 seconds... Like 2 seconds?
There was a problem hiding this comment.
The way phpunit bridge works is brilliant. You are a genius. Or at least you use other geniuses tools. Well done.
There was a problem hiding this comment.
phpunit bridge does the job. You are a genius.
|
|
||
| script: | ||
| - bin/phpunit --coverage-text --debug | ||
| - bin/simple-phpunit --coverage-text |
There was a problem hiding this comment.
Good improvement ;-)
| $this->onConsume($endpoint, $message); | ||
| $wakeup = microtime(true); | ||
| } | ||
|
|
There was a problem hiding this comment.
If we added extra line codes here, that take more than $inactivityTrigger, then we could trigger the nap by mistake... And it then it could make the system up to 50% slower.
The way it was done was not the best but it avoided that situation. Maybe it is not that important...!
There was a problem hiding this comment.
The use of "iFeelAsleep" made sure that you would not have a nap just after consuming a message.
There was a problem hiding this comment.
Okay we can keep it like this. There are pros and cons, but (development) time matters.
…tain period of inactivity.
Because now with the DBConfigurableConsumer, we consume with an endless frantic loop. This change allow to enter in a slow mode after some inactivity. When a new message is coming, then we leave that slow mode, until a long period of inactivity is detected again.