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

bulk: Add metrics to bulk mem monitor for better visualisation #39754

Merged
merged 1 commit into from
Aug 20, 2019

Conversation

adityamaru27
Copy link
Contributor

This change reworks how we want to use memory monitors for bulk
operations.

We have a single bulkMonitor which is a child of the
root sql memory monitor. Each bulk operation will further create a
child of the bulkMonitor which will be used to control memory
growth of the bulk adder.
A new class of metrics has been hooked up to the bulkMonitor
which allows for visualization of total memory usage in the
admin UI.

Release note: None

@adityamaru27 adityamaru27 requested a review from dt August 19, 2019 21:41
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@adityamaru27
Copy link
Contributor Author

adityamaru27 commented Aug 19, 2019

Screen Shot 2019-08-19 at 5 42 20 PM

A quick test on TPCC-100 allowing cockroach to use 50% of my total memory (8 GiB), shows that the bulk memory monitor reports a max of 2.3GiB was reserved at one point by the 9 concurrent imports. The above graph is a plot of the bytes allocated by the parent bulk-monitor. This is well below the max an import could grow to (128 * 9 + 512 * 9MiB ~ 5.5GiB) but I would assume the statements completed well before they needed such memory demands. It is promising to see that all the bytes are released once the import has completed.

I'll run some more tests on larger imports and post my findings.

@dt
Copy link
Member

dt commented Aug 19, 2019

I don't really know much about the monitors or their API so I'll defer review to someone who does. is that @knz?

@dt dt requested review from knz and removed request for dt August 19, 2019 21:52
@adityamaru27
Copy link
Contributor Author

@knz I was also a little confused about why we record the logarithmic value of the high watermark of bytes allocated in a monitor. (https://github.com/cockroachdb/cockroach/blob/master/pkg/util/mon/bytes_usage.go#L404)

I consulted your comment but can you give me some intuition as to why we would not record the actual value instead?

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

I consulted your comment but can you give me some intuition as to why we would not record the actual value instead?

Back then the plotting facility in the web UI was not able to plot with a log scale on the y-axis. Given that the sizes of memory allocations follow a power law distribution, the visual result would be a few spikes at a dozen megabyte+ sizes, with the bulk of allocations (<1000 bytes) completely squashed along the x axis.

your implementation LGTM

Reviewed 4 of 4 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @adityamaru27)


pkg/util/mon/bytes_usage.go, line 218 at r1 (raw file):

	noteworthyUsageBytes int64

	curBytesCount *metric.Gauge

These two fields are missing a comment. Please explain what they are and what is their purpose; otherwise the review is difficult.

@knz
Copy link
Contributor

knz commented Aug 20, 2019

Back then the plotting facility in the web UI was not able to plot

Note: I do not know whether this has changed. It may still well be the case.

This change reworks how we want to use memory monitors for bulk
operations.

We have a single `bulkMonitor` which is a child of the
root sql memory monitor. Each bulk operation will further create a
child of the `bulkMonitor` which will be used to control memory
growth of the bulk adder.
A new class of metrics has been hooked up to the `bulkMonitor`
which allows for visualization of total memory usage in the
admin UI.

Release note: None
Copy link
Contributor Author

@adityamaru27 adityamaru27 left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @knz)


pkg/util/mon/bytes_usage.go, line 218 at r1 (raw file):

Previously, knz (kena) wrote…

These two fields are missing a comment. Please explain what they are and what is their purpose; otherwise the review is difficult.

Done.

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@adityamaru27
Copy link
Contributor Author

TFTR
bors r+

craig bot pushed a commit that referenced this pull request Aug 20, 2019
39754: bulk: Add metrics to bulk mem monitor for better visualisation r=adityamaru27 a=adityamaru27

This change reworks how we want to use memory monitors for bulk
operations.

We have a single `bulkMonitor` which is a child of the
root sql memory monitor. Each bulk operation will further create a
child of the `bulkMonitor` which will be used to control memory
growth of the bulk adder.
A new class of metrics has been hooked up to the `bulkMonitor`
which allows for visualization of total memory usage in the
admin UI.

Release note: None

Co-authored-by: Aditya Maru <adityamaru@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Aug 20, 2019

Build succeeded

@craig craig bot merged commit 57ca960 into cockroachdb:master Aug 20, 2019
@adityamaru27 adityamaru27 deleted the monitor-cleanup branch August 20, 2019 15:50
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.

4 participants