Some performance improvements.

This commit is contained in:
Martin Edenhofer 2015-05-01 09:44:31 +02:00
parent 8c2ea52b3c
commit 1a72bfd98a

View file

@ -89,12 +89,18 @@ module Import::OTRS2
data['Key'] = Setting.get('import_otrs_endpoint_key')
log 'POST: ' + url
log 'PARAMS: ' + data.inspect
open_timeout = 10
read_timeout = 120
if data.empty?
open_timeout = 6
read_timeout = 20
end
response = UserAgent.post(
url,
data,
{
open_timeout: 6,
read_timeout: 60,
open_timeout: open_timeout,
read_timeout: read_timeout,
user: Setting.get('import_otrs_user'),
password: Setting.get('import_otrs_password'),
},
@ -343,7 +349,7 @@ module Import::OTRS2
# create customers
count = 0
steps = 30
steps = 50
run = true
while run
count += steps
@ -360,6 +366,8 @@ module Import::OTRS2
thread_count = 8
threads = {}
count = 0
memory_clear_after_loops = 10
memory_clear_loop_counter = 0
locks = { User: {} }
(1..thread_count).each {|thread|
threads[thread] = Thread.new {
@ -369,6 +377,11 @@ module Import::OTRS2
run = true
steps = 20
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
log "loading... thread# #{thread} ..."
offset = count - steps
@ -512,6 +525,8 @@ module Import::OTRS2
result.each {|record|
ActiveRecord::Base.transaction do
# cleanup values
_cleanup(record)
@ -790,6 +805,7 @@ module Import::OTRS2
)
end
}
end
}
end