Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Messenger] Batch delivery#51034

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
hgraca wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromhgraca:messenger/doctrine_transport_batch_delivery

Conversation

hgraca
Copy link

@hgracahgraca commentedJul 19, 2023
edited
Loading

QA
Branch?7.1
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#47828
LicenseMIT
Doc PRsymfony/symfony-docs#18566

Currently, the doctrine transport only delivers one message at a time,
resulting in low performance and a very high amount of hits to the DB.
(one hit per message)

With batch delivery, the transport will retrieve several messages in a single query.

jamesisaac, valtzu, jdreesen, and BlackbitDevs reacted with thumbs up emoji
@hgracahgracaforce-pushed themessenger/doctrine_transport_batch_delivery branch from8ecf8bb to84e4797CompareAugust 1, 2023 19:19
@OskarStarkOskarStark changed the titleMessenger/doctrine transport batch delivery[Messenger][Doctrine] Batch deliveryAug 2, 2023
@carsonbotcarsonbot changed the title[Messenger][Doctrine] Batch delivery[Messenger] Batch deliveryAug 2, 2023
@hgracahgracaforce-pushed themessenger/doctrine_transport_batch_delivery branch from84e4797 to18d2270CompareAugust 4, 2023 21:29
@hgracahgracaforce-pushed themessenger/doctrine_transport_batch_delivery branch 2 times, most recently from308f750 to5572863CompareAugust 13, 2023 19:32
@hgraca
Copy link
Author

hgraca commentedAug 13, 2023
edited
Loading

I've rebased this PR on branch 6.4, and removed all the commits that were merely small improvements (I will open PRs for them later).

I see that the pipeline is failing but it seems to be unrelated to this PR.

I am, however, afraid that this PR might be getting stale since it is open for a few weeks now.

Is this normal or is there something else that I should do? (I'm new to contributing to Symfony so I really don't know)

btw, there are checks failing but I believe they are unrelated to this PR.

@hgracahgracaforce-pushed themessenger/doctrine_transport_batch_delivery branch 2 times, most recently frombcd4960 toc727bb9CompareSeptember 25, 2023 20:02
@hgraca
Copy link
Author

Rebased again and put the changelog in the correct file

@hgracahgracaforce-pushed themessenger/doctrine_transport_batch_delivery branch 6 times, most recently frome6bc6fe to5501be1CompareNovember 5, 2023 09:18
@nicolas-grekasnicolas-grekas modified the milestones:6.4,7.1Nov 15, 2023
@hgracahgracaforce-pushed themessenger/doctrine_transport_batch_delivery branch 2 times, most recently frombe723f3 tob12ed43CompareNovember 17, 2023 16:29
@hgracahgracaforce-pushed themessenger/doctrine_transport_batch_delivery branch 2 times, most recently fromb12ed43 to32105fbCompareNovember 17, 2023 23:56
Currently, the doctrine transport only delivers one message at a time,resulting in low performance and a very high amount of hits to the DB.(one hit per message)With batch delivery, the transport will retrieve several messagesin a single query.Co-authored-by: Alexander Malyk <shu.rick.ifmo@gmail.com>
@hgracahgracaforce-pushed themessenger/doctrine_transport_batch_delivery branch from32105fb tod2bae3bCompareNovember 21, 2023 15:07
public function __destruct()
{
// The worker using this transport might have pulled 50 msgs out of the mq, marking them as "in process",
// but because of its options (ie --limit, --failure-limit, --memory-limit, --time-limit) it might terminate
Copy link
Author

@hgracahgracaNov 22, 2023
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Then I think we would increase complexity and it wouldn't scale.

For--limit we could do some calculations... would be doable despite the increase in complexity..
But for-failure-limit we would need to somehow keep track of how many failures happened, probably replicating logic that is already built somewhere. For--memory-limit and--time-limit the same.

Then, if/when in the future we would add more options, someone would need to also adjust this code, to be able to handle the new option.

With the implementation in this PR however, we don't need to do anything special to adjust to a particular option, neither now nor in the future if/when we add new options.

*/
public function extractDoctrineEnvelopeListIds(array $doctrineEnvelopeList): array
{
return array_map(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

return array_column($doctrineEnvelopeList, 'id') will do the same and might be a bit faster by keeping all the logic in the C layer.

@@ -151,7 +155,7 @@ public function send(string $body, array $headers, int $delay = 0): string
return $this->driverConnection->lastInsertId();
}

public function get():?array
public function get(): array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I suggest document the type of the returned array.

],
[
Types::DATETIME_IMMUTABLE,
class_exists(ArrayParameterType::class) ? ArrayParameterType::INTEGER : Types::SIMPLE_ARRAY,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is wrong.Types::SIMPLE_ARRAY is something totally different. The fallback for older DBAL versions isConnection::PARAM_INT_ARRAY.

And the code below does not check for older versions, so it is inconsistent.

@@ -58,11 +60,16 @@ public function get(): iterable
throw new TransportException($exception->getMessage(), 0, $exception);
}

if (null === $doctrineEnvelope) {
if (null === $doctrineEnvelopeList) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This won't ever be true.Connection::get cannot returnnull anymore.

@@ -83,6 +90,11 @@ public function reject(Envelope $envelope): void
}
}

public function undeliverNotHandled(): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should it be marked as@internal ?

@xabbuhxabbuh modified the milestones:7.1,7.2May 15, 2024
@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@fabpotfabpotfabpot left review comments

@stofstofstof left review comments

@dunglasdunglasAwaiting requested review from dunglas

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

[Messenger] Bad performances with the Doctrine/MySQL transport
7 participants
@hgraca@fabpot@stof@nicolas-grekas@OskarStark@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp