Performance optimization: zero GenServer.call hot path, pluggable strategies, CI/CD#5
Merged
Merged
Conversation
…rver.call hot path - Rewrite hot path to use ETS + atomics instead of Registry.lookup + GenServer.call - Add pluggable connection strategies: round_robin, random, power_of_two - Add PoolState GenServer for ETS ownership and persistent_term setup - Add TelemetryReporter GenServer replacing recursive timer.sleep loop - Add await_ready/2 for startup readiness signaling - Add max_reconnect_attempts config replacing crash_after_reconnect_attempt - Add stale scaling lock detection (30s timeout) - Add Benchee benchmarks (bench/get_channel_bench.exs) - Add GitHub Actions CI/CD with auto-publish to Hex on v* tag - Update README with strategies docs, architecture diagram, benchmarks - Update CHANGELOG with v0.3.0 entry - Bump version to 0.3.0
- Fix alias ordering (alphabetical) in pool, worker, tests - Replace explicit try with implicit try in config, pool, worker - Extract scale_down helpers to reduce cyclomatic complexity - Extract release_slot helper to reduce nesting depth - Fix number underscore style (50051 -> 50_051) in tests - All credo --strict clean, dialyzer passes with 0 errors
PLT files are machine-specific and should be generated locally or cached in CI. Fixes dialyzer failure on GitHub Actions.
Wait for worker to be idle (GenServer.call) before sending second disconnect message, instead of a fixed sleep. The worker blocks in GRPC.Stub.connect (~5s timeout) and can't process messages during that time. Also increase max_reconnect_attempts in test config to prevent worker from crashing before the test completes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lock-free atomics round-robin.
(least-recently-used tiebreak). Custom strategies supported.
crash_after_reconnect_attempt replaced with max_reconnect_attempts, ETS concurrency flags added.
Benchmark Results
┌───────────────────────┬───────────┬───────────┬─────────────┐
│ Metric │ v0.2.x │ v0.3.0 │ Improvement │
├───────────────────────┼───────────┼───────────┼─────────────┤
│ get_channel (pool=5) │ 473K ips │ 2.03M ips │ 4.3x faster │
├───────────────────────┼───────────┼───────────┼─────────────┤
│ get_channel (pool=25) │ 343K ips │ 1.99M ips │ 5.8x faster │
├───────────────────────┼───────────┼───────────┼─────────────┤
│ 100 concurrent p99 │ 1,035 μs │ 439 μs │ 58% lower │
├───────────────────────┼───────────┼───────────┼─────────────┤
│ Memory/call (pool=25) │ 1.65 KB │ 0.72 KB │ 56% less │
├───────────────────────┼───────────┼───────────┼─────────────┤
│ Pool.status │ 1.47M ips │ 3.71M ips │ 2.5x faster │
└───────────────────────┴───────────┴───────────┴─────────────┘
Pool size scaling: pool=25 was 38% slower than pool=5 in v0.2.x — now only 2% slower (O(n) eliminated).
Test Plan