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

chore: add active users counter per rate limiter duration #3150

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nadezhdapopovaa
Copy link
Contributor

@nadezhdapopovaa nadezhdapopovaa commented Oct 23, 2024

Description:
Add counter for active users based on the rate limiter duration period.

Related issue(s):

Fixes #3151

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Copy link

github-actions bot commented Oct 23, 2024

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled validates enforcement of request id. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact
Cost: 27,888 ms

Heap Statistics (before vs after executing the test):

  • Total Heap Size: increased with 1.46 MB
  • Total Heap Size Executable: no changes
  • Total Physical Size: decreased with 348.16 KB
  • Total Available Size: decreased with 4.20 MB
  • Total Global Handles Size: no changes
  • Used Global Handles Size: decreased with 64.00 bytes
  • Used Heap Size: decreased with 3.44 MB
  • Heap Size Limit: no changes
  • Malloced Memory: no changes
  • External Memory: no changes
  • Peak Malloced Memory: no changes

Heap Space Statistics (before vs after executing the test):

  • Old Space:

    • Space Size: increased with 1.84 MB
    • Space Used Size: increased with 2.08 MB
    • Space Available Size: decreased with 7.09 MB
    • Physical Space Size: increased with 1.84 MB
  • Large Object Space:

    • Space Size: increased with 835.58 KB
    • Space Used Size: increased with 813.50 KB
    • Space Available Size: no changes
    • Physical Space Size: increased with 835.58 KB

Recommendations

Please investigate the memory allocations in this test, focusing on objects that are not being properly deallocated.

Copy link

github-actions bot commented Oct 23, 2024

Test Results

 17 files   -   4  229 suites   - 48   29m 25s ⏱️ - 4m 14s
603 tests  -   2  599 ✅ +  3  4 💤 ±0  0 ❌  - 5 
619 runs   - 251  615 ✅  - 245  4 💤  - 1  0 ❌  - 5 

Results for commit 9ae5db5. ± Comparison against base commit ca044f1.

This pull request removes 2 tests.
"before all" hook in "@precompile-calls Tests for eth_call with HTS" ‑ RPC Server Acceptance Tests Acceptance tests @precompile-calls Tests for eth_call with HTS "before all" hook in "@precompile-calls Tests for eth_call with HTS"
"before each" hook for "should execute "eth_getStorageAt" request to get old state with passing specific block" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests "before each" hook for "should execute "eth_getStorageAt" request to get old state with passing specific block"

♻️ This comment has been updated with latest results.

@nadezhdapopovaa nadezhdapopovaa force-pushed the 3109-hbar-rate-limit-redesign-add-a-counter-to-expose-dau-metrics branch from c40af15 to 9c52deb Compare October 24, 2024 09:37
@nadezhdapopovaa nadezhdapopovaa self-assigned this Oct 24, 2024
@nadezhdapopovaa nadezhdapopovaa added the enhancement New feature or request label Oct 24, 2024
@nadezhdapopovaa nadezhdapopovaa added this to the 0.59.0 milestone Oct 24, 2024
natanasow
natanasow previously approved these changes Oct 24, 2024
Copy link
Collaborator

@natanasow natanasow left a comment

Choose a reason for hiding this comment

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

LGTM

@nadezhdapopovaa nadezhdapopovaa marked this pull request as ready for review October 25, 2024 15:02
Copy link
Collaborator

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

Good change but not sure it's at the right level and might have side effects

this.register.removeSingleMetric(activeUsersPerLimitPeriodCounterName);
this.activeUsersPerLimitPeriodCounter = new Counter({
name: activeUsersPerLimitPeriodCounterName,
help: 'Relay Hbar rate limiter active users counter',
Copy link
Collaborator

Choose a reason for hiding this comment

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

note this isn't specific to the spending plan.
This should be in general, it just happens that eth_sendRawTransaction and others might spend hBAR.
Does have it in the spending plan mean we'd miss calls that don't spend HBAR.
Maybe this should be placed higher up in the server?

* @private
*/
private resetActiveUsers(): void {
this.activeUsersPerLimitPeriodCounter.reset();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we should be resetting in code.
Shouldn't we be able to group this within the metric collection tool e.g. Grafana
For instance if the duration is not 24hrs the intent breaks

@ebadiere ebadiere modified the milestones: 0.59.0, 0.60.0 Oct 30, 2024
@nadezhdapopovaa nadezhdapopovaa force-pushed the 3109-hbar-rate-limit-redesign-add-a-counter-to-expose-dau-metrics branch from 9c52deb to 540fdca Compare November 5, 2024 14:14
@nadezhdapopovaa nadezhdapopovaa force-pushed the 3109-hbar-rate-limit-redesign-add-a-counter-to-expose-dau-metrics branch from 540fdca to 9ae5db5 Compare November 5, 2024 14:40
Copy link

sonarcloud bot commented Nov 5, 2024

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 83.09%. Comparing base (ca044f1) to head (9ae5db5).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
packages/server/src/server.ts 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3150      +/-   ##
==========================================
- Coverage   83.11%   83.09%   -0.03%     
==========================================
  Files          66       66              
  Lines        4312     4317       +5     
  Branches      843      845       +2     
==========================================
+ Hits         3584     3587       +3     
- Misses        485      486       +1     
- Partials      243      244       +1     
Flag Coverage Δ
config-service 98.14% <ø> (ø)
relay 85.23% <ø> (ø)
server 83.35% <66.66%> (-0.18%) ⬇️
ws-server 36.87% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/server/src/server.ts 71.05% <66.66%> (-0.22%) ⬇️

Copy link
Collaborator

@ebadiere ebadiere left a comment

Choose a reason for hiding this comment

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

Is there a way to have this managed by the metrics service?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
4 participants