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

Use already open blocks while compacting. #441

Merged
merged 1 commit into from
Nov 15, 2018
Merged

Conversation

brian-brazil
Copy link
Contributor

This roughly halves the RAM requirements of compaction.

There's not much point in optimising compaction memory itself further, as loading in the new blocks would OOM at reload time. Reducing the memory used by the indexes would be the main hope.

This also makes compaction a little bit faster.

This roughly halves the RAM requirements of compaction.

Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
@krasi-georgiev
Copy link
Contributor

would you mind opening the same PR on Prometheus so we can run a bench test to see it in action?

@bwplotka
Copy link
Contributor

bwplotka commented Nov 1, 2018

Nice @brian-brazil

Just curious how you measured the RAM consumption? Profiling, flamegraph? Can see you added timings as well.

Also just wondering in what case Prometheus had those blocks already opened? by what operation?

@brian-brazil
Copy link
Contributor Author

Heap profiling.

They'll already be loaded by Prometheus as they're normal blocks.

Copy link
Collaborator

@gouthamve gouthamve left a comment

Choose a reason for hiding this comment

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

LGTM!


// Use already open blocks if we can, to avoid
// having the index data in memory twice.
for _, o := range open {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we simplify this by making a map of the open blocks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thinking was there's usually only 10ish open blocks, so no need to optimise.

Compact(dest string, dirs ...string) (ulid.ULID, error)
// Can optionally pass a list of already open blocks,
// to avoid having to reopen them.
Compact(dest string, dirs []string, open []*Block) (ulid.ULID, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is changing public interface. Could you tag a minor version? We don't have any tags yet so maybe a good time to start now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

0.1.0?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah , or maybe even 1.1.0 , since it is pretty stable now and I think go modules don't pull anything below 1.0. It would be nice if we could use these tags as well when we vendor it in Prometheus.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think go modules don't pull anything below 1.0

Go modules do work with v0.x.y tags. Cutting a v1 is a pretty heavy commitment and I tend to think that a v0.something is appropriate here.

Copy link
Contributor

@krasi-georgiev krasi-georgiev Nov 14, 2018

Choose a reason for hiding this comment

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

I don't mind either way as long as we put something in place in terms of API versioning it is a step in the right direction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, so I should merge and then add a v0.1.0 tag?

Copy link
Contributor

Choose a reason for hiding this comment

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

yep lets try something as simple as that, unless @simonpasquier has any other recommendations.

I will keep reading how are we suppose to do this properly, but for now it is ok to start with just this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, so I should merge and then add a v0.1.0 tag?

Hm.. you don't want to tag 0.1.0 before changing API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We've changed the API many times before, we have to start somewhere.

@brian-brazil brian-brazil merged commit 41b5458 into master Nov 15, 2018
@brian-brazil brian-brazil deleted the compact-ram branch November 15, 2018 12:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants