Open Bug 283763 Opened 19 years ago Updated 1 year ago

memsets in libssl affect performance ; SSL buffer also starts too small

Categories

(NSS :: Libraries, enhancement, P2)

3.9.5
enhancement

Tracking

(Not tracked)

People

(Reporter: julien.pierre, Unassigned)

Details

(Keywords: perf)

Attachments

(1 file, 1 obsolete file)

Performance profile data shows that several cleanup calls memset in libssl
affect performance significantly.
We may want to retain these memset calls for security purposes. However, when
it's time for running benchmarks, these calls should be removed . We need to
have a way to run the code less securely without them. This should probably be a
runtime setting ...

Another observation is that we call PORT_Realloc twice for really small amounts
(from 79 to 86 to 150 bytes) in sslBuffer_Grow . We should increase the default
minimum size to avoid those calls.

I will attach a patch that addresses both of these issues.
Not meant to be checked in as is; the memset need a dynamic setting.
Severity: normal → enhancement
Priority: -- → P2
Target Milestone: --- → 3.10
Comment on attachment 175623 [details] [diff] [review]
remove cleanup memset calls, and increase default SSL buffer size

>+    newLen = PR_MAX(newLen, 18432);

Would be nice to define a macro for the magic
number 18432.
Comment on attachment 175623 [details] [diff] [review]
remove cleanup memset calls, and increase default SSL buffer size

Julien,  Your patch removes two memsets, believing that they are only for
"security" and not necessary for correctness.  But one of them is needed
for correctness.  

Both of these memsets clear structures that were separately malloc'ed at 
one time, but are now parts of the larger SSLSocket structure.	That change 
was made to reduce malloc calls, which as you know is something we want 
to do MORE of.	These memsets took the place of PORT_ZFree calls that 
preceeded that change.	

The second of these two removed memsets only occurs when the socket is 
being closed, and is only to prevent sensitive info from remaining in 
memory after close.  But the first is used in a function that may be 
called repeatedly on an SSLSocket that is in use.  It is called from 
SSL_ResetHandshake, and removing that memset stops SSL_ResetHandshake 
from working properly.	When called from SSL_ResetHandshake, 
the first memset must be done.

The first of the two modified functions is also called from the second, 
which means that the first memset is overlapped by the second one.  
I propose adding an argument to the first function, which is internal,
that tells it whether or not to do that memset.
Comment on attachment 175623 [details] [diff] [review]
remove cleanup memset calls, and increase default SSL buffer size

BTW, the comment just above function ssl_DestroySecurityInfo is 
incorrect.  It is not called from SSL_ResetHandshake.  It is the
previous function that is called from SSL_ResetHandshake.
So, when this bug is fixed, that comment should be fixed too.

> /*
> ** Called from SSL_ResetHandshake (above), and 
> **        from ssl_FreeSocket     in sslsock.c
Attachment #175623 - Flags: review-
still not for checkin
Attachment #175623 - Attachment is obsolete: true
QA Contact: bishakhabanerjee → jason.m.reid
This work is planned for 3.11
Target Milestone: 3.10 → 3.11
QA Contact: jason.m.reid → libraries
remove target milestone, since the target was missed.
Target Milestone: 3.11 → ---
Keywords: perf
Severity: normal → S3

The bug assignee is inactive on Bugzilla, and this bug has priority 'P2'.
:beurdouche, could you have a look please?

For more information, please visit auto_nag documentation.

Assignee: nelson → nobody
Flags: needinfo?(bbeurdouche)

We have modified the bot to only consider P1 as high priority, so I'm cancelling the needinfo here.

Flags: needinfo?(bbeurdouche)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: