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

feat: add transactions.mempool.lockedTransactions and chainlocks.blockHeight stats #6237

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

PastaPastaPasta
Copy link
Member

Issue being fixed or feature implemented

Add basic lockedTransactions count and chain locked block height to stats

What was done?

How Has This Been Tested?

Will be tested once this has a docker image

Breaking Changes

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@PastaPastaPasta PastaPastaPasta added this to the 21.2 milestone Aug 28, 2024
@PastaPastaPasta PastaPastaPasta force-pushed the stats-add-basic-islock-clsig branch from 8f47ceb to ab3598b Compare August 28, 2024 17:15
@DashCoreAutoGuix
Copy link

Guix Automation has began to build this PR tagged as v21.1.0-devpr6237.ab3598b1. A new comment will be made when the image is pushed.

@DashCoreAutoGuix
Copy link

Guix Automation has completed; a release should be present here: https://github.com/dashpay/dash-dev-branches/releases/tag/v21.1.0-devpr6237.ab3598b1. The image should be on dockerhub soon.

@DashCoreAutoGuix
Copy link

Guix Automation has began to build this PR tagged as v21.1.0-devpr6237.763e4fcc. A new comment will be made when the image is pushed.

@DashCoreAutoGuix
Copy link

Guix Automation has completed; a release should be present here: https://github.com/dashpay/dash-dev-branches/releases/tag/v21.1.0-devpr6237.763e4fcc. The image should be on dockerhub soon.

@DashCoreAutoGuix
Copy link

Guix Automation has began to build this PR tagged as v21.1.0-devpr6237.63241c25. A new comment will be made when the image is pushed.

@DashCoreAutoGuix
Copy link

Guix Automation has completed; a release should be present here: https://github.com/dashpay/dash-dev-branches/releases/tag/v21.1.0-devpr6237.63241c25. The image should be on dockerhub soon.

src/validation.cpp Outdated Show resolved Hide resolved
@DashCoreAutoGuix
Copy link

Guix Automation has began to build this PR tagged as v21.1.0-devpr6237.2f26f788. A new comment will be made when the image is pushed.

@PastaPastaPasta
Copy link
Member Author

Applied

Comment on lines 794 to 787
auto time_diff = [&] () -> int64_t {
LOCK(cs_timingsTxSeen);
if (auto it = timingsTxSeen.find(islock->txid); it != timingsTxSeen.end()) {
// This is the normal case where we received the TX before the islock
return GetTimeMillis() - it->second;
}
// But if we received the islock and don't know when we got the tx, then say 0, to indicate we received the islock first.
return 0;
}();
statsClient.timing("islock_ms", time_diff);
Copy link
Member Author

Choose a reason for hiding this comment

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

any concerns about doing this here? kinda concerned about potential performance implications doing this in this thread. Any thoughts?

Copy link

Choose a reason for hiding this comment

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

should be ok imo

@DashCoreAutoGuix
Copy link

Guix Automation has completed; a release should be present here: https://github.com/dashpay/dash-dev-branches/releases/tag/v21.1.0-devpr6237.2f26f788. The image should be on dockerhub soon.

@UdjinM6
Copy link

UdjinM6 commented Sep 10, 2024

pls see 7aa0a48 + clang format is complaining

PastaPastaPasta added a commit that referenced this pull request Sep 11, 2024
4faf35f chore: add `stats` as a pull request header scope (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  Would allow tagging #5167, #6267 and #6237 as `feat(stats)`.

  ## Breaking Changes

  None.

  ## Checklist:

  - [x] I have performed a self-review of my own code **(note: N/A)**
  - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)**
  - [x] I have added or updated relevant unit/integration/functional/e2e tests **(note: N/A)**
  - [x] I have made corresponding changes to the documentation **(note: N/A)**
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ **(note: N/A)**

ACKs for top commit:
  PastaPastaPasta:
    utACK 4faf35f
  UdjinM6:
    utACK 4faf35f
  thephez:
    utACK 4faf35f

Tree-SHA512: 25cc28792351852b9e920d980b8814d93274bc53d22ce63fb1a5bf32821b10902d22b384a408e1c4a7b97239e53e235c45ac008d0f82e1afe5d6071b392acb47
Copy link

This pull request has conflicts, please rebase.

@UdjinM6 UdjinM6 removed this from the 21.2 milestone Oct 29, 2024
@@ -254,6 +254,9 @@ class CInstantSendManager : public CRecoveredSigsListener
mutable Mutex cs_pendingRetry;
std::unordered_set<uint256, StaticSaltedHasher> pendingRetryTxs GUARDED_BY(cs_pendingRetry);

mutable Mutex cs_timingsTxSeen;
std::unordered_map<uint256, int64_t, StaticSaltedHasher> timingsTxSeen GUARDED_BY(cs_timingsTxSeen);
Copy link
Collaborator

Choose a reason for hiding this comment

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

it seems as this map can indefinitely grow and eat all significant amount of RAM

Comment on lines +1198 to +1185
if (auto it = timingsTxSeen.find(tx->GetHash()); it == timingsTxSeen.end()) {
timingsTxSeen[tx->GetHash()] = GetTimeMillis();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's avoid double lookup on map here:

Suggested change
if (auto it = timingsTxSeen.find(tx->GetHash()); it == timingsTxSeen.end()) {
timingsTxSeen[tx->GetHash()] = GetTimeMillis();
}
timingsTxSeen.try_emplace(tx->GetHash(), GetTimeMillis());

emplace() and try_emplace() are similar, but difference in performance - one is expecting success by default, other is expecting failure by default

Copy link
Collaborator

Choose a reason for hiding this comment

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

proof that it works:

$ cat a.cpp 
#include <iostream>
#include <unordered_map>

using namespace std;

int main() {
    unordered_map<int, int> m;
    if (m.try_emplace(2, 3).second) cout << "OK" << endl; else cout << "FAIL" << endl;
    if (m.try_emplace(3, 4).second) cout << "OK" << endl; else cout << "FAIL" << endl;
    if (m.try_emplace(2, 5).second) cout << "OK" << endl; else cout << "FAIL" << endl;
    for (auto i : m) {
        cout << i.first << ' ' << i.second << endl;
    }
}
$ ./a 
OK
OK
FAIL
3 4
2 3

@DashCoreAutoGuix
Copy link

Guix Automation has began to build this PR tagged as v22.1.0-devpr6237.3e524228. A new comment will be made when the image is pushed.

@DashCoreAutoGuix
Copy link

Guix Automation has completed; a release should be present here: https://github.com/dashpay/dash-dev-branches/releases/tag/v22.1.0-devpr6237.3e524228. The image should be on dockerhub soon.

@DashCoreAutoGuix
Copy link

Guix Automation has began to build this PR tagged as v22.1.0-devpr6237.35745503. A new comment will be made when the image is pushed.

@DashCoreAutoGuix
Copy link

Guix Automation has completed; a release should be present here: https://github.com/dashpay/dash-dev-branches/releases/tag/v22.1.0-devpr6237.35745503. The image should be on dockerhub soon.

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

Successfully merging this pull request may close these issues.

4 participants