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

Simplify and optimize state tracking #1293

Merged
merged 11 commits into from Nov 19, 2019
Merged

Simplify and optimize state tracking #1293

merged 11 commits into from Nov 19, 2019

Conversation

tsherif
Copy link
Contributor

@tsherif tsherif commented Nov 19, 2019

  • Consolidate state tracking functions and tables. State tracking now only exports the following functions: setParameters, getParameters, withParameters, resetParameters.
  • Optimize state setting to avoid copying large objects.
  • Update tests.

CPU performance improvement on the deck.gl stress test is significant:

Before After Improvement
CPU Time 68ms 34ms 34ms (50%)
GPU Time 22ms 22ms 0ms (0%)

@coveralls
Copy link

coveralls commented Nov 19, 2019

Coverage Status

Coverage decreased (-0.2%) to 61.92% when pulling ca0e78e on state-track-simplify into 0e923a8 on master.

@@ -1350,7 +1350,7 @@ test('WebGL#Transform run (custom parameters)', t => {
const outTexData = transform.getData({packed: true});
t.deepEqual(outTexData, expectedData, `${name} Transform should write correct data into Texture`);

t.ok(getParameter(gl2, GL.BLEND) === true, 'Parameters are properly set');
t.ok(getParameters(gl2, [GL.BLEND])[GL.BLEND] === true, 'Parameters are properly set');
Copy link
Contributor

Choose a reason for hiding this comment

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

getParameters(gl, key) -> getParameters(gl, key)[key], this is breaking API change. Update getParamters doc and also upgrade guide?

Also why do we have to specify the key twice?

Copy link
Contributor Author

@tsherif tsherif Nov 19, 2019

Choose a reason for hiding this comment

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

It's getParameter (singular) to getParameters (plural) which returns an object. getParameter (singular) has been removed.

Docs have already been updated.

Copy link
Collaborator

@ibgreen ibgreen left a comment

Choose a reason for hiding this comment

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

@tsherif The perf gains look promising!

A general comment: Due to the amount of code moved, git's diffing process is not effective here and it is hard to see what changes have actually been made. I would for instance be interested in understanding the performance optimization related changes, and also get a handle on what other detailed changes where made.

Just an idea: In cases like this, when I realize the diffing didn't work, I sometimes go back and split this type of PRs into:

  • a first PR that just moves code between files without changing anything, that can be quickly landed.
  • then a second PR that now clearly shows what was changed in the old code.

Not a must, but if you did, I'd certainly be happy to take a second look.

// Reset all parameters to a pure context state
export function resetParameters(gl) {
setParameters(gl, getDefaultParameters(gl));
setParameters(gl, GL_PARAMETER_DEFAULTS);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Keep the comment that explains that the defaults will not be correct for certain values, e.g. those that are initialized based on canvas sizes?


// frameBuffer not supported: use framebuffer API
// TODO - is this still true?
assert(!parameters.frameBuffer);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check can be dropped now. No apps have been using params.frameBuffer with that spelling for a long time.

@tsherif
Copy link
Contributor Author

tsherif commented Nov 19, 2019

The biggest change, performance-wise was getting rid of this: https://github.com/uber/luma.gl/pull/1293/files#diff-5a444b3148edb50012ab27ede7777f31L62

I'm considering generally disallowing that pattern of using Object.assign to set defaults as it's come up a few times as a performance bottleneck.

@tsherif tsherif merged commit 4070147 into master Nov 19, 2019
@tsherif tsherif deleted the state-track-simplify branch November 19, 2019 22:29
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.

None yet

5 participants