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

Optimize line drawing by avoiding per-tile work #3485

Merged
merged 2 commits into from
Oct 30, 2016
Merged

Conversation

mourner
Copy link
Member

@mourner mourner commented Oct 28, 2016

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
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
Copy link
Member Author

mourner commented Oct 28, 2016

@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.

Copy link
Contributor

@jfirebaugh jfirebaugh left a comment

Choose a reason for hiding this comment

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

Fair point!

@mourner
Copy link
Member Author

mourner commented Oct 28, 2016

@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
Copy link
Member Author

mourner commented Oct 28, 2016

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

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