aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2015-07-13 14:12:19 +0200
committerThomas White <taw@physics.org>2015-07-13 16:00:46 +0200
commitfc2a630ffa41f34454911c3a91c253b82475212c (patch)
tree21dac18458196005c5c49beef1f4205d3b99a585
parent59b0708b8b89e921ee6914e072ff71eb121d7c41 (diff)
Slow down the status updates
-rw-r--r--libcrystfel/src/dirax.c6
-rw-r--r--libcrystfel/src/xds.c6
-rw-r--r--src/im-sandbox.c72
-rw-r--r--src/indexamajig.c6
4 files changed, 35 insertions, 55 deletions
diff --git a/libcrystfel/src/dirax.c b/libcrystfel/src/dirax.c
index 05e44d97..fb69cece 100644
--- a/libcrystfel/src/dirax.c
+++ b/libcrystfel/src/dirax.c
@@ -43,12 +43,6 @@
#include <sys/ioctl.h>
#include <errno.h>
-#ifdef HAVE_CLOCK_GETTIME
-#include <time.h>
-#else
-#include <sys/time.h>
-#endif
-
#include "image.h"
#include "dirax.h"
#include "utils.h"
diff --git a/libcrystfel/src/xds.c b/libcrystfel/src/xds.c
index 40e2fd72..f5985e73 100644
--- a/libcrystfel/src/xds.c
+++ b/libcrystfel/src/xds.c
@@ -45,12 +45,6 @@
#include <sys/ioctl.h>
#include <errno.h>
-#ifdef HAVE_CLOCK_GETTIME
-#include <time.h>
-#else
-#include <sys/time.h>
-#endif
-
#include "cell.h"
#include "image.h"
#include "utils.h"
diff --git a/src/im-sandbox.c b/src/im-sandbox.c
index 5e9c4838..1264c46a 100644
--- a/src/im-sandbox.c
+++ b/src/im-sandbox.c
@@ -68,8 +68,6 @@
struct sandbox
{
int n_processed_last_stats;
- int n_hadcrystals_last_stats;
- int n_crystals_last_stats;
int t_last_stats;
struct index_args *iargs;
@@ -749,6 +747,35 @@ static void check_signals(struct sandbox *sb, const char *semname_q,
}
+static void try_status(struct sandbox *sb, time_t tNow)
+{
+ int r;
+ int n_proc_this;
+ double indexable;
+
+ r = pthread_mutex_trylock(&sb->shared->term_lock);
+ if ( r ) return; /* No lock -> don't bother */
+
+ n_proc_this = sb->shared->n_processed
+ - sb->n_processed_last_stats;
+ indexable = (sb->shared->n_processed == 0) ? 0 :
+ 100.0 * sb->shared->n_hadcrystals
+ / sb->shared->n_processed;
+
+ STATUS("%4i indexable out of %4i processed (%4.1f%%), "
+ "%4i crystals so far. "
+ "%4i images processed since the last message.\n",
+ sb->shared->n_hadcrystals,
+ sb->shared->n_processed, indexable,
+ sb->shared->n_crystals, n_proc_this);
+
+ sb->n_processed_last_stats = sb->shared->n_processed;
+ sb->t_last_stats = tNow;
+
+ pthread_mutex_unlock(&sb->shared->term_lock);
+}
+
+
void create_sandbox(struct index_args *iargs, int n_proc, char *prefix,
int config_basename, FILE *fh,
Stream *stream, const char *tempdir)
@@ -775,8 +802,6 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix,
}
sb->n_processed_last_stats = 0;
- sb->n_hadcrystals_last_stats = 0;
- sb->n_crystals_last_stats = 0;
sb->t_last_stats = get_monotonic_seconds();
sb->n_proc = n_proc;
sb->iargs = iargs;
@@ -885,51 +910,24 @@ void create_sandbox(struct index_args *iargs, int n_proc, char *prefix,
do {
- int r;
- double tNow;
+ time_t tNow;
+ /* Check for stream output from workers */
try_read(sb);
+
+ /* Check for interrupt or zombies */
check_signals(sb, semname_q, 1);
/* Top up the queue if necessary */
- r = 0;
pthread_mutex_lock(&sb->shared->queue_lock);
if ( sb->shared->n_events < QUEUE_SIZE/2 ) {
- r = fill_queue(fh, config_basename, iargs->det, prefix,
- sb);
+ fill_queue(fh, config_basename, iargs->det, prefix, sb);
}
pthread_mutex_unlock(&sb->shared->queue_lock);
/* Update progress */
tNow = get_monotonic_seconds();
- r = pthread_mutex_trylock(&sb->shared->term_lock);
- if ( r == 0 ) {
-
- /* Could get lock, so write status */
- int n_proc_this;
- double indexable;
-
- n_proc_this = sb->shared->n_processed
- - sb->n_processed_last_stats;
- indexable = (sb->shared->n_processed == 0) ? 0 :
- 100.0 * sb->shared->n_hadcrystals
- / sb->shared->n_processed;
-
- STATUS("%4i indexable out of %4i processed (%4.1f%%), "
- "%4i crystals so far. "
- "%4i images processed since the last message.\n",
- sb->shared->n_hadcrystals,
- sb->shared->n_processed, indexable,
- sb->shared->n_crystals, n_proc_this);
-
- sb->n_processed_last_stats = sb->shared->n_processed;
- sb->n_hadcrystals_last_stats = sb->shared->n_hadcrystals;
- sb->n_crystals_last_stats = sb->shared->n_crystals;
- sb->t_last_stats = tNow;
-
- pthread_mutex_unlock(&sb->shared->term_lock);
-
- }
+ if ( tNow > sb->t_last_stats+5 ) try_status(sb, tNow);
/* Have all the events been swallowed? */
pthread_mutex_lock(&sb->shared->queue_lock);
diff --git a/src/indexamajig.c b/src/indexamajig.c
index deac67bf..21f8f167 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -48,12 +48,6 @@
#include <sys/stat.h>
#include <fcntl.h>
-#ifdef HAVE_CLOCK_GETTIME
-#include <time.h>
-#else
-#include <sys/time.h>
-#endif
-
#include "version.h"
#include "utils.h"
#include "hdf5-file.h"