Some performance improvements.
This commit is contained in:
parent
8c2ea52b3c
commit
1a72bfd98a
1 changed files with 274 additions and 258 deletions
|
@ -89,12 +89,18 @@ module Import::OTRS2
|
||||||
data['Key'] = Setting.get('import_otrs_endpoint_key')
|
data['Key'] = Setting.get('import_otrs_endpoint_key')
|
||||||
log 'POST: ' + url
|
log 'POST: ' + url
|
||||||
log 'PARAMS: ' + data.inspect
|
log 'PARAMS: ' + data.inspect
|
||||||
|
open_timeout = 10
|
||||||
|
read_timeout = 120
|
||||||
|
if data.empty?
|
||||||
|
open_timeout = 6
|
||||||
|
read_timeout = 20
|
||||||
|
end
|
||||||
response = UserAgent.post(
|
response = UserAgent.post(
|
||||||
url,
|
url,
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
open_timeout: 6,
|
open_timeout: open_timeout,
|
||||||
read_timeout: 60,
|
read_timeout: read_timeout,
|
||||||
user: Setting.get('import_otrs_user'),
|
user: Setting.get('import_otrs_user'),
|
||||||
password: Setting.get('import_otrs_password'),
|
password: Setting.get('import_otrs_password'),
|
||||||
},
|
},
|
||||||
|
@ -343,7 +349,7 @@ module Import::OTRS2
|
||||||
|
|
||||||
# create customers
|
# create customers
|
||||||
count = 0
|
count = 0
|
||||||
steps = 30
|
steps = 50
|
||||||
run = true
|
run = true
|
||||||
while run
|
while run
|
||||||
count += steps
|
count += steps
|
||||||
|
@ -360,6 +366,8 @@ module Import::OTRS2
|
||||||
thread_count = 8
|
thread_count = 8
|
||||||
threads = {}
|
threads = {}
|
||||||
count = 0
|
count = 0
|
||||||
|
memory_clear_after_loops = 10
|
||||||
|
memory_clear_loop_counter = 0
|
||||||
locks = { User: {} }
|
locks = { User: {} }
|
||||||
(1..thread_count).each {|thread|
|
(1..thread_count).each {|thread|
|
||||||
threads[thread] = Thread.new {
|
threads[thread] = Thread.new {
|
||||||
|
@ -369,6 +377,11 @@ module Import::OTRS2
|
||||||
run = true
|
run = true
|
||||||
steps = 20
|
steps = 20
|
||||||
while run
|
while run
|
||||||
|
memory_clear_loop_counter++
|
||||||
|
if memory_clear_loop_counter == memory_clear_after_loops
|
||||||
|
GC.start
|
||||||
|
memory_clear_loop_counter = 0
|
||||||
|
end
|
||||||
count += steps
|
count += steps
|
||||||
log "loading... thread# #{thread} ..."
|
log "loading... thread# #{thread} ..."
|
||||||
offset = count - steps
|
offset = count - steps
|
||||||
|
@ -512,6 +525,8 @@ module Import::OTRS2
|
||||||
|
|
||||||
result.each {|record|
|
result.each {|record|
|
||||||
|
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
|
||||||
# cleanup values
|
# cleanup values
|
||||||
_cleanup(record)
|
_cleanup(record)
|
||||||
|
|
||||||
|
@ -790,6 +805,7 @@ module Import::OTRS2
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue