Closed
Bug 158242
Opened 22 years ago
Closed 17 years ago
PK11_PutCRL is very memory inefficient
Categories
(NSS :: Libraries, defect, P2)
Tracking
(Not tracked)
RESOLVED
FIXED
3.12
People
(Reporter: julien.pierre, Assigned: alvolkov.bgs)
Details
(Keywords: perf)
Attachments
(2 files, 1 obsolete file)
3.40 KB,
patch
|
nelson
:
review+
julien.pierre
:
review+
|
Details | Diff | Splinter Review |
987 bytes,
patch
|
nelson
:
review+
|
Details | Diff | Splinter Review |
When storing a new CRL to a token, the memory usage grows significantly.
Tasks manager shows the process memory for crlutil going from 170 MB to 270 MB
at the time of importing a 25 MB DER CRL to the softoken. This is roughly 4x the
size of the DER CRL. I have not yet traced where the successive copies of the
DER are being made exactly.
The call to PK11_PutCRL is being made from crl_storeCRL in crl.c .
Comment 1•22 years ago
|
||
Assigned the bug to Julien.
Assignee: wtc → jpierre
Priority: -- → P2
Target Milestone: --- → 3.6
Reporter | ||
Comment 2•22 years ago
|
||
With the current version of the tip, the peak memory for this test is 157 MB.
This is still too much, but a lot less than when the bug was first reported.
Comment 3•22 years ago
|
||
Julien, could you set some criteria for this bug
to be considered fixed?
Target Milestone: 3.6 → 3.7
Reporter | ||
Comment 4•22 years ago
|
||
Wan-Teh,
Ideally, the process shouldn't grow to more than 2x or 3x the size of the CRL to
be stored. That would amount to somewhere between 55 and 80 MB.
Comment 5•22 years ago
|
||
Moved to target milestone 3.8 because the original
NSS 3.7 release has been renamed 3.8.
Target Milestone: 3.7 → 3.8
Comment 6•22 years ago
|
||
Remove target milestone of 3.8, since these bugs didn't get into that release.
Target Milestone: 3.8 → ---
Assignee | ||
Comment 8•20 years ago
|
||
The additional copies of der crl are done in two functions, NewDBCrlEntry and
WriteDBCrlEntry, that get called from nsslowcert_UpdateCrl.
First one creates certDBEntryRevocation object and copies derCrl.data into its
derCrl. Then in the next line of nsslowcert_UpdateCrl we call WriteDBCrlEntry
which makes another copy by calling EncodeDBCrlEntry function.
The problem can be fixed by introducing a copy flag, similar to
CRL_DECODE_DONT_COPY_DER, like it is done in
CERT_DecodeDERCrlWithFlags.
Reporter | ||
Comment 9•20 years ago
|
||
Alexei,
The code you mentioned is in the softoken. Where would that new option be
getting passed from/to ? Are you sure a new option is required ? I think we
should try to get the code optimized without a new option, if possible.
Assignee | ||
Comment 10•20 years ago
|
||
Sorry for not clarifying it earlier.
I propose the modification of NewDBCrlEntry function parameters. But you are
right: this is a static function and it is called only from one place. We can
modify the body of the function instead of modification of parameters and
use the same memory derCrl.data is pointing to for certDBEntryRevocation
object.
*** pcertdb.c.~1.48.~ 2004-04-25 08:03:16.000000000 -0700
--- pcertdb.c 2005-03-17 14:44:42.000000000 -0800
***************
*** 1268,1274 ****
entry->derCrl.len = derCrl->len;
! PORT_Memcpy(entry->derCrl.data, derCrl->data, derCrl->len);
return(entry);
--- 1268,1274 ----
entry->derCrl.len = derCrl->len;
! entry->derCrl.data = derCrl->data;
return(entry);
Reporter | ||
Comment 11•20 years ago
|
||
Alexei,
Doesn't this change create a memory leak ?
If there was a memcpy, presumably entry->derCrl.data was already allocated. So,
just assigning the variable would leak the buffer.
Please show more of the code in future diffs. 10 lines of context (cvs -q diff
-u10) would be good.
Comment 12•20 years ago
|
||
Even for tiny little diff patches like the one in comment 10, it's a good
idea to attach them as patches to the bug. That way, the reviewer can
get bugzilla to display as much or as little context as he wants.
Assignee | ||
Comment 13•20 years ago
|
||
I didn't mean to include whole fix into the report. Memory allocation
for derCrl.data will be removed as well. The patch is attached.
Assignee | ||
Comment 14•20 years ago
|
||
Comment 15•20 years ago
|
||
Comment on attachment 177895 [details] [diff] [review]
the fix
We need to add a comment to NewDBCrlEntry and nsslowcert_UpdateCrl that the
entry must be destroyed before the derCRL goes out of scope.
It might be better to make 'NewDBCrlEntry' a function at takes a static
CrlEntry and initializes all the fields (setting arena to NULL).
Updated•19 years ago
|
QA Contact: bishakhabanerjee → jason.m.reid
Reporter | ||
Comment 16•19 years ago
|
||
Reassigning this bug to Alexei.
Assignee: julien.pierre.bugs → alexei.volkov.bugs
Updated•19 years ago
|
QA Contact: jason.m.reid → libraries
Assignee | ||
Updated•18 years ago
|
Priority: P3 → P2
Target Milestone: --- → 3.12
Assignee | ||
Comment 17•18 years ago
|
||
avoid memory allocation for certDBEntryRevocation data
Attachment #177895 -
Attachment is obsolete: true
Attachment #241761 -
Flags: review?(nelson)
Comment 18•18 years ago
|
||
Comment on attachment 241761 [details] [diff] [review]
skip extra data copy
This eliminates one allocation and copy.
Julien, is this sufficient?
Attachment #241761 -
Flags: review?(nelson)
Attachment #241761 -
Flags: review?
Attachment #241761 -
Flags: review+
Updated•18 years ago
|
Attachment #241761 -
Flags: review? → review?(julien.pierre.bugs)
Reporter | ||
Comment 19•18 years ago
|
||
Comment on attachment 241761 [details] [diff] [review]
skip extra data copy
This fix is good. I can't answer whether this is sufficient. When I filed the bug, I had been given a very large CRL (26 MB) that took CMS 4 hours to generate. I had then imported with crlutil, and noted that the process memory exploded - it allocated it about 6 times. PK11_PutCRL was one of the offenders.
I would suggest creating a large CRL again now that crlutil can do so, in much less time. Then observe the process VM size and see how many times the CRL size it is, and how much it grows from the time of before the call to PK11_PutCRL to after it returns.
I think ideally there should be zero copy in that function and thus little process growth. I'm not sure if the PKCS#11 layering actually allows that, but I think so.
Attachment #241761 -
Flags: review?(julien.pierre.bugs) → review+
Assignee | ||
Comment 20•18 years ago
|
||
/cvsroot/mozilla/security/nss/lib/softoken/pcertdb.c,v <-- pcertdb.c
new revision: 1.64; previous revision: 1.63
The patch eliminates one out of four in memory copies of importing CRL.
Assignee | ||
Comment 21•18 years ago
|
||
skipping entry decoding will be more efficient.
Attachment #256105 -
Flags: review?(nelson)
Comment 22•18 years ago
|
||
Comment on attachment 256105 [details] [diff] [review]
skipping crl entry decoding decoding
Alexei, have you committed the previously reviewed patch yet?
Attachment #256105 -
Flags: review?(nelson) → review+
Assignee | ||
Comment 23•18 years ago
|
||
previous patch was committed into trunk (see comment #20).
Assignee | ||
Comment 24•17 years ago
|
||
No additional work is foreseen for this bug. Closing..
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•