summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Axtens <dja@axtens.net>2017-02-10 13:55:15 +1100
committerDaniel Axtens <dja@axtens.net>2017-02-13 09:43:24 +1100
commit90679884efa7bc277ced354032ca655e1e99faa2 (patch)
treeffdc8f21cbafe74e551d93b3633e4fc7102c12c4
parent10e096fe097a489eec41bad120f5b5e52fa4b61c (diff)
ISA-L: Only calculate gf tables on init, not every encode
Currently, the Galois Field multiplication tables are recalcuated every time an encode is done. This is wasteful, as they are fixed by k and m, which is set on init. Calculate the tables only once, on init. This trades off a little bit of per-context memory and creation time for measurably faster encodes when using the same context. On powerpc64le, when repeatedly encoding a 4kB file with pyeclib, this increases the measured speed by over 10%. Change-Id: I2f025aaee2d13cb1717a331e443e179ad5a13302 Signed-off-by: Daniel Axtens <dja@axtens.net>
Notes
Notes (review): Code-Review+2: Tim Burke <tim@swiftstack.com> Code-Review+2: Kota Tsuyuzaki <tsuyuzaki.kota@lab.ntt.co.jp> Workflow+1: Kota Tsuyuzaki <tsuyuzaki.kota@lab.ntt.co.jp> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 29 Mar 2017 06:49:40 +0000 Reviewed-on: https://review.openstack.org/431850 Project: openstack/liberasurecode Branch: refs/heads/master
-rw-r--r--include/isa_l/isa_l_common.h1
-rw-r--r--src/backends/isa-l/isa_l_common.c28
2 files changed, 19 insertions, 10 deletions
diff --git a/include/isa_l/isa_l_common.h b/include/isa_l/isa_l_common.h
index caad19a..0445544 100644
--- a/include/isa_l/isa_l_common.h
+++ b/include/isa_l/isa_l_common.h
@@ -52,6 +52,7 @@ typedef struct {
52 52
53 /* fields needed to hold state */ 53 /* fields needed to hold state */
54 unsigned char *matrix; 54 unsigned char *matrix;
55 unsigned char *encode_tables;
55 int k; 56 int k;
56 int m; 57 int m;
57 int w; 58 int w;
diff --git a/src/backends/isa-l/isa_l_common.c b/src/backends/isa-l/isa_l_common.c
index b7fb05e..63e7cca 100644
--- a/src/backends/isa-l/isa_l_common.c
+++ b/src/backends/isa-l/isa_l_common.c
@@ -41,22 +41,13 @@ int isa_l_encode(void *desc, char **data, char **parity,
41{ 41{
42 isa_l_descriptor *isa_l_desc = (isa_l_descriptor*) desc; 42 isa_l_descriptor *isa_l_desc = (isa_l_descriptor*) desc;
43 43
44 unsigned char *g_tbls = NULL; 44 unsigned char *g_tbls = isa_l_desc->encode_tables;
45 int k = isa_l_desc->k; 45 int k = isa_l_desc->k;
46 int m = isa_l_desc->m; 46 int m = isa_l_desc->m;
47 47
48 // Generate g_tbls from encode matrix encode_matrix
49 g_tbls = malloc(sizeof(unsigned char) * (k * m * 32));
50 if (NULL == g_tbls) {
51 return -1;
52 }
53
54 isa_l_desc->ec_init_tables(k, m, &isa_l_desc->matrix[k * k], g_tbls);
55
56 /* FIXME - make ec_encode_data return a value */ 48 /* FIXME - make ec_encode_data return a value */
57 isa_l_desc->ec_encode_data(blocksize, k, m, g_tbls, (unsigned char**)data, 49 isa_l_desc->ec_encode_data(blocksize, k, m, g_tbls, (unsigned char**)data,
58 (unsigned char**)parity); 50 (unsigned char**)parity);
59 free(g_tbls);
60 return 0; 51 return 0;
61} 52}
62 53
@@ -444,6 +435,7 @@ int isa_l_exit(void *desc)
444 435
445 isa_l_desc = (isa_l_descriptor*) desc; 436 isa_l_desc = (isa_l_descriptor*) desc;
446 437
438 free(isa_l_desc->encode_tables);
447 free(isa_l_desc->matrix); 439 free(isa_l_desc->matrix);
448 free(isa_l_desc); 440 free(isa_l_desc);
449 441
@@ -536,8 +528,24 @@ void * isa_l_common_init(struct ec_backend_args *args, void *backend_sohandle,
536 */ 528 */
537 desc->gf_gen_encoding_matrix(desc->matrix, desc->k + desc->m, desc->k); 529 desc->gf_gen_encoding_matrix(desc->matrix, desc->k + desc->m, desc->k);
538 530
531
532 /**
533 * Generate the tables for encoding
534 */
535 desc->encode_tables = malloc(sizeof(unsigned char) *
536 (desc->k * desc->m * 32));
537 if (NULL == desc->encode_tables) {
538 goto error_free;
539 }
540
541 desc->ec_init_tables(desc->k, desc->m,
542 &desc->matrix[desc->k * desc->k],
543 desc->encode_tables);
544
539 return desc; 545 return desc;
540 546
547error_free:
548 free(desc->matrix);
541error: 549error:
542 free(desc); 550 free(desc);
543 551