pocketnetteam / pocketnet.core

Decentralized social network based on the blockchain
https://pocketnet.app
Apache License 2.0
114 stars 28 forks source link

Basic code optimizations #192

Open lostystyg opened 2 years ago

lostystyg commented 2 years ago

I suggest fill this issue with basic code optimization suggestions (performance and engineering) that are non-critical but could make code more correct.

tawmaz commented 2 years ago

This is more of a code cleanup task, but there are a lot of conditionals in the code that are only relevant for older pre-2018 bitcoin releases which could be removed to simplify the code and improve performance slightly because pocketnet will never hit those code cases.

andyoknen commented 2 years ago

I would suggest that each participant make edits to the code without much regard for the team - every change will be reviewed anyway. Here we could post discussion links if needed.

andyoknen commented 2 years ago

The following functions are very generalized, although they do not make sense - only a few fields can be used in finite functions, or even just the fact of the presence/absence of an entry in the database. Refactoring is needed.

https://github.com/pocketnetteam/pocketnet.core/blob/0.20/src/pocketdb/repositories/ConsensusRepository.h ConsensusRepository::GetFirstContent ConsensusRepository::GetLastContent

andyoknen commented 2 years ago
2022-05-05T18:46:13Z SQL Bench `GetFullCommentInfo`: 2719.12ms
2022-05-05T18:46:13Z SQL Bench `ExistsBlock`: 2716.11ms
2022-05-05T18:46:17Z SQL Bench `GetFullCommentInfo`: 1982.23ms
2022-05-05T18:46:17Z SQL Bench `GetScoreData`: 1874.62ms
2022-05-05T18:46:35Z SQL Bench `GetFullCommentInfo`: 7081.30ms
2022-05-05T18:46:35Z SQL Bench `GetScoreData`: 7081.30ms
2022-05-05T18:46:47Z SQL Bench `GetFullCommentInfo`: 2218.72ms
2022-05-05T18:46:47Z SQL Bench `GetScoreData`: 2218.72ms
2022-05-05T18:46:52Z SQL Bench `GetFullCommentInfo`: 4884.91ms
2022-05-05T18:46:52Z SQL Bench `GetAccountData`: 4884.91ms
2022-05-05T18:46:57Z SQL Bench `GetSubscribeAddressTo`: 4956.56ms
2022-05-05T18:46:57Z SQL Bench `GetScoreContentCount`: 5125.57ms
2022-05-05T18:47:02Z SQL Bench `GetFullCommentInfo`: 3856.03ms
2022-05-05T18:47:02Z SQL Bench `GetAccountRegistrationTime`: 3854.04ms
2022-05-05T18:47:08Z SQL Bench `GetFullCommentInfo`: 3413.41ms
2022-05-05T18:47:08Z SQL Bench `GetAccountRegistrationTime`: 3413.41ms
2022-05-05T18:47:14Z SQL Bench `GetFullCommentInfo`: 6887.79ms
2022-05-05T18:47:14Z SQL Bench `GetReferrer`: 6887.79ms
2022-05-05T18:47:18Z SQL Bench `GetFullCommentInfo`: 4027.37ms
2022-05-05T18:47:18Z SQL Bench `GetScoreData`: 4027.37ms
2022-05-05T18:47:24Z SQL Bench `GetFullCommentInfo`: 5086.89ms
2022-05-05T18:47:24Z SQL Bench `GetAccountData`: 5086.89ms
2022-05-05T18:47:30Z SQL Bench `GetFullCommentInfo`: 6875.27ms
2022-05-05T18:47:30Z SQL Bench `GetScoreData`: 6875.27ms
2022-05-05T18:47:38Z SQL Bench `GetFullCommentInfo`: 7171.60ms
2022-05-05T18:47:38Z SQL Bench `GetAccountData`: 7171.60ms
2022-05-05T18:47:48Z SQL Bench `GetFullCommentInfo`: 9937.40ms
2022-05-05T18:47:48Z SQL Bench `GetScoreData`: 9937.40ms
2022-05-05T18:48:00Z SQL Bench `GetSubscribeAddressTo`: 2078.49ms
2022-05-05T18:48:00Z SQL Bench `GetScoreData`: 2078.49ms
2022-05-05T18:48:02Z SQL Bench `GetSubscribeAddressTo`: 1889.56ms
2022-05-05T18:48:02Z SQL Bench `GetAccountData`: 1889.56ms
2022-05-05T18:48:05Z SQL Bench `GetSubscribeAddressTo`: 2577.55ms
2022-05-05T18:48:05Z SQL Bench `GetScoreData`: 2577.55ms
2022-05-05T18:48:09Z SQL Bench `GetSubscribeAddressTo`: 4154.73ms
2022-05-05T18:48:09Z SQL Bench `GetAccountData`: 4154.73ms
2022-05-05T18:48:11Z SQL Bench `GetFullCommentInfo`: 1662.64ms
2022-05-05T18:48:11Z SQL Bench `GetScoreContentCount`: 1849.99ms