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

Add maxWorkers option #2655

Closed
wants to merge 1 commit into from

Conversation

anandthakker
Copy link
Contributor

Also sets maxWorkers on the debug page to 3, on the theory that a pretty
large majority of users have 4 cpus.

Closes #2022

@anandthakker
Copy link
Contributor Author

cc @lucaswoj

I don't see an especially good way to add meaningful tests for this, since it's basically about passing a number through to new Style() and then to new Dispatcher(). I've used something like proxyquire in other projects to mock CJS module dependencies, but not sure that that's something yall want to adpot

@lucaswoj
Copy link
Contributor

lucaswoj commented Jun 2, 2016

I don't see an especially good way to add meaningful tests for this

Looks like you made one test start failing. That might be a good place to start looking. 😉

@@ -58,7 +58,8 @@
zoom: 12.5,
center: [-77.01866, 38.888],
style: 'mapbox://styles/mapbox/streets-v8',
hash: true
hash: true,
maxWorkers: 3
Copy link
Contributor

Choose a reason for hiding this comment

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

Why maxWorkers? Isn't this literally the number of workers?

Copy link
Member

Choose a reason for hiding this comment

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

👍 numWorkers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lucaswoj @mourner I considered "num", but chose "max" -- this was the argument in my head:

maxWorkers is really what the user (me) wants to control, whereas numWorkers is more of an internal property. The fact that they are the same right now is an implementation detail; I could imagine the implementation changing to, say, construct/destroy workers on demand (especially given the possibility of worker pooling).

That said, I don't feel especially strongly about this, so just lemme know what yall think

Copy link
Contributor

Choose a reason for hiding this comment

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

Right now, this property literally controls the number of spawned workers. If we change the implementation in the future, we can change the property name 😄

Let's go with workerCount for an abbreviation-free, grammatically correct, and best-practice compliant name.

@lucaswoj
Copy link
Contributor

lucaswoj commented Jun 2, 2016

Happy to 🚢 this with a test case, and agreenment on the parameter name.

@anandthakker
Copy link
Contributor Author

Looks like you made one test start failing. That might be a good place to start looking. 😉

Oh dear. 😊

Thanks, will do.

@anandthakker
Copy link
Contributor Author

@lucaswoj Fixed the failing test and added another, but the build still fails because coveralls (I think) doesn't like my fork:

/home/ubuntu/mapbox-gl-js/node_modules/coveralls/bin/coveralls.js:18
        throw err;
        ^
Bad response: 422 {"message":"Couldn't find a repository matching this job.","error":true}

@lucaswoj
Copy link
Contributor

lucaswoj commented Jun 3, 2016

The coveralls error should have been (might have been?) fixed by 1b25043. Have you rebased in the last day?

@anandthakker
Copy link
Contributor Author

The coveralls error should have been (might have been?) fixed by 1b25043. Have you rebased in the last day?

I had not! Just rebased and force pushed.

@lucaswoj
Copy link
Contributor

lucaswoj commented Jun 3, 2016

Rad! Looks like it is working now.

@anandthakker
Copy link
Contributor Author

Sweet!

Did you see my note about the option name? Easy to change, just lemme know.

Also sets maxWorkers on the debug page to 3, on the theory that a pretty
large majority of users have 4 cpus.

Closes mapbox#2022
@anandthakker
Copy link
Contributor Author

Amended the commit:

  • s/maxWorkers/workerCount/
  • Add jsdoc for workerCount option

I believe this should now be ready

@anandthakker
Copy link
Contributor Author

➡️ #2666

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.

3 participants