batch tag upserts, remove randint in tag sampling#699
Merged
DanCech merged 3 commits intographite-project:masterfrom Dec 4, 2017
Merged
batch tag upserts, remove randint in tag sampling#699DanCech merged 3 commits intographite-project:masterfrom
DanCech merged 3 commits intographite-project:masterfrom
Conversation
deniszh
reviewed
Nov 23, 2017
lib/carbon/writer.py
Outdated
| def writeTagsForever(): | ||
| if reactor.running: | ||
| try: | ||
| written = writeTags() |
Member
There was a problem hiding this comment.
Maybe stupid question - why not just call writeTags()? Why assign to written and never check result? And writeTags() should not return anything, right?
Member
Author
There was a problem hiding this comment.
Yeah that was a by-product of some refactoring that I need to clean up
Member
Author
|
I realized that |
deniszh
approved these changes
Nov 24, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR complements graphite-project/graphite-web#2125 and switches writer to batch tag updates.
The implementation is pretty basic, series created and updated are added to 2 queues which are then processed in batches in a separate thread. 2 queues are used so that new series are prioritized when writing to the TagDB, and so that they don't compete with updates for space in the queue. Each queue has a maximum length of
TAG_QUEUE_SIZE.The writer will write at most
TAG_BATCH_SIZEpaths in each request, and will process the queue as quickly as possible until the queue is empty. I'm not sure if we want to add a delay in between batches to avoid overloading graphite-web.The other change here is to remove the use of
random.randintin selecting which updates to send to the tagdb, instead just using a global counter and sending everyTAG_UPDATE_INTERVALth path. As long as the total number of series being processed isn't an exact multiple or factor ofTAG_UPDATE_INTERVALthis will still result in every series getting upserted periodically.Finally I updated
run_twistd_pluginto enable debug logging when passing--debugon the command line.As always, any and all suggestions for improvement are appreciated.
H/T to @Civil for the suggestion of batching the tagdb updates.