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

fix: support parallel script execution in pipelines #1304

Merged

Conversation

marcbachmann
Copy link
Collaborator

@marcbachmann marcbachmann commented Mar 19, 2021

Fixes #1303

Support parallel .multi script execution by delaying the assignment of the load confirmation.

btw. regarding the project setup: the package-lock.json links to http://artprod.dev.bloomberg.com/artifactory/api/npm/npm-repos/ as npm registry, which isn't publicly available. Therefore npm install and npm ci fails locally. By replacing all the urls with the npm registry, the npm install works again.

@marcbachmann marcbachmann marked this pull request as draft March 19, 2021 02:19
@marcbachmann marcbachmann force-pushed the support-parallel-script-execution-in-pipelines branch from cfe6a65 to 227235a Compare March 19, 2021 02:24
if (
!script ||
this.redis._addedScriptHashes[script.sha] ||
scripts.includes(script)
Copy link
Collaborator Author

@marcbachmann marcbachmann Mar 19, 2021

Choose a reason for hiding this comment

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

We might want to replace the .includes with an object lookup or set.
A Set would automatically deduplicate it.

Maybe also use const scripts = {} and then Object.values(scripts) further down.
But the performance overhead is negligible as this operation only occurs every time the scripts cache is cleared. I'd rather deduplicate the execution on first load. With the current code the script gets loaded multiple times per for every pipeline created in parallel.

We could also change the behavior by assigning a promise and then reuse that in other requests.
Also doable in another PR if desired.

this.redis._addedScriptHashes[script.sha] = loadPromise

The whole logic could also be moved into the custom command functions invoked in redis.sendCommand.

@marcbachmann marcbachmann marked this pull request as ready for review March 19, 2021 02:26
lib/pipeline.ts Outdated Show resolved Hide resolved
@marcbachmann marcbachmann force-pushed the support-parallel-script-execution-in-pipelines branch from 227235a to fb80fae Compare March 19, 2021 13:42
lib/pipeline.ts Outdated Show resolved Hide resolved
lib/pipeline.ts Outdated Show resolved Hide resolved
@marcbachmann marcbachmann force-pushed the support-parallel-script-execution-in-pipelines branch from fb80fae to f03188d Compare March 19, 2021 16:06
Copy link
Contributor

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@luin luin merged commit c917719 into redis:master Mar 21, 2021
ioredis-robot pushed a commit that referenced this pull request Mar 21, 2021
## [4.24.3](v4.24.2...v4.24.3) (2021-03-21)

### Bug Fixes

* support parallel script execution in pipelines ([#1304](#1304)) ([c917719](c917719))
@ioredis-robot
Copy link
Collaborator

🎉 This PR is included in version 4.24.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@luin
Copy link
Collaborator

luin commented Mar 21, 2021

Awesome! Thanks for the contributions!

We could also change the behavior by assigning a promise and then reuse that in other requests.
Also doable in another PR if desired.

Functionality-wise that sounds good to me. Not sure if it worth the effort (ex considering the maintainability) though as it anyway only affects cases without cache. However, PR will be welcome if you see it as appropriate. Thanks again!

@marcbachmann marcbachmann deleted the support-parallel-script-execution-in-pipelines branch January 8, 2022 02:57
janus-dev87 added a commit to janus-dev87/ioredis-work that referenced this pull request Mar 1, 2024
## [4.24.3](redis/ioredis@v4.24.2...v4.24.3) (2021-03-21)

### Bug Fixes

* support parallel script execution in pipelines ([#1304](redis/ioredis#1304)) ([c917719](redis/ioredis@c917719))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parallel .multi requests with custom scripts result in NOSCRIPT error
4 participants