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

EthService performance fix for AtomicReference update loops #775

Merged

Conversation

dmitry-worker
Copy link
Contributor

@dmitry-worker dmitry-worker commented Nov 4, 2020

Description

  1. updateAndGet() method used to remove obsolete hashes contains do{ map.filter() } while() nested loop and has overall O(n^2) complexity.
  2. mapValues should be avoided as its memory issue is fixed only in scala 2.13. Also, one shouldn't use mapValues if only values needed.
  3. AtomicReference is redundant, because compareAndSet-based method result (in p.1) is not used in code.

Proposed Solution

Remove updateAndGet to save CPU cycles, remove AtomicReference since all the changes in TrieMap are atomic.
Introduce TrieMap to handle concurrent writes and save memory spent on Map instances, that were created on each hashRate read request (with obsolete elements)

@dmitry-worker dmitry-worker changed the title Introduced TrieMap to simplify the code and to reduce cpu/memory usage EthService performance fix for AtomicReference update loops Nov 5, 2020
Copy link
Contributor

@mirkoAlic mirkoAlic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@mirkoAlic mirkoAlic merged commit 46d18e7 into input-output-hk:develop Nov 9, 2020
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.

2 participants