-
Notifications
You must be signed in to change notification settings - Fork 502
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
services/horizon/internal/ingest: Remove unnecessary use of ChangeCompactor to reduce memory bloat during ingestion #5252
Conversation
d3399d1
to
3621cef
Compare
It's probably worth adding a comment to ChangeCompactor saying something like this, to prevent incorrect usage in future. |
services/horizon/internal/ingest/processors/account_data_processor.go
Outdated
Show resolved
Hide resolved
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, great write-up as well on problem/solution in pr description, left some minor comments for consideration.
PR Checklist
PR Structure
otherwise).
services/friendbot
, orall
ordoc
if the changes are broad or impact manypackages.
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
needed with deprecations, added features, breaking changes, and DB schema changes.
semver, or if it's mainly a patch change. The PR is targeted at the next
release branch if it's not a patch change.
What
Part of #5258
Horizon users have reported that state rebuilds have caused Horizon's memory usage to exceed 32 GB. After profiling Horizon we discovered that most memory is being retained in the
ChangeCompactor
:The
ChangeCompactor
is described in detail here https://github.com/stellar/go/blob/master/ingest/change_compactor.go#L49 . It turns out that there is no need to use theChangeCompactor
when ingesting from the history archives because all ledger entries changes obtained from the history archives are of the created type which means that we will never compact any ledger entries.By removing the
ChangeCompactor
from all the state processors we avoid creating additional copies of ledger entries obtained from the history archives. This has resulted in a substantial reduction in memory usage. Previously we used ~32 GB of RAM to do a state rebuild, now, we are able to do a state rebuild in ~5G:The only place where it makes sense to use a
ChangeCompactor
is when processing ledger entry changes extracted from aLedgerCloseMeta
payload. It is possible for a ledger entry to be created and then modified or removed within the same ledger.Known limitations
[N/A]