Skip to content
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

Fix performance of coin balance history chart #3125

Merged
merged 8 commits into from
Jun 2, 2020

Conversation

vbaranov
Copy link
Member

@vbaranov vbaranov commented May 26, 2020

#1946

Changelog

Create a proper table to get data for coin balance history chart:

\d address_coin_balances_daily;
                    Table "public.address_coin_balances_daily"
    Column    |            Type             | Collation | Nullable |    Default
--------------+-----------------------------+-----------+----------+---------------
 address_hash | bytea                       |           | not null |
 day          | date                        |           | not null |
 value        | numeric(100,0)              |           |          | NULL::numeric
 inserted_at  | timestamp without time zone |           | not null |
 updated_at   | timestamp without time zone |           | not null |
Indexes:
    "address_coin_balances_daily_address_hash_day_index" UNIQUE, btree (address_hash, day)
Foreign-key constraints:
    "address_coin_balances_daily_address_hash_fkey" FOREIGN KEY (address_hash) REFERENCES addresses(hash)

and adding a logic of filling it with the data. Retrieve data for coin balance history chart from this table. After this PR, the number of days to display at the coin balance history chart can be configured via environment variable COIN_BALANCE_HISTORY_DAYS

Related PR to add COIN_BALANCE_HISTORY_DAYS env var to the list blockscout/docs#20

Checklist for your Pull Request (PR)

@vbaranov vbaranov force-pushed the vb-fix-performance-coin-balance-history-nnew-wave branch from e0643af to c21cdc9 Compare May 26, 2020 11:05
@coveralls
Copy link

coveralls commented May 26, 2020

Pull Request Test Coverage Report for Build e908e697-779e-4dca-a320-c85757576711

  • 114 of 135 (84.44%) changed or added relevant lines in 11 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.2%) to 75.155%

Changes Missing Coverage Covered Lines Changed/Added Lines %
apps/indexer/lib/indexer/block/realtime/fetcher.ex 10 11 90.91%
apps/indexer/lib/indexer/fetcher/coin_balance_on_demand.ex 12 13 92.31%
apps/explorer/lib/explorer/chain/import/runner/address/coin_balances_daily.ex 13 18 72.22%
apps/indexer/lib/indexer/transform/address_coin_balances_daily.ex 32 46 69.57%
Files with Coverage Reduction New Missed Lines %
apps/indexer/lib/indexer/fetcher/coin_balance_on_demand.ex 4 85.37%
Totals Coverage Status
Change from base Build 22318daf-e286-45a5-bab3-923eb1ed4ab4: 0.2%
Covered Lines: 5835
Relevant Lines: 7764

💛 - Coveralls

@vbaranov vbaranov force-pushed the vb-fix-performance-coin-balance-history-nnew-wave branch from c21cdc9 to 3af241b Compare May 26, 2020 11:15
@vbaranov vbaranov force-pushed the vb-fix-performance-coin-balance-history-nnew-wave branch from 3af241b to 14fbf27 Compare May 26, 2020 11:21
@vbaranov vbaranov force-pushed the vb-fix-performance-coin-balance-history-nnew-wave branch 13 times, most recently from 238b059 to a69c582 Compare May 29, 2020 12:31
@vbaranov vbaranov added the wip label May 29, 2020
@vbaranov vbaranov force-pushed the vb-fix-performance-coin-balance-history-nnew-wave branch 6 times, most recently from f0b6d1b to bb9e7bd Compare May 29, 2020 16:32
@leeoniya
Copy link

@vbaranov if you want to improve the frontend chart performance, too you can try using uPlot instead of Chart.js. Phoenix LiveDashboard uses uPlot for their real-time metrics panel.

/shameless plug :D

@vbaranov
Copy link
Member Author

vbaranov commented Jun 1, 2020

@leeoniya performance comparison of chart libraries looks promising! Definitely I should give it a try. Thanks for pointing me out.

@vbaranov vbaranov force-pushed the vb-fix-performance-coin-balance-history-nnew-wave branch 3 times, most recently from 3ca9697 to e27add4 Compare June 1, 2020 11:41
@vbaranov vbaranov force-pushed the vb-fix-performance-coin-balance-history-nnew-wave branch from e27add4 to c669359 Compare June 1, 2020 11:57
@vbaranov vbaranov removed the wip label Jun 2, 2020
@vbaranov vbaranov self-assigned this Jun 2, 2020
@vbaranov vbaranov merged commit 7019769 into master Jun 2, 2020
@vbaranov vbaranov deleted the vb-fix-performance-coin-balance-history-nnew-wave branch June 2, 2020 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants