[Groonga-commit] groonga/groonga-query-log at d27814c [master] Add feature that verify cache hit rate. (#9)

Zurück zum Archiv-Index

komainu8 null+****@clear*****
Fri Apr 21 11:16:17 JST 2017


komainu8	2017-04-21 11:16:17 +0900 (Fri, 21 Apr 2017)

  New Revision: d27814c99159a77bacc9ec4c455f7c83680f3b2f
  https://github.com/groonga/groonga-query-log/commit/d27814c99159a77bacc9ec4c455f7c83680f3b2f

  Message:
    Add feature that verify cache hit rate.  (#9)
    
    Patch by komainu8. Thanks!!!

  Modified files:
    lib/groonga/query-log/command/run-regression-test.rb
    lib/groonga/query-log/command/verify-server.rb
    lib/groonga/query-log/response-comparer.rb
    lib/groonga/query-log/server-verifier.rb

  Modified: lib/groonga/query-log/command/run-regression-test.rb (+20 -0)
===================================================================
--- lib/groonga/query-log/command/run-regression-test.rb    2017-04-14 14:55:30 +0900 (8f86c80)
+++ lib/groonga/query-log/command/run-regression-test.rb    2017-04-21 11:16:17 +0900 (e2be4d2)
@@ -46,6 +46,7 @@ module Groonga
           @skip_finished_queries = false
           @output_query_log = false
           @care_order = true
+          @verify_cachehit_mode = false
         end
 
         def run(command_line)
@@ -260,6 +261,10 @@ module Groonga
             end
           end
 
+          def use_persistent_cache?
+            @groonga_options.include?("--cache-base-path")
+          end
+
           def shutdown
             begin
               send_command("shutdown")
@@ -268,6 +273,14 @@ module Groonga
             Process.waitpid(@pid)
           end
 
+          def restart
+            self.shutdown
+            run_thread = Thread.new do
+              self.run{}
+            end
+            run_thread.join
+          end
+
           private
           def find_unused_port
             server = TCPServer.new(@host, 0)
@@ -363,6 +376,12 @@ module Groonga
               rescue Interrupt
                 puts("Interrupt: #{query_log_path}")
               end
+              if****@new*****_persistent_cache?
+                @new.restart
+              end
+              if****@old*****_persistent_cache?
+                @old.restart
+              end
             end
 
             old_thread = Thread.new do
@@ -390,6 +409,7 @@ module Groonga
             ]
             command_line << "--no-care-order" if @options[:care_order] == false
             command_line << query_log_path.to_s
+            command_line << "--verify-cachehit-mode" if****@new*****_persistent_cache? or****@old*****_persistent_cache?
             verify_server = VerifyServer.new
             verify_server.run(command_line)
           end

  Modified: lib/groonga/query-log/command/verify-server.rb (+6 -0)
===================================================================
--- lib/groonga/query-log/command/verify-server.rb    2017-04-14 14:55:30 +0900 (276bf95)
+++ lib/groonga/query-log/command/verify-server.rb    2017-04-21 11:16:17 +0900 (30fcf55)
@@ -135,6 +135,12 @@ module Groonga
             @options.output_path = path
           end
 
+          parser.on("--verify-cachehit-mode",
+                    "Verify cachehit rate. After execute query, 'status' command execute.",
+                    "[#{@options.verify_cachehit_mode}]") do
+            @options.verify_cachehit_mode = true
+          end
+
           parser.separator("Debug options:")
           parser.separator("")
 

  Modified: lib/groonga/query-log/response-comparer.rb (+6 -0)
===================================================================
--- lib/groonga/query-log/response-comparer.rb    2017-04-14 14:55:30 +0900 (b4bf597)
+++ lib/groonga/query-log/response-comparer.rb    2017-04-21 11:16:17 +0900 (209c66c)
@@ -36,6 +36,8 @@ module Groonga
           case****@comma*****
           when "select", "logical_select"
             same_select_response?
+          when "status"
+            same_cache_hit_rate?
           else
             same_response?
           end
@@ -71,6 +73,10 @@ module Groonga
         end
       end
 
+      def same_cache_hit_rate?
+        @response1.body["cache_hit_rate"] ==****@respo*****["cache_hit_rate"]
+      end
+
       def care_order?
         return false unless @options[:care_order]
         return false if random_sort?

  Modified: lib/groonga/query-log/server-verifier.rb (+9 -0)
===================================================================
--- lib/groonga/query-log/server-verifier.rb    2017-04-14 14:55:30 +0900 (9ba8bf0)
+++ lib/groonga/query-log/server-verifier.rb    2017-04-21 11:16:17 +0900 (8c82d7e)
@@ -78,6 +78,9 @@ module Groonga
               begin
                 verify_command(groonga1_client, groonga2_client,
                                statistic.command)
+
+                verify_command(groonga1_client, groonga2_client,
+                               Groonga::Command::Status.new)
               rescue
                 log_client_error($!) do
                   $stderr.puts(statistic.command.original_source)
@@ -106,6 +109,9 @@ module Groonga
       end
 
       def verify_command(groonga1_client, groonga2_client, command)
+        if command.instance_of?(Groonga::Command::Status)
+          return unles****@optio*****_cachehit_mode
+        end
         command["cache"] = "no" if****@optio*****_cache?
         command["output_type"] = :json
         response1 = groonga1_client.execute(command)
@@ -148,6 +154,7 @@ module Groonga
         attr_accessor :target_command_names
         attr_accessor :output_path
         attr_accessor :care_order
+        attr_accessor :verify_cachehit_mode
         def initialize
           @groonga1 = GroongaOptions.new
           @groonga2 = GroongaOptions.new
@@ -164,8 +171,10 @@ module Groonga
             "normalize",
             "object_exist",
             "select",
+            "status",
           ]
           @care_order = true
+          @verify_cahehit_mode = false
         end
 
         def request_queue_size
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index