• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TykTechnologies / tyk / 3187

Build:
DEFAULT BRANCH: master
Ran 06 Oct 2017 02:20PM UTC
Jobs 1
Files 84
Run time 4s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
3187

push

travis-ci

buger
proxy: avoid copying bodies multiple times

When we copy a request or response's body, we replace both results'
bodies with a NopCloser around a bytes.Buffer. We do this to be able to
read it multiple times from different places at different times.
However, once we put it in a bytes.Buffer once, it's already in memory
and doing the same again is useless.

Instead, buffer only once, and simply re-use a shallow copy of
bytes.Buffer from there on. This is enough, since it will make a copy of
the read offset yet share the same underlying buffer.

There is no indication that this is a bottleneck, but it's an easy win
and we do call copyRequest and copyResponse multiple times in the
codebase.

Benchmark of copying a request and response 10 times each, before and
after:

name                   old time/op    new time/op    delta
CopyRequestResponse-4     168µs ± 0%      26µs ± 1%  -84.39%  (p=0.004 n=5+6)

name                   old alloc/op   new alloc/op   delta
CopyRequestResponse-4     296kB ± 0%      36kB ± 0%  -87.98%  (p=0.000 n=5+6)

name                   old allocs/op  new allocs/op  delta
CopyRequestResponse-4       184 ± 0%        76 ± 0%  -58.70%  (p=0.002 n=6+6)

6144 of 13311 relevant lines covered (46.16%)

0.5 hits per line

Jobs
ID Job ID Ran Files Coverage
2 3187.2 (LATEST_GO=true) 06 Oct 2017 02:20PM UTC 0
46.16
Travis Job 3187.2
Source Files on build 3187
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #3187
  • 51b05b9d on github
  • Prev Build on master (#3186)
  • Next Build on master (#3188)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc