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

Transfer approx terrain heights to workers instead of requesting #6716

Closed
wants to merge 4 commits into from

Conversation

likangning93
Copy link
Contributor

@likangning93 likangning93 commented Jun 21, 2018

See discussion in #6715.

Fixes #6711

@cesium-concierge
Copy link

Signed CLA is on file.

@likangning93, thanks for the pull request! Maintainers, we have a signed CLA from @likangning93, so you can review this at any time.

⚠️ I noticed that CHANGES.md has not been updated. If this change updates the public API in any way, fixes a bug, or makes any non-trivial update, please add a bullet point to CHANGES.md and comment on this pull request so we know it was updated. For more info, see the Pull Request Guidelines.


I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome.

🌍 🌎 🌏

if (packedLength > 0) {
var array = new Float64Array(packedLength);
subTaskTransferableObjects = [array.buffer];
transferTerrainHeightsPromise.then(function() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to reviewer: diff tool needs to chill here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding the query param w=1 will make the diff ignore whitespace changes
https://github.com/AnalyticalGraphicsInc/cesium/pull/6716/files?w=1

@likangning93
Copy link
Contributor Author

likangning93 commented Jun 22, 2018

I think those test failures are because Primitive setup is timing out on Travis, I can kind of reproduce the failures locally by forcing the beforeAll in PolylineVisualizerSpec to time out...

Now to figure out why.

// Push tasks transferring the JSON to the workers.
transferTerrainHeightsPromise = ApproximateTerrainHeights.initialize()
.then(function() {
var terrainHeightsString = JSON.stringify(ApproximateTerrainHeights._terrainHeights);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure this is a good idea, did we time this? I’m not sure why we didn’t just make everything work on the worker

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not terrible, even on my chromebook-grade machine this is typically under 50 ms according to simple console.time wrapping. I think it's swallowed by the rest of worker spinup, if that's anywhere near as slow as it is in Node. Keep in mind that the JSON parse on the worker side is something that has to happen even if the worker's requesting the terrain heights instead.

We could also hold the string on the main thread alongside the parsed version, then release it after workers are spun up... I'll go ahead and add that right after I get CI passing on Travis again.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you only timed the Stringify, then you are missing the part where it gets sent over to the worker. For a string, that's probably not a lot of overhead though. However, why wouldn't just making getModuleUrl work in workers be a better solution? I feel like this another bug like this will pop up again in the future the next time we want to do something with a url on a worker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, why wouldn't just making getModuleUrl work in workers be a better solution? I feel like this another bug like this will pop up again in the future the next time we want to do something with a url on a worker.

I guess this would also get us around the test failure that I keep running into on Travis in this PR...

@likangning93 likangning93 force-pushed the transferApproxTerrainHeights branch from 86c94c5 to 925c011 Compare June 22, 2018 13:34
@mramato
Copy link
Contributor

mramato commented Jun 22, 2018

I'm against this PR going into master. I think a much better approach here would be to modify TaskProcessor to get the current base url and pass it to the worker during the bootstrap process. This would allow all workers to "just work" with base urls in all cases and is a complete fix for the general issue of buildModuleUrl not being available in workers. It might require some tweaks to buildModuleUrl, but nothing major.

If what I'm proposing can't work for some reason, then I suppose this PR might be a decent fallback, but definitely not my first choice.

@mramato
Copy link
Contributor

mramato commented Jun 28, 2018

Replaced by #6720 (though I'm going to keep this branch around until that one gets merged).

@mramato mramato closed this Jun 28, 2018
@likangning93 likangning93 deleted the transferApproxTerrainHeights branch July 1, 2018 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants