Skip to content

Conversation

@natanasow
Copy link
Member

@natanasow natanasow commented Dec 4, 2025

Description

This PR implements a comprehensive logging performance optimization by replacing isLevelEnabled guards with Pino's interpolation values (printf-style formatting) across the codebase. The current implementation uses JavaScript string interpolation within conditional guards, which causes performance overhead by building log messages even when the corresponding log level is disabled.

Key improvements:

  • Performance: Eliminates string building overhead
  • Readability: Removes cluttered conditional logging statements, making code cleaner and more maintainable
  • Consistency: Standardizes logging approach using %s for string interpolation and %o for object interpolation
  • RPC Method Cleanup: Removes redundant trace logging

Related issue(s)

Fixes #4080

Testing Guide

Changes from original design (optional)

N/A

Additional work needed (optional)

N/A

Checklist

  • I've assigned an assignee to this PR and related issue(s) (if applicable)
  • I've assigned a label to this PR and related issue(s) (if applicable)
  • I've assigned a milestone to this PR and related issue(s) (if applicable)
  • I've updated documentation (code comments, README, etc. if applicable)
  • I've done sufficient testing (unit, integration, etc.)

Signed-off-by: nikolay <[email protected]>
@natanasow natanasow added this to the 0.74.0 milestone Dec 4, 2025
@natanasow natanasow self-assigned this Dec 4, 2025
@natanasow natanasow requested review from a team as code owners December 4, 2025 10:32
@natanasow natanasow added the enhancement New feature or request label Dec 4, 2025
@natanasow natanasow requested a review from acuarica December 4, 2025 10:32
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

Test Results

 20 files  ±0  277 suites  ±0   23m 7s ⏱️ +21s
805 tests ±0  801 ✅ +2  4 💤 ±0  0 ❌  - 2 
821 runs  ±0  817 ✅ +2  4 💤 ±0  0 ❌  - 2 

Results for commit 4517829. ± Comparison against base commit 14955e9.

♻️ This comment has been updated with latest results.

jasuwienas
jasuwienas previously approved these changes Dec 4, 2025
Copy link
Contributor

@jasuwienas jasuwienas left a comment

Choose a reason for hiding this comment

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

That's pretty straightforward! I wasn't sure whether we should use %s for an array, but it matches the current behavior where we inject the values directly into the string, so it's fine (${['']} === [''].toString()).

That said, these changes will heavily conflict with the work I did for the Redis refactor. (and which I didn't merge because of the newman issue): #4623

Perhaps we can leave the updates to RedisCache.ts out of this PR and handle them in a separate task? wdyt?

konstantinabl
konstantinabl previously approved these changes Dec 5, 2025
simzzz
simzzz previously approved these changes Dec 5, 2025
@natanasow natanasow dismissed stale reviews from simzzz, konstantinabl, and jasuwienas via 819aac1 December 8, 2025 08:03
simzzz
simzzz previously approved these changes Dec 8, 2025
…ing-interpolation-when-logging

# Conflicts:
#	packages/relay/src/lib/services/rateLimiterService/RedisRateLimitStore.ts
#	packages/relay/tests/lib/services/rateLimiterService/RedisRateLimitStore.spec.ts
Signed-off-by: nikolay <[email protected]>
simzzz
simzzz previously approved these changes Dec 9, 2025
Copy link
Contributor

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

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

Great work so far but I think many more guards can be removed or updated

…ing-interpolation-when-logging

# Conflicts:
#	packages/relay/src/lib/services/ethService/contractService/ContractService.ts
@natanasow
Copy link
Member Author

@quiet-node all comments were resolved, thank you for the feedback! 🙏

simzzz
simzzz previously approved these changes Dec 10, 2025
konstantinabl
konstantinabl previously approved these changes Dec 10, 2025
Signed-off-by: nikolay <[email protected]>
@natanasow natanasow dismissed stale reviews from konstantinabl and simzzz via 902b2f9 December 10, 2025 16:06
@github-actions
Copy link

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled should execute with PrestateTracer type and onlyTopCall option. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact
Cost: 37,700.8 ms

Heap Statistics (before vs after executing the test):

  • Total Heap Size: increased with 4.46 MB
  • Total Heap Size Executable: no changes
  • Total Physical Size: increased with 393.22 KB
  • Total Available Size: decreased with 899.65 KB
  • Total Global Handles Size: no changes
  • Used Global Handles Size: decreased with 32.00 bytes
  • Used Heap Size: decreased with 553.58 KB
  • 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):

  • New Space:

    • Space Size: increased with 4.19 MB
    • Space Used Size: decreased with 543.76 KB
    • Space Available Size: increased with 2.61 MB
    • Physical Space Size: increased with 131.07 KB
  • Old Space:

    • Space Size: increased with 262.14 KB
    • Space Used Size: decreased with 9.82 KB
    • Space Available Size: increased with 89.49 KB
    • Physical Space Size: increased with 262.14 KB

