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

WAL/marshalable chunks #2764

Merged
merged 4 commits into from
Nov 4, 2020
Merged

Conversation

owen-d
Copy link
Member

@owen-d owen-d commented Oct 15, 2020

This PR adds more types/functions to prepare for WAL serialization. Includes some basic tests.

@codecov-io
Copy link

Codecov Report

Merging #2764 into master will decrease coverage by 0.10%.
The diff coverage is 54.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2764      +/-   ##
==========================================
- Coverage   61.32%   61.21%   -0.11%     
==========================================
  Files         179      181       +2     
  Lines       14438    14547     +109     
==========================================
+ Hits         8854     8905      +51     
- Misses       4775     4824      +49     
- Partials      809      818       +9     
Impacted Files Coverage Δ
pkg/chunkenc/dumb_chunk.go 0.00% <0.00%> (ø)
pkg/chunkenc/interface.go 85.18% <ø> (ø)
pkg/ingester/checkpoint.go 0.00% <0.00%> (ø)
pkg/ingester/encoding.go 75.00% <75.00%> (ø)
pkg/chunkenc/memchunk.go 73.43% <100.00%> (+0.06%) ⬆️
pkg/ingester/transfer.go 58.91% <100.00%> (-1.56%) ⬇️
pkg/storage/stores/shipper/uploads/table.go 68.66% <0.00%> (-1.85%) ⬇️
...kg/storage/stores/shipper/uploads/table_manager.go 65.78% <0.00%> (-1.76%) ⬇️
pkg/promtail/targets/file/filetarget.go 63.38% <0.00%> (-0.71%) ⬇️
... and 3 more

Copy link
Contributor

@sandeepsukhani sandeepsukhani left a comment

Choose a reason for hiding this comment

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

Changes look good to me so far. The only thing I can't relate to is the need for toWireChunks and fromWireChunks. If I understand it correctly we would be needing just the encoding and decoding of records and series. Can you please help me understand why we need it or is it not related to WAL implementation?

@owen-d
Copy link
Member Author

owen-d commented Nov 4, 2020

The wireChunks functions are inspired by Cortex and will be used for serializing in memory chunks to/from disks in the checkpointing process of the WAL.

@@ -106,11 +106,13 @@ type Chunk interface {
Blocks(mintT, maxtT time.Time) []Block
Size() int
Bytes() ([]byte, error)
BytesWith([]byte) ([]byte, error) // uses provided []byte for buffer instantiation
Copy link
Contributor

Choose a reason for hiding this comment

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

Fun fact we also need this for iterator, to be able to reuse them.

// The passed wireChunks slice is for re-use.
func toWireChunks(descs []*chunkDesc, wireChunks []Chunk) ([]Chunk, error) {
if cap(wireChunks) < len(descs) {
wireChunks = make([]Chunk, len(descs))
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it wouldn't be better to append what is missing. But without benchmark, I can't prove it so we shall see in the future.

lastUpdated: time.Now(),
}

mc, err := chunkenc.NewByteChunk(c.Data, conf.BlockSize, conf.TargetChunkSize)
Copy link
Contributor

Choose a reason for hiding this comment

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

changing the config of this could be catastrophic for the wal ? I wonder if we should encode this in the chunk header now ? Not for this PR but just raising a point here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was worried about this as well, but don't think it will adversely affect us. We'd simply flush on the next push if moving from a larger to a smaller block or target size.

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

@owen-d owen-d merged commit dc0bd01 into grafana:master Nov 4, 2020
cyriltovena pushed a commit to cyriltovena/loki that referenced this pull request Jun 11, 2021
…2764)

Signed-off-by: Trevor Wood <Trevor.G.Wood@gmail.com>

Co-authored-by: Marco Pracucci <marco@pracucci.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants