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

perf(queue): allow to add more than one base marker #2841

Closed
wants to merge 7 commits into from

Conversation

roggervalf
Copy link
Collaborator

when using bulk operations, only one marker is added, in this case only one worker is awake. Other worker instances will be waiting for 5 seconds to pick jobs from waiting

@roggervalf roggervalf force-pushed the perf-multiple-markers branch from 9f629d8 to fe654fb Compare October 31, 2024 02:21
@roggervalf roggervalf changed the title perf(queue): allow to add more than one base marker DRAFT perf(queue): allow to add more than one base marker Oct 31, 2024
@roggervalf roggervalf force-pushed the perf-multiple-markers branch from 8d38fc5 to d21b980 Compare November 1, 2024 05:12
@manast
Copy link
Contributor

manast commented Nov 5, 2024

I see the problem, but I feel the solution is quite complex, maybe there is another way to do it that is simpler, we could for example always add a marker after every work in a bulk even if it is not really needed, that will be a bit less efficient but it is much simpler to implement as you just do it in the multi/exec pipeline... maybe there are even better solutions.

@roggervalf roggervalf force-pushed the perf-multiple-markers branch from d21b980 to f1f5f7f Compare November 12, 2024 00:23
@@ -297,8 +299,18 @@ export class Job<
});
}

if (opts.markerCount > 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not using the number of jobs instead of an option?
Also, If the jobs are standard jobs, no markers are needed at all right? this should only be needed for prioritised or if they are delayed less than the blockTime unless I am missing something.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added as an option to not add more matkers than necessary, imagine that you add 1000 jobs and you only have 2 workers. If add 1000 matkers workers Will consume all of them unnecessarily. Only need 2 markes one pr each worker to wake up them. Also is a good point about limiting by the type of job, this should only consider standard and prioritized jobs. Delayed matkers will be added by addDelayedJob script so I can ignore this type in that case. Standard jobs are also using matkers, this is needed for this case as well

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but this option will never be used correctly anyway, as it is difficult to keep track how many actual workers are there. It would be possible to do a client list and find the workers also, but this is slower and it does not work in GCP as they do not support the CLIENT LIST command (but we could ignore this as it is GCPs fault so to speak)

Copy link
Contributor

Choose a reason for hiding this comment

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

But in any case, these markers are only needed for prioritised and delayed jobs faster than the default blockTime right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

markers are also needed for standard jobs as we are not using brpoplpush anymore

Copy link
Contributor

Choose a reason for hiding this comment

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

How fast would a call to "getWorkers" be?

Copy link
Contributor

@manast manast Nov 13, 2024

Choose a reason for hiding this comment

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

what about this: a queue instance keeps a "getWorkersCount" cached for lets say 5 minutes, or some configurable value, and based on this count it will apply the number of markers to add?

Copy link
Contributor

Choose a reason for hiding this comment

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

the number of workers should not change particularly often anyway

Copy link
Contributor

@manast manast Nov 13, 2024

Choose a reason for hiding this comment

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

Something like, in "addBulk", if we hace a fresh workers count we use that one, if it is not fresh we get a new count and use that count.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think that it's necessary to call getWorkers every time as you said, this number should not change particularly often. Maximum marker count can be handled by users in my opinion or they can avoid of passing markerCount in bulk operations.

@@ -297,8 +299,18 @@ export class Job<
});
}

if (opts.markerCount > 1) {
const markers: (number | string)[] = [];
Array.from(Array(opts.markerCount - 1).keys()).forEach(index => {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use "fill" instead: const array = Array(length).fill(0);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll try it

@roggervalf roggervalf force-pushed the perf-multiple-markers branch from 65e9708 to 63355ca Compare November 14, 2024 02:11
@roggervalf
Copy link
Collaborator Author

in favor of #2904

@roggervalf roggervalf closed this Nov 19, 2024
@roggervalf roggervalf deleted the perf-multiple-markers branch November 19, 2024 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants