-
Notifications
You must be signed in to change notification settings - Fork 512
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
/active_series
: improve json encoding performance
#6667
Conversation
/active_series
: improve json encoding performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -106,7 +107,16 @@ func ActiveSeriesCardinalityHandler(distributor Distributor, limits *validation. | |||
return | |||
} | |||
|
|||
util.WriteJSONResponse(w, activeSeriesResponse{res}) | |||
var json = jsoniter.ConfigCompatibleWithStandardLibrary | |||
bytes, err := json.Marshal(v1.Response{Data: res}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this have a Status: "success"
field set as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prometheus does set that field, however it's not quite clear to me why. Isn't the HTTP status code a good enough indication that the payload is going to be ok/parseable as expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I don't think we need the field either, but I think right now it is returning Status: ""
, which is not useful. So I'd say we either keep it and conform to the prometheus response (which includes setting the error fields), or just return Data
and nothing else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, makes sense, I'll stick with the custom struct then.
What this PR does
This adds a benchmark for the querier's
ActiveSeriesCardinalityHandler
and uses json-iterator to replace the standard libraryencoding/json
to improve marshaling performance.Here are benchmark results comparing the first two commits in this PR (std vs json-iterator encoding).
Which issue(s) this PR fixes or relates to
n/a
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]