This patch set is an attempt at doing better in terms of individual operation performance when the number of open sessions or valid objects in the same process ammounts to a high count.
Currently, for almost every API call, opencryptoki needs to go over internal linked-list structures in order to look-up session and objects's internal representation. This effectivelly makes the time taken by each API call to perform session+object lookup an exponential function of the number of open sessions or valid objects. For any number above 5000 it starts to take more than 80% of the cpu time. The proposed solution is un-orthodoxal in the sense of using the data structure's own pointer as handlers, and trying to de-reference those immediately instead of looking them up in a possibly very long loop. The bad part is that we also have to resort to un-orthodoxal methods to avoid segfaulting every time a caller passes an invalid handler. Another one is that we MUST guarantee that the handler types are able to carry a valid pointer in the target architecture. For now this seems valid for most Linux/gcc combinations that we care, though. Patches 1 and 4 are complementing the testcases in the hope of validating those changes. Patch 2 is mostly clean-up, while 3 tries to use global counters to simplify/optimize session management functions Patches 5-7 are where we are indeed using pointers as sessions and objects handlers. This has been somehow tested with swtok on x64, ppc64 and s390x, and with icatok on s390x, but our testsuite is not complete. Any additional testing (specially memory leakage and token objects) are (specially) welcome. Comments, questions, arguments and even flames are welcome as well. -Klaus [PATCH 1/7] New "sess_perf.c" testcase [PATCH 2/7] Remove duplicate object_mgr_remove_from_map() function [PATCH 3/7] Optimize tracking for Read-Only sessions and login state [PATCH 4/7] Add "invalid session handle" to sess_mgmt.c testcase [PATCH 5/7] Use pointer as session handler in API layer [PATCH 6/7] Use pointer as session handler in common library layer [PATCH 7/7] Use pointer as object handler global diffstat: testcases/driver/Makefile.am | 4 +- testcases/driver/sess_mgmt.c | 62 +++++++++ testcases/driver/sess_perf.c | 250 ++++++++++++++++++++++++++++++++++++ usr/include/pkcs11/apictl.h | 3 +- usr/lib/pkcs11/api/api_interface.c | 1 + usr/lib/pkcs11/api/apiutil.c | 55 ++++++-- usr/lib/pkcs11/common/globals.c | 8 +- usr/lib/pkcs11/common/h_extern.h | 11 +- usr/lib/pkcs11/common/host_defs.h | 6 + usr/lib/pkcs11/common/mech_ssl3.c | 12 +- usr/lib/pkcs11/common/new_host.c | 8 +- usr/lib/pkcs11/common/obj_mgr.c | 223 +++++++++++++++++++++----------- usr/lib/pkcs11/common/sess_mgr.c | 217 ++++++++++++++----------------- 13 files changed, 630 insertions(+), 230 deletions(-) ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Opencryptoki-tech mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opencryptoki-tech
