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

Very Balanced Worker Spawn Method #2

Closed
gazmull opened this issue Sep 4, 2019 · 0 comments

Comments

@gazmull
Copy link
Owner

commented Sep 4, 2019

The CPU cores are wasted due to the current code only distributing Resources per character (which is 3 Resources on average). On average, only 3 CPU cores were being occupied by the DownloadManager. Currently using the latest commit on a 12-core cloud instance and I'm wasting cents each second passes by.

Currently I can only propose that to occupy all CPU cores: do a round-robin distribution on Character[] as well. For of is very weak in this case so try to avoid it.

For Reference:

for (const char of this.data as ICharacter[]) {
const resources = [ ...char.resources.entries() ];
const balancedData = this._balanceData<[hashIdentifier, IResourceValues]>(resources);
const workers = await Promise.all(
balancedData.map((val, idx) => {
const finalData: ICharacter = {
id: char.id,
name: char.name,
resources: new Collection(val)
};
return this._spawnWorker(idx, finalData);
})
);
workersResult.push(...workers);
}

@gazmull gazmull added the enhancement label Sep 4, 2019

@gazmull gazmull closed this in 24c5e3e Sep 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.