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

overall optimization #1269

Open
1 of 8 tasks
onur-ozkan opened this issue Apr 28, 2022 · 4 comments
Open
1 of 8 tasks

overall optimization #1269

onur-ozkan opened this issue Apr 28, 2022 · 4 comments
Assignees

Comments

@onur-ozkan
Copy link
Member

onur-ozkan commented Apr 28, 2022

Once #1247 is done, we should consider doing overall optimization around the project. Aim is simply decreasing the huge compilation time, and increasing runtime performance as much as possible.

Things should be considered:

  • remove un-needed functions
  • don't allocate memory for things that computer could recompute fast enough
  • update expensive algorithms to make it cheaper if possible
  • replace global allocator (consider jemalloc for UNIX systems with optimization tweaks)
  • Optimize data structures (prefer smallest possible data type for most cases) if possible
  • Consider caching on heavy operations if possible
  • Precompute/Preexecute things asynchronously if they don't need to be blocked by previous operations.
  • unify duplicated code (specially data-types re-defined for tests)
@tonymorony
Copy link

right now we are considering the switching to infrastructure providing for the some of the blockchain nodes

I did the following test:

  1. In CLI enabled BNB and one BNB-BEP20 token
  2. Left it run for some time

Right now it consume ~10 calls/minute in idle mode. Probably there is a room for optimisation (what might be a cost cut in case of such subscription service usage or infra loading cut in case of own nodes usage)

image

@artemii235
Copy link
Member

@ozkanonur That's a good idea in general, but I would like to highlight some topics from the list, that have higher priority than others:

  1. huge compilation time slows down the development, CI builds, etc. so it burns some of our development time. Worth fixing ASAP. I think you can do it along with Refactoring the project #1247 so I assigned this issue to you too 🙂
  2. Excessive 3rd party APIs calls @tonymorony mentioned also has to be fixed ASAP as it will incur additional costs to us and possibly to our users. Assigned to @caglaryucekaya.
  3. As per other topics: I think we have to focus first on code that can potentially become (or already became, like previous item) a bottleneck or can use less network traffic or RPS (requests or messages per second) than it uses now. During research on this issue, please pay more attention to orderbook sync protocol and atomic swap messages exchange. Messages size, how frequently they are sent, how much memory this data consumes and if it's cleaned up properly if not required etc.

artemii235 pushed a commit that referenced this issue Jun 27, 2022
* Run current balance loop only for coins with active maker orders

* Use OrdermatchContext for maker orders and increase balance request interval

* Stop balance loops if the maker order of the corresponding coin is cancelled

* Prevent multiple balance loops running for the same coin

* Fix WASM build problem

* Use parking lot mutex for balance loops and fix docker test problems

* Fix formatting problem

* remove unused imports

* Add MakerOrderContext in OrderMatchContext

* Fix OrdermatchContext initialization

* Fix Mutex lock usages

* Fix a wasm issue

* Use thread handles to stop balance loops

* Import spawn_abortable

* Fix format

* Add balance loops after adding maker orders

* Add further improvements

* Use String as spawn_balance_loop parameter
@artemii235
Copy link
Member

right now we are considering the switching to infrastructure providing for the some of the blockchain nodes
...
Right now it consume ~10 calls/minute in idle mode

@tonymorony this should be fixed in #1269, could you retest using dev branch, please?

@tonymorony
Copy link

performed same (as #1269 (comment)) test case today: activated BNB and 1 BEP20 token and left mm2 (without any orders) in idle mode for a day: calls to endpoint were executed only on activation event. So situation above is definitely looks fixed

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants