redis-rb / redis-cluster-client

Redis cluster-aware client for Ruby
https://rubygems.org/gems/redis-cluster-client
MIT License
21 stars 9 forks source link

perf: lessen memory consumptions in a emulated mget method #360

Closed supercaracal closed 7 months ago

supercaracal commented 7 months ago

Before

allocated memory by gem
-----------------------------------
   5506464  redis-client-0.22.1
    435368  redis-cluster-client/lib
     70110  socket
     10672  uri
      1072  other
allocated memory by location
-----------------------------------
   1640720  redis-client-0.22.1/lib/redis_client/ruby_connection/resp3.rb:99
   1027840  redis-client-0.22.1/lib/redis_client/ruby_connection/resp3.rb:54
    976160  redis-client-0.22.1/lib/redis_client/command_builder.rb:9
    788688  redis-client-0.22.1/lib/redis_client/ruby_connection/resp3.rb:189
    488440  redis-client-0.22.1/lib/redis_client/ruby_connection/resp3.rb:38
    187440  redis-client-0.22.1/lib/redis_client/ruby_connection/buffered_io.rb:32
    175840  redis-client-0.22.1/lib/redis_client/ruby_connection/resp3.rb:175
    160000  redis-cluster-client/lib/redis_client/cluster/key_slot_converter.rb:71
    146440  redis-client-0.22.1/lib/redis_client/ruby_connection/buffered_io.rb:39
     75160  redis-cluster-client/lib/redis_client/cluster/command.rb:53
     66512  redis-cluster-client/lib/redis_client/cluster/node.rb:53
     57918  ruby/lib/socket.rb:457
     40440  redis-client-0.22.1/lib/redis_client/ruby_connection/resp3.rb:69
     40000  redis-cluster-client/lib/redis_client/cluster.rb:34
     16548  redis-client-0.22.1/lib/redis_client/ruby_connection/buffered_io.rb:18
     11520  redis-cluster-client/lib/redis_client/cluster/node.rb:346
     11232  redis-cluster-client/lib/redis_client/cluster/node.rb:359
      9920  ruby/lib/socket.rb:231
      7328  redis-cluster-client/lib/redis_client/cluster/command.rb:50
      7208  redis-cluster-client/lib/redis_client/cluster/node/base_topology.rb:55

After

allocated memory by gem
-----------------------------------
   5541520  redis-client-0.22.1
    355368  redis-cluster-client/lib
     77295  socket
     10672  uri
      1072  other
allocated memory by location
-----------------------------------
   1640800  redis-client-0.22.1/lib/redis_client/ruby_connection/resp3.rb:99
   1028320  redis-client-0.22.1/lib/redis_client/ruby_connection/resp3.rb:54
    976160  redis-client-0.22.1/lib/redis_client/command_builder.rb:9
    788728  redis-client-0.22.1/lib/redis_client/ruby_connection/resp3.rb:189
    488480  redis-client-0.22.1/lib/redis_client/ruby_connection/resp3.rb:38
    187520  redis-client-0.22.1/lib/redis_client/ruby_connection/buffered_io.rb:32
    176000  redis-client-0.22.1/lib/redis_client/ruby_connection/resp3.rb:175
    146880  redis-client-0.22.1/lib/redis_client/ruby_connection/buffered_io.rb:39
     80000  redis-cluster-client/lib/redis_client/cluster/key_slot_converter.rb:71
     75160  redis-cluster-client/lib/redis_client/cluster/command.rb:53
     66512  redis-cluster-client/lib/redis_client/cluster/node.rb:53
     62055  ruby/lib/socket.rb:457
     49364  redis-client-0.22.1/lib/redis_client/ruby_connection/buffered_io.rb:18
     40480  redis-client-0.22.1/lib/redis_client/ruby_connection/resp3.rb:69
     40000  redis-cluster-client/lib/redis_client/cluster.rb:34
     12400  ruby/lib/socket.rb:231
     11520  redis-cluster-client/lib/redis_client/cluster/node.rb:346
     11232  redis-cluster-client/lib/redis_client/cluster/node.rb:359
      7328  redis-cluster-client/lib/redis_client/cluster/command.rb:50
      7208  redis-cluster-client/lib/redis_client/cluster/node/base_topology.rb:55