Recommendations

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

@github-actions
Copy link

🚨 Memory Leak Detected 🚨

A potential memory leak has been detected in the test titled should fail when debug API is not enabled. This may impact the application's performance and stability.

Details

📊 Memory Leak Detection Report 📊

GC Type: MarkSweepCompact
Cost: 34,020.6 ms

Heap Statistics (before vs after executing the test):

  • Total Heap Size: increased with 8.91 MB
  • Total Heap Size Executable: no changes
  • Total Physical Size: increased with 532.48 KB
  • Total Available Size: decreased with 10.11 MB
  • Total Global Handles Size: no changes
  • Used Global Handles Size: decreased with 32.00 bytes
  • Used Heap Size: decreased with 1.29 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):

  • New Space:

    • Space Size: increased with 8.39 MB
    • Space Used Size: decreased with 1.74 MB
    • Space Available Size: increased with 5.87 MB
    • Physical Space Size: increased with 8.19 KB
  • Old Space:

    • Space Size: increased with 524.29 KB
    • Space Used Size: increased with 455.68 KB
    • Space Available Size: decreased with 10.50 MB
    • Physical Space Size: increased with 524.29 KB
  • Large Object Space:

    • Space Size: increased with 184.32 KB
    • Space Used Size: increased with 179.61 KB
    • Space Available Size: no changes
    • Physical Space Size: increased with 184.32 KB

Recommendations

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

@simzzz simzzz self-requested a review December 10, 2025 16:35
simzzz
simzzz previously approved these changes Dec 10, 2025
Copy link
Contributor

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

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

LGTM Great work!

@natanasow natanasow merged commit 3f2f960 into main Dec 11, 2025
83 of 87 checks passed
@natanasow natanasow deleted the 4080-use-interpolation-values-instead-of-string-interpolation-when-logging branch December 11, 2025 08:11
@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

❌ Patch coverage is 85.51724% with 42 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/relay/src/lib/clients/sdkClient.ts 72.72% 15 Missing ⚠️
packages/relay/src/lib/clients/mirrorNodeClient.ts 82.35% 9 Missing ⚠️
...lay/src/lib/clients/cache/redisCache/redisCache.ts 80.00% 5 Missing ⚠️
...rvices/ethService/accountService/AccountService.ts 50.00% 4 Missing ⚠️
...ices/ethService/contractService/ContractService.ts 80.95% 4 Missing ⚠️
...vices/ethService/ethCommonService/CommonService.ts 55.55% 4 Missing ⚠️
...ackages/ws-server/src/metrics/connectionLimiter.ts 90.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #4679      +/-   ##
==========================================
+ Coverage   95.59%   95.84%   +0.25%     
==========================================
  Files         137      137              
  Lines       21475    21325     -150     
  Branches     1796     1718      -78     
==========================================
- Hits        20528    20439      -89     
+ Misses        929      866      -63     
- Partials       18       20       +2     
Flag Coverage Δ
config-service 98.85% <ø> (ø)
relay 92.71% <73.56%> (+1.33%) ⬆️
server 88.99% <ø> (ø)
ws-server 97.73% <96.55%> (+1.28%) ⬆️

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

Files with missing lines Coverage Δ
...kages/relay/src/lib/clients/cache/localLRUCache.ts 97.42% <100.00%> (-0.02%) ⬇️
...ay/src/lib/config/hbarSpendingPlanConfigService.ts 97.65% <100.00%> (+1.50%) ⬆️
...barLimiter/evmAddressHbarSpendingPlanRepository.ts 99.29% <100.00%> (+2.06%) ⬆️
...sitories/hbarLimiter/hbarSpendingPlanRepository.ts 100.00% <100.00%> (+2.40%) ⬆️
...hbarLimiter/ipAddressHbarSpendingPlanRepository.ts 98.48% <100.00%> (+5.73%) ⬆️
packages/relay/src/lib/debug.ts 99.21% <100.00%> (-0.17%) ⬇️
...es/relay/src/lib/dispatcher/rpcMethodDispatcher.ts 99.00% <100.00%> (ø)
packages/relay/src/lib/eth.ts 99.81% <100.00%> (+0.24%) ⬆️
packages/relay/src/lib/relay.ts 98.65% <100.00%> (ø)
...b/services/ethService/blockService/BlockService.ts 98.66% <100.00%> (+2.02%) ⬆️
... and 12 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Development

Successfully merging this pull request may close these issues.

Use "interpolation values" instead of string interpolation when logging

6 participants