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

DH 7: ref: nix async lib in the simplest way #61

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

coolaj86
Copy link
Contributor

@coolaj86 coolaj86 commented Jun 15, 2023

This is built on other PRs now, so the relevant commit is just 7fea699.

This replaces async with Promise in the simplest way possible.

Much of the time task pools are used with such a high number that they actually cause thrashing and decrease performance.

My assumption that the magic number of 16 tasks probably wasn't tested, but just chosen at random and this would actually be more performant queuing single tasks in a row anyway.

Since it's being called on a batch (which already contains some number of requests), I think that even more.

Built on #60 just look at b94b291 for actual code changes.

Essentially:

- this.queue = async.queue((task, callback) => {
-   task(callback);
- }, queueSize);
+ this._chain = Promise.resolve();
+ this.queue = {
+   push: function (task) {
+     const taskAsync = promisify(task);
+     this._chain = this._chain.then(async function () {
+       await taskAsync();
+     });
+   },
+ };

@coolaj86 coolaj86 force-pushed the ref-nix-async-lib-simple branch 2 times, most recently from 1f855ba to 29d8fe7 Compare June 15, 2023 23:31
@coolaj86 coolaj86 changed the title ref: nix async lib in the simplest way DH 7: ref: nix async lib in the simplest way Apr 12, 2024
@coolaj86 coolaj86 changed the title DH 7: ref: nix async lib in the simplest way DH 7(a): ref: nix async lib in the simplest way Apr 12, 2024
@coolaj86 coolaj86 changed the title DH 7(a): ref: nix async lib in the simplest way DH 7: ref: nix async lib in the simplest way Apr 12, 2024
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.

None yet

1 participant