Breakdown tsdb/head.go into multiple files#9147
Conversation
|
Would we benefit from a head package instead? |
I thought about it, but in many places (including non Head tests) we use the non exported method and fields of the Head. While it makes sense, it would be a bigger refactor touching other files, and I wont not be able to commit to it myself at the moment. So this should be a good first step before we have a head package. |
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
roidelapluie
left a comment
There was a problem hiding this comment.
Approved, but let's try to get Bartek's approval as well
|
I will wait till EOD to merge and address any concerns later if Bartek cannot come to it today. Because any other TSDB PR merges will make updating this PR tricky :) |
bwplotka
left a comment
There was a problem hiding this comment.
Nice. I don't mind - it really depends on what IDEs ppl are using. No harm either. Thanks!
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
head.gohas grown very big and lots of things have spread around randomly, making it hard to find stuff and read the code. In this PR I am proposing to break this down into the following files:head_append.go- all the code for appending stuff (samples, exemplars, future histograms, etc)head_read.go- all the code for reading the series/chunks from the Headhead_wal.go- current WAL replay code, and soon, the snapshot code would go into this.head.go- remaining stuff, i.e., structs (for head, series, stripe series, chunk etc), GC/truncation of head, helper functions for the structsThis PR merely moves code around and is a no-op. So if the contents in the new files makes sense, then that should be enough of a check.
NOTE: this will require a rebase of existing open TSDB PRs and future PRs that are in progress, but that will be required anytime we break
head.godown (or refactor), and the breakdown would be required sooner or later.