Skip to content

Automatically batch style updates - #2355

Merged
mourner merged 3 commits into
masterfrom
autobatch
Mar 30, 2016
Merged

mourner merged 3 commits into
masterfrom
autobatch

Conversation

@mourner

@mourner mourner commented Mar 29, 2016

Copy link
Copy Markdown
Member

Closes #2343. Removes map.batch and implements automatic batching of style changes, applying them once per frame. The style keeps track of all mutations done through Style setLayoutProperty, addLayer, etc., and then all mutations are applied with the style.update method which is called in map._render and happens once per frame.

Remaining tasks:

@mourner mourner added feature 🍏 performance ⚡ Speed, stability, CPU usage, memory usage, or power usage labels Mar 29, 2016
@mourner
mourner force-pushed the autobatch branch 4 times, most recently from 4bafb00 to 1f2b317 Compare March 29, 2016 05:28
Comment thread js/style/style.js
*/
batch: function(work) {
styleBatch(this, work);
update: function(classes, options) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The terminology here is starting to feel overwhelming: mutate, update, change, cascade, recalculate...

How do you feel about picking a consistent verb (i.e. update, change) and differentiating these properties and methods with direct objects?

  • cascade -> updateTransitions
  • recalculate -> updateZoom
  • mutations -> updates
  • broadcastLayers -> updateWorkerLayers
  • reloadSource -> updateSource
  • change event -> update

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, great point! I like all the suggested renames except the change event, which we use throughout the code for other classes, and it's generally more common to have events like this called change rather than update in JS APIs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd also leave reloadSource -> updateSource rename for another PR because it's tricky, potentially involving a lot of changes that are out of scope for this PR (e.g. it calls source.reload, which in turn calls pyramid.reload, but pyramid also has update method which is different, so you also have to rethink pyramid API).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've renamed mutations, broadcastLayers and did some other minor cleanups/renames, but leaving the rest for future PRs (especially cascade and recalculate) so that it doesn't interfere with current DDS PRs, otherwise we would have a lot of conflicts to resolve.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 I openend #2359

Comment thread js/style/style.js Outdated
return this;
},

_resetMutations: function() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

_resetMutations --> _resetUpdates

@lucaswoj

Copy link
Copy Markdown
Contributor

This is ready to 🚢 once you address the two minor comments above.

Great work! I love a negative line PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 🍏 performance ⚡ Speed, stability, CPU usage, memory usage, or power usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

remove map.batch and automatically batch style changes

2 participants