-
Notifications
You must be signed in to change notification settings - Fork 20.1k
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
core/rawdb: avoid unnecessary receipt processing for log filtering #23147
Conversation
To see how these types are used refer here: s1na#5 |
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.
LGTM
To estimate how effective the triage suggestion #23058 (comment) would be I added 2 metrics in #23520 which show us how often we lookup a block with zero matching logs and it seems to happen in ~1% of cases. That means we can avoid reading block body from db in 1% of cases by filtering deeper in the stack. |
1c41fba
to
b82b409
Compare
I did a hacky implementation of the optimization in s1na@7fd9ac9 and measured the time for a few contracts/events (see script). The script sends many subsequent The right-side chart is the mean time for responding to a request and left-side is the mean time for processing one matching block within a request. I stopped the node twice and changed branches:
Something interesting I hadn't noticed is why the response time is increasing over time (I used to test with lower number of requests) |
for i, receipt := range receipts { | ||
logs[i] = receipt.Logs | ||
logs := rawdb.ReadLogs(db, hash, *number) | ||
if logs == nil { |
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 would prefer ReadLogs to return an error instead of relying on logs to be non nil 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.
I hear you. just didn't return an error to be consistent with the rest of the accessors
Added a benchmark to compare decoding a stored receipt the normal way (via
|
Benchmark is wrong -- you need to do the work exactly b.N times
|
Thanks for the catch. Here are the updated result:
|
|
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.
LGTM
"faster is better"
Oh no needs a rebase |
b16ef5c
to
7edca90
Compare
@holiman I rebased. Just a reminder that this PR only has Optim1. Didn't want to make it too big by including Optim2 as well |
7edca90
to
80cf4ee
Compare
This is a successor for #23058. In this PR, the new lightweight
receiptLogs
type has been instead moved to rawdb and made private.