Messages in this thread | | | Date | Fri, 01 Aug 2008 12:16:16 -0600 | From | Andreas Dilger <> | Subject | Re: high resolution timers, scheduling & sleep granularity |
| |
On Aug 01, 2008 09:25 -0400, Josef Bacik wrote: > + if (unlikely(!journal->j_average_commit_time)) > + journal->j_average_commit_time = commit_time; > + else > + journal->j_average_commit_time = (commit_time + > + journal->j_average_commit_time) / 2;
You may also consider making this a decaying average, so that minor changes in the workload are smoothed out. Also, it is probably easier to read likely(foo) instead of unlikely(!foo)...
if (likely(journal->j_average_commit_time != 0)) journal->j_average_commit_time = (commit_time * 3 + journal->j_average_commit_time) / 4; else journal->j_average_commit_time = commit_time;
> + if (journal->print_count < 100) { > + journal->print_count++; > + printk(KERN_ERR "avg commit time = %lu\n", > + journal->j_average_commit_time); > + }
There is already the jbd stats patch in jbd2 that is reporting this information for the previous transactions.
> > + spin_lock(&journal->j_state_lock); > + commit_time = journal->j_average_commit_time; > + spin_unlock(&journal->j_state_lock); > + > + sleep_time = elapsed_jiffies(transaction->t_start_time, jiffies); > + if (!sleep_time) > + sleep_time = 1; > + sleep_time = (commit_time / sleep_time) * commit_time;
I was also going to comment on the use of jiffies here, but Ric beat me to it.
Cheers, Andreas -- Andreas Dilger Sr. Staff Engineer, Lustre Group Sun Microsystems of Canada, Inc.
| |