Skip to content
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

Clean up and optimize http.batch(), fix batchPerHost #1259

Merged
merged 4 commits into from
Dec 10, 2019

Conversation

na--
Copy link
Member

@na-- na-- commented Dec 3, 2019

This removes unnecessary goroutine spawning, synchronization, type conversion, etc. I had to update goja because of dop251/goja#84, since I needed to refactor this:https://github.com/loadimpact/k6/blob/a2e1c6f4e6207d69461a1b0f24c3aa2c72233101/js/modules/k6/http/response.go#L36-L38

I also reduced the default batchPerHost value from 20 to 6, so k6 would be more in-line with browsers. Also, thanks to @mstoykov and #1264, the default value of batchPerHost now actually works.

Closes #767 and #967 (because of the goja update)

@na-- na-- added this to the v0.26.0 milestone Dec 3, 2019
@codecov-io
Copy link

codecov-io commented Dec 3, 2019

Codecov Report

Merging #1259 into master will increase coverage by 0.08%.
The diff coverage is 87.5%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1259      +/-   ##
=========================================
+ Coverage   75.31%   75.4%   +0.08%     
=========================================
  Files         149     150       +1     
  Lines       10844   10883      +39     
=========================================
+ Hits         8167    8206      +39     
  Misses       2211    2211              
  Partials      466     466
Impacted Files Coverage Δ
lib/limiter.go 100% <ø> (ø)
cmd/options.go 70.63% <100%> (+0.23%) ⬆️
lib/netext/httpext/batch.go 100% <100%> (ø)
js/modules/k6/http/response.go 76.63% <100%> (-0.43%) ⬇️
js/modules/k6/http/request.go 81.57% <81.13%> (+1.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2e1c6f...f950d67. Read the comment docs.

@na--
Copy link
Member Author

na-- commented Dec 4, 2019

I think a slight further optimization of this could be using a slice+atomic instead of a buffered channel, and using a double pointer instead of copying the response data

js/modules/k6/http/request.go Outdated Show resolved Hide resolved
js/modules/k6/http/request.go Show resolved Hide resolved
js/modules/k6/http/request.go Show resolved Hide resolved
lib/netext/httpext/batch.go Outdated Show resolved Hide resolved
lib/netext/httpext/batch.go Outdated Show resolved Hide resolved
@na-- na-- changed the title [WIP] Clean up and optimize http.batch() Clean up and optimize http.batch() Dec 6, 2019
@na-- na-- changed the title Clean up and optimize http.batch() Clean up and optimize http.batch(), fix batchPerHost Dec 6, 2019
This adds a minor breaking change - if some of the requests in the http.batch() fail, now the first error would be returned instead of the last one.
@na-- na-- merged commit 3de91a1 into master Dec 10, 2019
@na-- na-- deleted the make-batch-great-again branch December 10, 2019 08:35
mstoykov added a commit to grafana/k6-docs that referenced this pull request Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http.batch(array) result isn't an array
5 participants