-
Notifications
You must be signed in to change notification settings - Fork 413
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
Stream lambda function compiler responses #1340
Conversation
I like this idea! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small doubt regarding handling a JSON.parse potential error
services/server/src/server/services/compiler/lambda/SolcLambda.ts
Outdated
Show resolved
Hide resolved
forceEmscripten | ||
); | ||
} catch (e) { | ||
logger.error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that here we need to run local compilation only on the specific "too big output" error not all the errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I pushed the new commit before I saw your comment update)
The problem with this is that I cannot really find out which error code is given by AWS in the case the response is too big. I was checking the docs and they were not very helpful (https://docs.aws.amazon.com/lambda/latest/api/API_InvokeWithResponseStreamCompleteEvent.html).
We could also try to find a contract whose compiler output is bigger than the response stream limit of 20 MB. I'm just not sure how to go about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking... Maybe on the lambda side you can find the output size and if it's more than 20mb send a specific response. Could this work?
Continues here: #1340 (comment)
serverless/compiler-lambda/index.js
Outdated
}; | ||
console.debug("Compilation output: ", output); | ||
|
||
const outputBlob = new Blob([JSON.stringify(output)]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Continuing this comment: #1340 (comment)
like this:
if (weight(outputBlob) > 20MB ) {
output = { error: "specific error for this case" }
return or throw
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice idea! That should work out! Thanks for the hint
… to the stream response limit
8348703
to
08f8d8f
Compare
...ices/server/src/server/services/compiler/lambda-with-fallback/SolcLambdaWithLocalFallback.ts
Outdated
Show resolved
Hide resolved
I added the version identifiers to the environment configurations. This change will break the running staging and production deployments if the lambda function is not updated at the same time as these changes are merged. In the future, the versioning will prevent this, meaning that we can deploy a new lambda function and later just increment the version in the configuration. In summary, we need to do the following:
|
I created a dashboard for visualizing the number of times the fallback to local compilation is invoked (the dashboard is empty since the changes are not released yet). I expect that this fallback will be barely used, but let's see in Grafana. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍
* Stream lambda function compiler responses * Log parsing errors from Lambda response * Fallback to local compilation if compilation with lambda function fails * Only fallback to local compilation when lambda compilation failed due to the stream response limit * SolcLambdaWithLocalFallback: log a warning instead of an error * Add version identifiers to lambda function names
See #1326
I didn't implement any chunking myself. Instead I used the
pipeline
function because the docs recommend to do so. AWS'sresponseStream
will just take care of chunking it.Note that that streamed responses also have a limit of 20 MB (usual payload response was 6 MB). Maybe it could make sense to fallback to local compilation if an error is received from the lambda function?
TODO: