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

support the lambda.norpc tag on the go1.x runtime #456

Merged
merged 6 commits into from Jul 27, 2022
Merged

Conversation

bmoffatt
Copy link
Collaborator

Description of changes:

This enhances the -tags lambda.norpc build option to work on the go1.x runtime. Before it only worked on provided and provided.al2.

This also:

  • re-writes the invoke_loop.go code to more directly implement the RuntimeAPI, rather than having to shim through the function.go RPC layer. This makes it easier to build RuntimeAPI aware features without plumbing it through unused in the RPC version of the runtime. We might also consider in future making -tags lambda.norpc the default build mode, if we can later identify no other required use of the RPC server.
  • improves the throughput of large payload functions, by bypassing one layer of buffering within the RPC version of the runtime.

added some super simple benchmark script that can demonstrate a marginally improved throughput on the go1.x runtime

data:

~/aws-lambda-go/lambda/testdata
$ ./bench.sh
data payload for tests is: 4.1M	data.json
-rwxr-xr-x  1 moffattb  staff   8.3M Jul 25 16:05 handler
-rwxr-xr-x  1 moffattb  staff   6.5M Jul 25 16:05 handler_norpc
-------------------------------------------------
/Users/moffattb/aws-lambda-go/lambda/testdata/handler_norpc /var/task/bootstrap public.ecr.aws/lambda/provided:alami
-------------------------------------------------
5c9263fec4a2f0bc8adb8a5500e94bfa936d39cd132694f35c0ff285b89e055c
ensuring healthy function before starting test
{
  "hello": "world"
}
-------------------------------------------------
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done


Server Software:
Server Hostname:        localhost
Server Port:            9001

Document Path:          /2015-03-31/functions/function/invocations
Document Length:        3233123 bytes

Concurrency Level:      1
Time taken for tests:   16.849 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      323322000 bytes
Total body sent:        323329800
HTML transferred:       323312300 bytes
Requests per second:    5.94 [#/sec] (mean)
Time per request:       168.490 [ms] (mean)
Time per request:       168.490 [ms] (mean, across all concurrent requests)
Transfer rate:          18739.60 [Kbytes/sec] received
                        18740.06 kb/s sent
                        37479.66 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   148  168 103.5    156    1190
Waiting:       41   55  11.1     50     108
Total:        148  168 103.5    157    1191

Percentage of the requests served within a certain time (ms)
  50%    157
  66%    159
  75%    161
  80%    164
  90%    169
  95%    178
  98%    195
  99%   1191
 100%   1191 (longest request)
rie-bench
-------------------------------------------------
/Users/moffattb/aws-lambda-go/lambda/testdata/handler_norpc /var/runtime/bootstrap public.ecr.aws/lambda/go
-------------------------------------------------
b1e913ea3fcabf83f0c5db1e79dec0ed2cce585a8744b14d79afa29ee7ac71cd
ensuring healthy function before starting test
{
  "hello": "world"
}
-------------------------------------------------
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done


Server Software:
Server Hostname:        localhost
Server Port:            9001

Document Path:          /2015-03-31/functions/function/invocations
Document Length:        3233123 bytes

Concurrency Level:      1
Time taken for tests:   18.710 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      323322000 bytes
Total body sent:        323329800
HTML transferred:       323312300 bytes
Requests per second:    5.34 [#/sec] (mean)
Time per request:       187.104 [ms] (mean)
Time per request:       187.104 [ms] (mean, across all concurrent requests)
Transfer rate:          16875.29 [Kbytes/sec] received
                        16875.70 kb/s sent
                        33750.99 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   160  187 104.2    172    1201
Waiting:       46   63  14.8     56     120
Total:        160  187 104.2    172    1201

Percentage of the requests served within a certain time (ms)
  50%    172
  66%    175
  75%    179
  80%    182
  90%    194
  95%    209
  98%    335
  99%   1201
 100%   1201 (longest request)
rie-bench
-------------------------------------------------
/Users/moffattb/aws-lambda-go/lambda/testdata/handler /var/runtime/bootstrap public.ecr.aws/lambda/go
-------------------------------------------------
3fd903dcfc5450f476ac9bc7adfcd8673d2830389e10d3a71e4379e3e79100f0
ensuring healthy function before starting test
{
  "hello": "world"
}
-------------------------------------------------
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done


Server Software:
Server Hostname:        localhost
Server Port:            9001

Document Path:          /2015-03-31/functions/function/invocations
Document Length:        3233123 bytes

Concurrency Level:      1
Time taken for tests:   23.359 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      323322000 bytes
Total body sent:        323329800
HTML transferred:       323312300 bytes
Requests per second:    4.28 [#/sec] (mean)
Time per request:       233.594 [ms] (mean)
Time per request:       233.594 [ms] (mean, across all concurrent requests)
Transfer rate:          13516.78 [Kbytes/sec] received
                        13517.10 kb/s sent
                        27033.88 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   158  233 241.0    171    1194
Waiting:       55   88 145.1     63    1114
Total:        158  234 241.0    172    1194

Percentage of the requests served within a certain time (ms)
  50%    172
  66%    176
  75%    180
  80%    185
  90%    198
  95%   1176
  98%   1188
  99%   1194
 100%   1194 (longest request)
rie-bench

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-commenter
Copy link

codecov-commenter commented Jul 25, 2022

Codecov Report

Merging #456 (4aaa997) into main (6796528) will increase coverage by 1.82%.
The diff coverage is 87.50%.

@@            Coverage Diff             @@
##             main     #456      +/-   ##
==========================================
+ Coverage   72.90%   74.73%   +1.82%     
==========================================
  Files          19       18       -1     
  Lines        1085     1116      +31     
==========================================
+ Hits          791      834      +43     
+ Misses        225      216       -9     
+ Partials       69       66       -3     
Impacted Files Coverage Δ
lambda/entry.go 81.81% <ø> (+9.81%) ⬆️
lambda/rpc_function.go 79.10% <72.72%> (ø)
lambda/invoke_loop.go 89.42% <92.42%> (+15.73%) ⬆️
lambda/errors.go 87.09% <0.00%> (+9.67%) ⬆️

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 6796528...4aaa997. Read the comment docs.

@bmoffatt bmoffatt marked this pull request as ready for review July 26, 2022 00:11
@bmoffatt bmoffatt requested a review from carlzogh July 26, 2022 00:12
Copy link
Contributor

@carlzogh carlzogh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much cleaner, thanks!

@bmoffatt bmoffatt merged commit 8bc331d into aws:main Jul 27, 2022
@bmoffatt bmoffatt deleted the no-rpc branch August 21, 2022 05:10
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.

None yet

3 participants