-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
getLogs perf improvements #1650
Conversation
CacheSnapshotHandler cacheSnapshotHandler = getRskSystemProperties().shouldPersistBloomsCacheSnapshot() | ||
? new CacheSnapshotHandler(resolveCacheSnapshotPath(bloomsStorePath)) | ||
: null; | ||
ds = new DataSourceWithCache(ds, bloomsCacheSize, cacheSnapshotHandler); |
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.
This construction 'leaks' the first datasource created at line 1183
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.
well, I would say it rather wraps it, same as it's being done in other places like 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.
hun, ok.
* Creates a block range by extract from/to values from {@code args}. | ||
*/ | ||
@Nonnull | ||
static Range makeBlockRange(@Nonnull String[] args, @Nonnull BlockStore blockStore) { |
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.
/* Thats elegant */
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)
c59bd08
to
f381f2c
Compare
Kudos, SonarCloud Quality Gate passed! |
pipeline:run |
f381f2c
to
95a2d4e
Compare
Kudos, SonarCloud Quality Gate passed! |
pipeline:run |
Description
This introduces some performance improvements to the
eth_getLogs
JSON-RPC method.To index block blooms which are not indexed yet, this PR adds a new cli tool -
IndexBlooms
. See motivation section for more details.Motivation and Context
The
eth_getLogs
JSON-RPC call consumes lots of resources, especially when it's triggered on a long block range to retrieve historical data. One way to improve this is to use blocks' bloom filters. Bloom filters are already part of each RSK block, but iterating over each block in a requested range is still time consuming operation, as it requires retrieving blocks from a db.To improve this some time ago there were introduced "combined" bloom filters for block batches (by default, each such batch has 64 blocks), so during the iteration process we can skip some block batches if their "combined" bloom doesn't fit our filter requirements. This can be thought as some form of indexing of block bloom filters. The node automatically index block batches that are being queried, so next time if blocks from same batches are queried again, their processing time should be lower.
Also the node already has a capability to auto-index blocks' blooms for new blocks that are being added to a chain from the network. But this feature is OFF by default. It can be enabled via this jvm flag -
-Dblooms.service=true
or via settingblooms.service
totrue
in the node's config.Besides existing capabilities for block blooms indexing, a new CLI tool is added -
IndexBlooms
- which allows to index in advance some specified block range. It can be triggered like thisfor entire chain or like this
for a specific range, in this case:
[1000..5000]
.One more way to seed up blooms index initialisation is to persist its cache snapshots (same as it was done here for states). This can be achieved by setting
persist-snapshot
totrue
in the config like this:or by providing the following cli arg:
-Dcache.blooms.persist-snapshot=true
, so, for example, the previous command for blooms indexing could look like the following:Pay attention that for this to take affect the node should also be started with the
-Dcache.blooms.persist-snapshot=true
flag (which is OFF by default) or with the appropriate config setting. It is also desirable to start the node with auto-indexing enabled. So the command could look like this:How Has This Been Tested?
Types of changes
Checklist: