#3435 Analyze monq_task performance

unreleased
invalid
nobody
General
nobody
2015-02-23
2011-12-13
No

Determine and run some queries to check the monq_task collection to find causes for slowness. Document the queries here in this ticket for future reference to run again if needed.

Here are a few:

in progress, and pending

db.monq_task.find({state:'busy'}).count()
db.monq_task.find({state:'ready'}).count()

raw quantity per day

db.monq_task.find({time_queue: {$gt: ISODate("2011-12-13T00:00:00.000Z"), $lt: ISODate("2011-12-14T00:00:00.000Z")}}).count()

recent tasks that took over 5 minutes

db.monq_task.find({'$where': "this.time_stop.getTime() - this.time_start.getTime() > 5*60*1000", time_stop: {'$ne': null}, time_start: {'$gt': ISODate("2011-12-10T00:00:00.000Z")}}).count()

what is assigned to each process

db.monq_task.find({'state':'busy', time_start: {$gt: new Date(Date.now() - 1000*60*60*48)}}, {process:1,task_name:1,time_start:1}).sort({'process':1})

details of current process

db.monq_task.find({'state':'busy', time_start: {$gt: new Date(Date.now() - 1000*60*60*3)}})

check an individual process activity

> sudo -u allura strace -p 6406
> kill -USR1 -p 6406  # need siteops to run; will print current task to /var/log/allura/allura.log

types of pending tasks

db.monq_task.distinct('task_name', {'state':'ready'})
q = {'state':'ready'}   
db.monq_task.distinct('task_name', q).forEach(function(t){ print(t, db.monq_task.find({$and: [q, {task_name:t}]}).count()) })

Discussion

  • Dave Brondsema

    Dave Brondsema - 2011-12-14
    • labels: --> performance, metrics
    • milestone: forge-dec-16 --> forge-backlog
     
  • Dave Brondsema

    Dave Brondsema - 2011-12-14

    Not as urgent, since the immediate problem was found in the mail notification task and fixed.

     
  • Dave Brondsema

    Dave Brondsema - 2012-04-20
    • status: open --> invalid
    • size: --> 0
    • milestone: forge-backlog --> forge-apr-20
     
  • Anonymous - 2012-09-20

    Originally by: scoop

    • milestone: limbo --> forge-sep-21
     
  • Dave Brondsema

    Dave Brondsema - 2012-11-08

    Find high occurrences of certain tools/projects within a task type

    q = {'state':'ready', 'task_name':'allura.tasks.notification_tasks.notify'}   
    db.monq_task.aggregate([
        {$match: q },
        {$group: {_id:'$context.app_config_id', num_tasks:{$sum:1}} },
        {$match: {num_tasks: {$gt: 50}}},
        {$sort: {num_tasks: -1}}
    ]).forEach(function(result) {
        ac_id = result._id
        config=db.getSiblingDB('project-data').config.findOne({_id:ac_id});
        if (config) {
            tool = config.tool_name;
            proj = db.getSiblingDB('pyforge').project.findOne({_id: config.project_id})
            if (proj) {
                proj = proj.shortname;
            } else {
                proj = 'no proj found for config';
            }
        } else {
            tool = 'no config found'
            proj = '';
        }
        print(result.num_tasks, ac_id, tool, proj)
    });
    
     

    Last edit: Dave Brondsema 2017-03-14
  • Dave Brondsema

    Dave Brondsema - 2014-06-17

    Find average time to complete certain tasks:

    function mean(arr) { 
        var i, sum = 0, len = arr.length; 
        for (i = 0; i < len; i++) { 
            sum += arr[i]; 
        } 
        return sum / len;
    }
    
    mean(db.monq_task.find({state:'complete', task_name:'allura.tasks.index_tasks.add_artifacts', _id: {$gt: objectIdWithTimestamp(ISODate('2014-06-16')), $lt: objectIdWithTimestamp(ISODate('2014-06-17'))} }, {time_start:1, time_stop:1}).map(function(t) { return t.time_stop - t.time_start; }))
    

    Count tasks by state:

    q = { task_name:'allura.tasks.index_tasks.add_artifacts', _id: {$gt: objectIdWithTimestamp(ISODate('2014-06-17T08:00'))} }
    
    db.monq_task.distinct('state', q).forEach(function(t){ print(t, db.monq_task.find({$and: [q, {state:t}]}).count()) })
    
     

Log in to post a comment.