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

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

Merged
alexshalamov merged 3 commits into
masterfrom
separate-segments
Feb 14, 2020
Merged

alexshalamov merged 3 commits into
masterfrom
separate-segments

Conversation

@kkaefer

@kkaefer kkaefer commented Aug 16, 2019 •

Copy link
Copy Markdown
Member

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

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

Looks great overall!

@springmeyer

Copy link
Copy Markdown
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

kkaefer commented Aug 19, 2019 •

Copy link
Copy Markdown
Member Author

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

kkaefer commented Aug 19, 2019

Copy link
Copy Markdown
Member Author

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

@kkaefer
kkaefer force-pushed the separate-segments branch from 0a14006 to 2a688c3 Compare August 19, 2019 07:41
@springmeyer

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

bump @kkaefer

@kkaefer

kkaefer commented Aug 22, 2019

Copy link
Copy Markdown
Member Author

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.

@alexshalamov
alexshalamov requested review from astojilj and tmpsantos and removed request for alexshalamov February 13, 2020 19:49
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
Copy Markdown
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