Last Comment Bug 391292 - Shared Database implementation slow
: Shared Database implementation slow
Product: NSS
Classification: Components
Component: Libraries (show other bugs)
: trunk
: All All
-- normal (vote)
: 3.12
Assigned To: Robert Relyea
Depends on:
Blocks: 217538
  Show dependency treegraph
Reported: 2007-08-07 17:28 PDT by Robert Relyea
Modified: 2007-10-24 15:54 PDT (History)
0 users
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---

First performance patch (11.95 KB, patch)
2007-08-30 17:36 PDT, Robert Relyea
neil.williams: review+
Details | Diff | Splinter Review

Description User image Robert Relyea 2007-08-07 17:28:25 PDT
The new shared database is noticeably slower than the old database implemention.

In the old implementation, there was a persistant cache if information. We need to implement a similiar cache for the shared databse.
Comment 1 User image Nelson Bolyard (seldom reads bugmail) 2007-08-07 18:14:54 PDT
If you cache the data for the DB, you need to ensure there are no 
cache coherency issues.  When ANY process modifies a part of the DB,
the cache for that part MUST be invalidated for all processes that
are sharing that DB.  

This very problem is why the old NSS databases were not safe for 
simultaneous access by multiple processes, IINM.  
Comment 2 User image Robert Relyea 2007-08-08 09:22:58 PDT
The cache would cache things like object id type is X.

Changing the type of a given object id would most likely cause problems well above the PKCS #11 layer.

I don't intend to do any database style caching.
Comment 3 User image Robert Relyea 2007-08-30 17:36:18 PDT
Created attachment 279042 [details] [diff] [review]
First performance patch

This patch collects all the private key attributes into a single get attribute call. The result of this patch:

certutil -L -d . with a database of 3 certs:

dbm base-line: .014u/.009s

Before this patch:
sqlite local FS: .149u/.046s  (10x user/5x system)
sqlite network FS: .311u/.247s (22x user/27x system)

After this patch:
sqlite local FS: .067u/.018s (5x user/2x system)
sqlite network FS: .094u/.052s (7x user/6x system)

This patch basically cuts our local fs times by half and your network fs by 1/3.

Comment 4 User image Neil Williams 2007-08-31 15:40:11 PDT
Comment on attachment 279042 [details] [diff] [review]
First performance patch

r+ but the comment at the head of sftk_MultipleAttribute2SecItem() should read "copy multiple unsigned attributes..." shouldn't it?
Comment 5 User image Robert Relyea 2007-09-06 13:48:44 PDT
checked in with neil's comments addressed (yes it should talk about multiple attributes).

Checking in pkcs11.c;
/cvsroot/mozilla/security/nss/lib/softoken/pkcs11.c,v  <--  pkcs11.c
new revision: 1.143; previous revision: 1.142
Checking in pkcs11u.c;
/cvsroot/mozilla/security/nss/lib/softoken/pkcs11u.c,v  <--  pkcs11u.c
new revision: 1.76; previous revision: 1.75
Checking in pkcs11i.h;
/cvsroot/mozilla/security/nss/lib/softoken/pkcs11i.h,v  <--  pkcs11i.h
new revision: 1.48; previous revision: 1.47
Comment 6 User image Robert Relyea 2007-10-24 15:54:11 PDT
This should be fixed on the current tip

Note You need to log in before you can comment on or make changes to this bug.