-
Notifications
You must be signed in to change notification settings - Fork 499
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
Feature flag to disable asset stats #668
Conversation
Right now it's updating stats every time a ledger is ingested, this PR makes it never update. What I would suggest then as it's a very similar change (code wise) is to change this from a boolean to an update period (default is 1 = updated every ledger close): that way we would make the SDF public nodes expose the endpoint but only update every 120 ledgers (10 minutes) for example. What do you think? |
This is one of the ideas I had too but it will still trigger high CPU load every X minutes this time possibly causing longer delays as list of assets to check grows bigger. And it still involves a big rearchitecture of the system. Currently every I propose the following solution:
|
Oh I see, I thought the cost of running was pretty much fixed cost. This seems fine then. I'll let other @stellar/platform-committers merge. |
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
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.
some thoughts on how to amortize the cost over N ledgers for a future PR:
-
if you write the list of modified assets to a db table ever ledger, there will be many overwrites because of repeats (which is good). This will effectively reduce the average number of assets needed to be calculated on a per-ledger basis, thereby amortizing the cost (because of the repeats).
-
you can have a background thread that looks at this table, copies over the first K values to a new table (to unblock insertions from the main ingestion thread), and then recomputes these K values. This will ensure we keep the cost fixed to a max of K values and the insertion table will also contain dates so assets are not "out of sync" for too long.
-
params N and K should be configurable, as indicated in the comments above.
Asset stats calculations have become very CPU intensive with the recent growth of operations per ledger and assets in, both, public and test networks. Because it's part of the ingestion session it sometimes caused delays in ingesting new ledgers but also slows down connected stellar-core DB (calculations are done in core DB).
The original plan I discussed with @MonsieurNicolas was to extract asset stats calculations outside ingestion and make it run every X seconds, independently of ingestion. The problem is that it's a huge architectural change and requires much more work than I expected to make it right and test it properly. Given all the arguments above and the fact that it's already causing operational issues for some organizations I think we should design it along with the upcoming big architectural change in Horizon and
ingest
package and have a quickfix now.This PR introduces a feature flag that can be set using environment variable or command line param. When
DISABLE_ASSET_STATS=true
assets stats calculation are turned off during ingestion and/assets
endpoint is not present. This is not a breaking change as the default value isfalse
. It can be released in 0.14.1 patch release.