-
Notifications
You must be signed in to change notification settings - Fork 175
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
Handle event encoding error gracefully (Port of 2562) #2565
Conversation
FVM Benchstat comparisonThis branch with compared with the base branch onflow:master commit 56d7658 The command Collapsed results for better readability
|
Codecov Report
@@ Coverage Diff @@
## master #2565 +/- ##
==========================================
- Coverage 55.59% 52.29% -3.31%
==========================================
Files 757 555 -202
Lines 69971 51648 -18323
==========================================
- Hits 38899 27008 -11891
+ Misses 27881 22422 -5459
+ Partials 3191 2218 -973
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
thanks for porting this change back
bors merge |
Build failed: |
# Conflicts: # fvm/transactionEnv.go
# Conflicts: # fvm/transactionEnv.go
bors merge |
Build failed: |
# Conflicts: # engine/execution/computation/computer/computer_test.go # fvm/errors/codes.go # fvm/errors/failures.go # fvm/handler/event.go # fvm/transactionEnv.go # fvm/transactionInvoker.go
Fix other tests
} | ||
} | ||
|
||
func (e *CadenceEventEncoder) Encode(event cadence.Event) ([]byte, 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.
just call return jsoncdc.Encode(event)
here? Since you end up resetting the buffer / copying the payload on each Encode call, there no benefit in pre-allocating a buffer / encoder.
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.
Reusing the buffer should give some speedeup, as resetting keeps underlaying bytes, but this seemed to be rather insignificant. So I did a benchmark and looks like there is quite a difference.
BenchmarkEncodingBuffer-16 1306316 949.6 ns/op
BenchmarkEncodingBuffer-16 1230076 944.8 ns/op
BenchmarkEncodingBuffer-16 1282364 941.2 ns/op
BenchmarkEncodingBuffer-16 1311118 900.7 ns/op
BenchmarkEncodingBufferV2-16 1468462 807.6 ns/op
BenchmarkEncodingBufferV2-16 1501274 821.0 ns/op
BenchmarkEncodingBufferV2-16 1456159 812.9 ns/op
BenchmarkEncodingBufferV2-16 1464187 818.2 ns/op
BenchmarkEncodingBufferV2-16 1410309 829.4 ns/op
PASS
ok github.com/onflow/flow-go/fvm/environment 20.927
V2 is the new version. I think difference would be even more visible for larger events.
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.
Looks good to me
Closes #2563 |
Originally this was a simple port, but it was unmerged for too long and I had to start from scratch.
I