Skip to content

Conversation

@AnotherRegularDude
Copy link
Member

Overview

  1. Certificate Hash Caching (8.3-8.7% improvement)
  • Implements SHA256 hash caching with compare_by_identity for SSL certificates
  • Avoids repeated expensive cryptographic operations
  1. URL Origin Caching (9.9-10.6% improvement)
  • Caches parsed URL origins to avoid repeated URI parsing
  • Some speedup for applications making multiple requests to the same domains
  1. Registry Structure Optimization
  • Replaces nested hash structure registry[origin][ssl_bucket] with flat compound keys
  • Simplifies lookups and reduces memory overhead
  1. Cleanup Interval Optimization (8.16% improvement)
  • Changes from immediate cleanup on every request to 60-second intervals
  • Reduces overhead while maintaining reasonable memory usage
  • Handle cases with time outed conns before triggered cleanup
  1. Update minimum supported Ruby version to: 3.1: https://www.ruby-lang.org/en/downloads/branches

Benchmarks

Look at bin/benchmark executable file.

============================================================
COMPARISON WITH MASTER
============================================================

Ssl certificate requests:
  requests with same SSL cert:
    Master:  88.84 i/s
    Current: 96.21 i/s
    Change:  8.3% 🚀 FASTER
  requests with different SSL certs:
    Master:  44.06 i/s
    Current: 47.89 i/s
    Change:  8.69% 🚀 FASTER

Multiple url requests:
  requests to same origin:
    Master:  90.9 i/s
    Current: 99.89 i/s
    Change:  9.9% 🚀 FASTER
  requests to different origins:
    Master:  57.27 i/s
    Current: 63.35 i/s
    Change:  10.62% 🚀 FASTER

Cleanup performance:
  frequent requests:
    Master:  133.72 i/s
    Current: 144.63 i/s
    Change:  8.16% 🚀 FASTER

Memory Usage:
  Total allocated bytes:
    Master:  4966980
    Current: 4761220
    Change:  -205760 bytes (-4.14%) ✅ BETTER
  Total retained bytes:
    Master:  18638
    Current: 18638
    Change:  0 bytes (0.0%) ❌ WORSE

@coveralls
Copy link

coveralls commented Jul 13, 2025

Pull Request Test Coverage Report for Build 16252854548

Details

  • 182 of 182 (100.0%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 15045884794: 0.0%
Covered Lines: 714
Relevant Lines: 714

💛 - Coveralls

@skirushkin skirushkin requested a review from tycooon July 15, 2025 07:21
# ... make some requests ...

# Close all persistent connections and clear caches
client.truncate!
Copy link
Member

Choose a reason for hiding this comment

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

А почему это называется truncate? Мб лучше как-то типа reset?


def get_origin(url)
HTTP::URI.parse(url).origin
origin_cache[url] ||= HTTP::URI.parse(url).origin
Copy link
Member

Choose a reason for hiding this comment

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

А если у меня урлы каждый раз будут разные (типа гет запросы с рандомным гуидом в урле) – память в итоге закончится?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants