Skip to content

Optimize line drawing by avoiding per-tile work - #3485

Merged
mourner merged 2 commits into
masterfrom
optimize-line-draw
Oct 30, 2016
Merged

mourner merged 2 commits into
masterfrom
optimize-line-draw

Conversation

@mourner

@mourner mourner commented Oct 28, 2016 •

Copy link
Copy Markdown
Member

This is a slightly messy attempt at winning back some of the performance that regressed with #3342 back, until we solve the challenge of ensuring all tiles are always rendered with the same style.

The idea is to simply check whether the program changed after useProgram call, and not do a big portion of the drawing work if it didn't.

On my 3342 benchmark, results are as follows:

  • v0.19: 8.3ms
  • v0.25: 17.2ms
  • master: 15.3ms (looks like some of your recent changes saved us some ms @jfirebaugh!)
  • this PR: 12.2ms 11.7ms

👀 @lucaswoj @jfirebaugh

@jfirebaugh

Copy link
Copy Markdown
Contributor

I'd prefer to follow the optimization that native uses: each program object records the value which was last set for each uniform, and avoids calling glUniform* when the value isn't changing. This optimization benefits every layer type as well as the k === 0 case here (you can reuse the uniform values set by a previous layer, if they're not changing).

@mourner

mourner commented Oct 28, 2016

Copy link
Copy Markdown
Member Author

@jfirebaugh yes, but that sounds like a more involved refactor (#145). Meanwhile this PR is an easy short-term stopgap that we can revert at any time.

@jfirebaugh jfirebaugh left a comment

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.

Fair point!

@mourner

mourner commented Oct 28, 2016

Copy link
Copy Markdown
Member Author

@jfirebaugh added another commit that removes redundant state changes for pattern/dash-related line drawing code by tracking if the tile zoom changed between tiles. Also cleaned it up a bit. This brings the benchmark result a little further down, from 12.2 to 11.7.

@mourner

mourner commented Oct 28, 2016

Copy link
Copy Markdown
Member Author

frame-duration benchmark result isn't as significant because of the averaging I mentioned in #3342, but still noticeable:

benchmark master optimize-line-draw
frame-duration 9.6 ms, 5% > 16ms 8.9 ms, 1% > 16ms

@mourner
mourner merged commit cdd27c0 into master Oct 30, 2016
@mourner
mourner deleted the optimize-line-draw branch October 30, 2016 01:38
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.

2 participants