diff options
author | Thomas White <taw@physics.org> | 2023-09-23 17:57:20 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2023-09-23 19:37:40 +0200 |
commit | 1a0580e817a0f60505e38c8dd29f9e4eeeae0558 (patch) | |
tree | 4cb92f99fbf100bfab226ea94012da262d4bda77 /src | |
parent | cee7ee0b8a4cafa1f8f3c67518f86c895520f5a6 (diff) |
indexamajig: Re-use the image data arrays
We noticed that constant freeing and re-allocating the (potentially
quite large) arrays resulted in much lower performance. Since we know
that all images have the same data layout, we can safely re-use the
arrays. This gives a large speedup.
Diffstat (limited to 'src')
-rw-r--r-- | src/crystfel_gui.c | 2 | ||||
-rw-r--r-- | src/gui_index.c | 2 | ||||
-rw-r--r-- | src/im-sandbox.c | 6 | ||||
-rw-r--r-- | src/process_image.c | 16 | ||||
-rw-r--r-- | src/process_image.h | 2 |
5 files changed, 18 insertions, 10 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c index 41546bcd..d0fab3b1 100644 --- a/src/crystfel_gui.c +++ b/src/crystfel_gui.c @@ -215,7 +215,7 @@ void update_imageview(struct crystfelproject *proj) image = image_read(proj->dtempl, proj->filenames[proj->cur_frame], proj->events[proj->cur_frame], - 0, 0); + 0, 0, NULL); } else { STATUS("Image data file not present.\n"); image = NULL; diff --git a/src/gui_index.c b/src/gui_index.c index 660dac1c..d690737d 100644 --- a/src/gui_index.c +++ b/src/gui_index.c @@ -160,7 +160,7 @@ static int get_first_frame_parameters(struct crystfelproject *proj, image = image_read(proj->dtempl, proj->filenames[0], proj->events[0], - 0, 0); + 0, 0, NULL); if ( image == NULL ) { ERROR("Failed to load first frame\n"); diff --git a/src/im-sandbox.c b/src/im-sandbox.c index 62b46187..1a6c9e88 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -342,6 +342,7 @@ static int run_work(const struct index_args *iargs, Stream *st, struct im_zmq *zmqstuff = NULL; struct im_asapo *asapostuff = NULL; Mille *mille; + ImageDataArrays *ida; if ( sb->profile ) { profile_init(); @@ -372,6 +373,8 @@ static int run_work(const struct index_args *iargs, Stream *st, mille = crystfel_mille_new(tmp); } + ida = image_data_arrays_new(); + while ( !allDone ) { struct pattern_args pargs; @@ -528,7 +531,7 @@ static int run_work(const struct index_args *iargs, Stream *st, profile_start("process-image"); process_image(iargs, &pargs, st, cookie, tmpdir, ser, sb->shared, sb->shared->last_task[cookie], - asapostuff, mille); + asapostuff, mille, ida); profile_end("process-image"); } @@ -545,6 +548,7 @@ static int run_work(const struct index_args *iargs, Stream *st, free(pargs.event); } + image_data_arrays_free(ida); crystfel_mille_free(mille); /* These are both no-ops if argument is NULL */ diff --git a/src/process_image.c b/src/process_image.c index 6212e361..57a994ac 100644 --- a/src/process_image.c +++ b/src/process_image.c @@ -108,7 +108,8 @@ static struct image *file_wait_open_read(const char *filename, signed int wait_for_file, int cookie, int no_image_data, - int no_mask_data) + int no_mask_data, + ImageDataArrays *ida) { signed int file_wait_time = wait_for_file; int wait_message_done = 0; @@ -154,7 +155,7 @@ static struct image *file_wait_open_read(const char *filename, profile_start("image-read"); image = image_read(dtempl, filename, event, - no_image_data, no_mask_data); + no_image_data, no_mask_data, ida); profile_end("image-read"); if ( image == NULL ) { if ( wait_for_file && !read_retry_done ) { @@ -179,7 +180,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, Stream *st, int cookie, const char *tmpdir, int serial, struct sb_shm *sb_shared, char *last_task, struct im_asapo *asapostuff, - Mille *mille) + Mille *mille, ImageDataArrays *ida) { struct image *image; int i; @@ -200,7 +201,8 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, iargs->data_format, serial, iargs->no_image_data, - iargs->no_mask_data); + iargs->no_mask_data, + ida); profile_end("read-zmq-data"); if ( image == NULL ) return; @@ -222,7 +224,8 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, iargs->data_format, serial, iargs->no_image_data, - iargs->no_mask_data); + iargs->no_mask_data, + ida); profile_end("read-asapo-data"); if ( image == NULL ) return; @@ -240,7 +243,8 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, iargs->wait_for_file, cookie, iargs->no_image_data, - iargs->no_mask_data); + iargs->no_mask_data, + ida); profile_end("file-wait-open-read"); if ( image == NULL ) { if ( iargs->wait_for_file != 0 ) { diff --git a/src/process_image.h b/src/process_image.h index 50abbaa8..f5e27631 100644 --- a/src/process_image.h +++ b/src/process_image.h @@ -119,7 +119,7 @@ extern void process_image(const struct index_args *iargs, int cookie, const char *tmpdir, int serial, struct sb_shm *sb_shared, char *last_task, struct im_asapo *asapostuff, - Mille *mille); + Mille *mille, ImageDataArrays *ida); #endif /* PROCESS_IMAGE_H */ |