[ARVADOS] updated: d7e23d9ae16310f9efe16a6a74ff2fc95ae4ccb4
git at public.curoverse.com
git at public.curoverse.com
Fri Jun 13 14:39:07 EDT 2014
Summary of changes:
services/api/script/crunch-dispatch.rb | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
via d7e23d9ae16310f9efe16a6a74ff2fc95ae4ccb4 (commit)
from 54e43ffa674583332713d980b5ba6701b4fa4d02 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit d7e23d9ae16310f9efe16a6a74ff2fc95ae4ccb4
Author: Tim Pierce <twp at curoverse.com>
Date: Fri Jun 13 14:03:04 2014 -0400
2934: count events and bytes in-memory
To avoid thrashing the database, crunch-dispatch.rb counts log events
and bytes in RAM instead of reading the database each time.
Refs #2934.
diff --git a/services/api/script/crunch-dispatch.rb b/services/api/script/crunch-dispatch.rb
index 6f3aeda..843fc0d 100755
--- a/services/api/script/crunch-dispatch.rb
+++ b/services/api/script/crunch-dispatch.rb
@@ -263,6 +263,8 @@ class Dispatcher
job_auth: job_auth,
stderr_buf_to_flush: '',
stderr_flushed_at: 0,
+ bytes_logged: 0,
+ events_logged: 0,
log_truncated: false
}
i.close
@@ -448,17 +450,13 @@ class Dispatcher
protected
- def too_many_bytes_logged_for_job(running_job)
- bytes_logged = Log.where(uuid: running_job[:uuid]).map { |event|
- (event.properties["text"] || "").length
- }.sum
- return (bytes_logged + j[:stderr_buf_to_flush].size >
+ def too_many_bytes_logged_for_job(j)
+ return (j[:bytes_logged] + j[:stderr_buf_to_flush].size >
Rails.configuration.crunch_limit_log_event_bytes_per_job)
end
- def too_many_events_logged_for_job(running_job)
- log_count = Log.where(uuid: running_job[:uuid]).count
- return (log_count >= Rails.configuration.crunch_limit_log_events_per_job)
+ def too_many_events_logged_for_job(j)
+ return (j[:events_logged] >= Rails.configuration.crunch_limit_log_events_per_job)
end
def did_recently(thing, min_interval)
@@ -493,6 +491,8 @@ class Dispatcher
owner_uuid: running_job[:job].owner_uuid,
properties: {"text" => running_job[:stderr_buf_to_flush]})
log.save!
+ running_job[:bytes_logged] += running_job[:stderr_buf_to_flush].size
+ running_job[:events_logged] += 1
running_job[:stderr_buf_to_flush] = ''
running_job[:stderr_flushed_at] = Time.now.to_i
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list