Commit 80406431186cc7dd9fac0c8ca23ddf02d20f8c7a

Authored by Andrew
1 parent eca9be0b

Start profiling [skip ci]

@@ -4,13 +4,15 @@ source "https://rubygems.org" @@ -4,13 +4,15 @@ source "https://rubygems.org"
4 gemspec 4 gemspec
5 5
6 gem "sqlite3" 6 gem "sqlite3"
7 -gem "activerecord", "~> 5.1.0" 7 +gem "activerecord", "~> 5.2.0.rc1"
8 gem "gemoji-parser" 8 gem "gemoji-parser"
9 gem "typhoeus" 9 gem "typhoeus"
10 -gem "activejob" 10 +gem "activejob", "~> 5.2.0.rc1"
11 gem "redis" 11 gem "redis"
12 gem "connection_pool" 12 gem "connection_pool"
  13 +gem "faraday", path: "~/forks/faraday"
  14 +gem "ethon", path: "~/forks/ethon"
13 15
14 # kaminari 16 # kaminari
15 -gem "actionpack" 17 +gem "actionpack", "~> 5.2.0.rc1"
16 gem "kaminari" 18 gem "kaminari"
benchmark/Gemfile
@@ -5,13 +5,15 @@ gemspec path: "../" @@ -5,13 +5,15 @@ gemspec path: "../"
5 5
6 # gem "sqlite3" 6 # gem "sqlite3"
7 gem "pg" 7 gem "pg"
8 -gem "activerecord", "~> 5.0.0" 8 +gem "activerecord", "~> 5.2.0.rc1"
9 gem "activerecord-import" 9 gem "activerecord-import"
10 -gem "activejob" 10 +gem "activejob", "~> 5.2.0.rc1"
11 gem "redis" 11 gem "redis"
12 gem "sidekiq" 12 gem "sidekiq"
13 13
14 # performance 14 # performance
  15 +gem "faraday", path: "~/forks/faraday"
  16 +gem "ethon", path: "~/forks/ethon"
15 gem "typhoeus" 17 gem "typhoeus"
16 gem "oj" 18 gem "oj"
17 19
benchmark/benchmark.rb
@@ -33,7 +33,7 @@ class Product < ActiveRecord::Base @@ -33,7 +33,7 @@ class Product < ActiveRecord::Base
33 end 33 end
34 end 34 end
35 35
36 -total_docs = 100000 36 +total_docs = 10000
37 37
38 # ActiveRecord::Migration.create_table :products, force: :cascade do |t| 38 # ActiveRecord::Migration.create_table :products, force: :cascade do |t|
39 # t.string :name 39 # t.string :name
@@ -56,26 +56,26 @@ Product.searchkick_index.delete rescue nil @@ -56,26 +56,26 @@ Product.searchkick_index.delete rescue nil
56 time = 56 time =
57 Benchmark.realtime do 57 Benchmark.realtime do
58 # result = RubyProf.profile do 58 # result = RubyProf.profile do
59 - # report = MemoryProfiler.report do 59 + report = MemoryProfiler.report do
60 # stats = AllocationStats.trace do 60 # stats = AllocationStats.trace do
61 - reindex = Product.reindex(async: true) 61 + reindex = Product.reindex #(async: true)
62 p reindex 62 p reindex
63 - # end  
64 -  
65 - 60.times do |i|  
66 - if reindex.is_a?(Hash)  
67 - docs = Searchkick::Index.new(reindex[:index_name]).total_docs  
68 - else  
69 - docs = Product.searchkick_index.total_docs  
70 - end  
71 - puts "#{i}: #{docs}"  
72 - if docs == total_docs  
73 - break  
74 - end  
75 - p Searchkick.reindex_status(reindex[:index_name]) if reindex.is_a?(Hash)  
76 - sleep(1)  
77 - # Product.searchkick_index.refresh  
78 end 63 end
  64 +
  65 + # 60.times do |i|
  66 + # if reindex.is_a?(Hash)
  67 + # docs = Searchkick::Index.new(reindex[:index_name]).total_docs
  68 + # else
  69 + # docs = Product.searchkick_index.total_docs
  70 + # end
  71 + # puts "#{i}: #{docs}"
  72 + # if docs == total_docs
  73 + # break
  74 + # end
  75 + # p Searchkick.reindex_status(reindex[:index_name]) if reindex.is_a?(Hash)
  76 + # sleep(1)
  77 + # # Product.searchkick_index.refresh
  78 + # end
79 end 79 end
80 80
81 # p GetProcessMem.new.mb 81 # p GetProcessMem.new.mb