lib/protoparser: avoid copying of buffer read from the network to unmarshal buffer

This commit is contained in:
Aliaksandr Valialkin 2020-09-28 17:06:26 +03:00
parent 8df33bd5c1
commit 1481d6d8ff
8 changed files with 8 additions and 8 deletions

View file

@ -48,7 +48,7 @@ func ParseStream(req *http.Request, callback func(rows []Row) error) error {
uw := getUnmarshalWork()
uw.callback = callback
uw.cds = cds
uw.reqBuf = append(uw.reqBuf[:0], ctx.reqBuf...)
uw.reqBuf, ctx.reqBuf = ctx.reqBuf, uw.reqBuf
common.ScheduleUnmarshalWork(uw)
}
return ctx.Error()

View file

@ -33,7 +33,7 @@ func ParseStream(r io.Reader, callback func(rows []Row) error) error {
for ctx.Read() {
uw := getUnmarshalWork()
uw.callback = callback
uw.reqBuf = append(uw.reqBuf[:0], ctx.reqBuf...)
uw.reqBuf, ctx.reqBuf = ctx.reqBuf, uw.reqBuf
common.ScheduleUnmarshalWork(uw)
}
return ctx.Error()

View file

@ -59,7 +59,7 @@ func ParseStream(r io.Reader, isGzipped bool, precision, db string, callback fun
uw.callback = callback
uw.db = db
uw.tsMultiplier = tsMultiplier
uw.reqBuf = append(uw.reqBuf[:0], ctx.reqBuf...)
uw.reqBuf, ctx.reqBuf = ctx.reqBuf, uw.reqBuf
common.ScheduleUnmarshalWork(uw)
}
return ctx.Error()

View file

@ -32,7 +32,7 @@ func ParseStream(r io.Reader, callback func(rows []Row) error) error {
for ctx.Read() {
uw := getUnmarshalWork()
uw.callback = callback
uw.reqBuf = append(uw.reqBuf[:0], ctx.reqBuf...)
uw.reqBuf, ctx.reqBuf = ctx.reqBuf, uw.reqBuf
common.ScheduleUnmarshalWork(uw)
}
return ctx.Error()

View file

@ -59,7 +59,7 @@ func ParseStream(req *http.Request, callback func(rows []Row) error) error {
uw := getUnmarshalWork()
uw.callback = callback
uw.reqBuf = append(uw.reqBuf[:0], ctx.reqBuf.B...)
uw.reqBuf, ctx.reqBuf.B = ctx.reqBuf.B, uw.reqBuf
common.ScheduleUnmarshalWork(uw)
return nil
}

View file

@ -34,7 +34,7 @@ func ParseStream(r io.Reader, defaultTimestamp int64, isGzipped bool, callback f
uw := getUnmarshalWork()
uw.callback = callback
uw.defaultTimestamp = defaultTimestamp
uw.reqBuf = append(uw.reqBuf[:0], ctx.reqBuf...)
uw.reqBuf, ctx.reqBuf = ctx.reqBuf, uw.reqBuf
common.ScheduleUnmarshalWork(uw)
}
return ctx.Error()

View file

@ -30,7 +30,7 @@ func ParseStream(req *http.Request, callback func(tss []prompb.TimeSeries) error
}
uw := getUnmarshalWork()
uw.callback = callback
uw.reqBuf = append(uw.reqBuf[:0], ctx.reqBuf.B...)
uw.reqBuf, ctx.reqBuf.B = ctx.reqBuf.B, uw.reqBuf
common.ScheduleUnmarshalWork(uw)
return nil
}

View file

@ -39,7 +39,7 @@ func ParseStream(req *http.Request, callback func(rows []Row) error) error {
for ctx.Read() {
uw := getUnmarshalWork()
uw.callback = callback
uw.reqBuf = append(uw.reqBuf[:0], ctx.reqBuf...)
uw.reqBuf, ctx.reqBuf = ctx.reqBuf, uw.reqBuf
common.ScheduleUnmarshalWork(uw)
}
return ctx.Error()