perftrace: limit the size of the perftrace in blackbox

Summary:
There are cases where Mercurial makes many serial requests to the server.
This diff limits the number of lines that a perftrace can send to blackbox
or print on stderr.

Reviewed By: xavierd

Differential Revision: D17078475

fbshipit-source-id: 8c8313ae0b602160e1018590dd6b87dfffd27662
This commit is contained in:
Stefan Filip 2019-08-28 11:04:46 -07:00 committed by Facebook Github Bot
parent 33f371d27c
commit f8ed4ca01d

View File

@ -491,8 +491,20 @@ def dispatch(req):
"pid": os.getpid(),
"time": time.time(),
}
splitoutput = output.split("\n")
if len(splitoutput) > 200:
readableoutput = "\n".join(
splitoutput[:200]
+ ["Perftrace trunkated at 200 lines, see {}".format(key)]
)
else:
readableoutput = output
req.ui.log(
"perftrace", "Trace:\n%s\n", output, key=key, payload=output
"perftrace",
"Trace:\n%s\n",
readableoutput,
key=key,
payload=output,
)
req.ui.log("perftracekey", "Trace key:%s\n", key, perftracekey=key)