Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Store gfx::DrawScope objects with associated render objects. #15395

Merged
merged 3 commits into from Feb 14, 2020

Conversation

kkaefer
Copy link
Contributor

@kkaefer kkaefer commented Aug 16, 2019

We used some shared SegmentVectors, e.g. for drawing raster or background tiles. In longer running maps, this lead to resource accumulation. By storing the SegmentVectors and the contained gfx::DrawScope objects, we ensure that resources get released when the associated render objects vanish.

As a longer term solution, we should remove gfx::DrawScope objects from SegmentVector objects and store them separately.

Fixes: #15179

@kkaefer kkaefer added performance Speed, stability, CPU usage, memory usage, or power usage Core The cross-platform C++ core, aka mbgl labels Aug 16, 2019
Copy link
Contributor

@pozdnyakov pozdnyakov left a comment

Choose a reason for hiding this comment

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

Looks great overall!

src/mbgl/renderer/layers/render_background_layer.cpp Outdated Show resolved Hide resolved
@springmeyer
Copy link
Contributor

In longer running maps, this lead to resource accumulation.

What is the best way to detect a situation like this in general? Is it possible to have a test that runs on CI which could catch a situation like this?

As a longer term solution, we should remove gfx::DrawScope objects from SegmentVector objects and store them separately.

What is the reason not to do that now? Too much effort or is it blocked by something specific currently?

@kkaefer
Copy link
Contributor Author

kkaefer commented Aug 19, 2019

What is the reason not to do that now? Too much effort or is it blocked by something specific currently?

I embarked on this refactor, but it got too convoluted in the symbol rendering code due to too many code paths, so I decided to split this into multiple PRs and address the issue separately.

@kkaefer
Copy link
Contributor Author

kkaefer commented Aug 19, 2019

What is the best way to detect a situation like this in general? Is it possible to have a test that runs on CI which could catch a situation like this?

I've been using Instruments.app and Mark Generation, then manually inspecting the remaining allocations while running the node-benchmark target.

I'm not sure there's a good way to automate this without lots of false positives in CI environment; I've been seeing various V8-internal allocations that I attributed to its memory management, as well as memory that was still allocated for good reasons (e.g. system caches of decompressed images).

@springmeyer
Copy link
Contributor

I'm not sure there's a good way to automate this without lots of false positives in CI environment; I've been seeing various V8-internal allocations that I attributed to its memory management, as well as memory that was still allocated for good reasons (e.g. system caches of decompressed images).

Got it. Do you think we might avoid false positives if we had a pure C++ benchmark instead of using a node one (obviously would still have issue of system caches)?

@springmeyer
Copy link
Contributor

@kkaefer is this close to ready to merge? I'll leave it to @pozdnyakov or another @mapbox/gl-native dev to approve.

@springmeyer
Copy link
Contributor

bump @kkaefer

@kkaefer
Copy link
Contributor Author

kkaefer commented Aug 22, 2019

I'm trying to figure out why https://circleci.com/gh/mapbox/mapbox-gl-native/317751 fails; it has repeatedly failed on CI at combinations/hillshade-translucent--line-translucent, which is just blank. That test doesn't fail locally for me.

kkaefer and others added 3 commits February 14, 2020 16:49
We used some shared SegmentVectors, e.g. for drawing raster or background tiles.
In longer running maps, this lead to resource accumulation. By storing the SegmentVectors
and the contained gfx::DrawScope objects, we ensure that resources get released
when the associated render objects vanish.
@alexshalamov alexshalamov merged commit 59294aa into master Feb 14, 2020
@alexshalamov alexshalamov deleted the separate-segments branch February 14, 2020 15:34
@springmeyer
Copy link
Contributor

Thanks for landing this @alexshalamov!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl performance Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memory consumption keeps growing when Debug info is enabled
5 participants