Bug 153779

Summary: Fix authentication with NetworkSession
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: New BugsAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: beidson
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch beidson: review+

Description Alex Christensen 2016-02-01 16:32:38 PST
Fix authentication with NetworkSession
Comment 1 Alex Christensen 2016-02-01 17:21:53 PST
Created attachment 270456 [details]
Patch
Comment 2 Brady Eidson 2016-02-02 14:56:54 PST
Comment on attachment 270456 [details]
Patch

This looks good.

I am concerned about the footprint ramifications of creating two NSURLSessions per SessionID as opposed to one. If a user has many private browsing tabs, that's almost doubling their NetworkProcess memory footprint.

PROBABLY not a big deal... unless it IS a big deal. In which case we need to know.

I asked Alex to try to gather some footprint metrics.
Comment 3 Alex Christensen 2016-02-02 15:11:54 PST
I estimate each unused NSURLSession to use about 3 KB of memory based on the following data:

// clang++ memtest.mm -framework Foundation && ./a.out

#import <Foundation/NSOperation.h>
#import <Foundation/NSURL.h>
#import <Foundation/NSURLCredential.h>
#import <Foundation/NSURLSession.h>

int main() {
	/*
	numSessions  memory footprint
	0              0.69 MB
	100            1.4  MB
	1000           4.3  MB
	10000         33.8  MB
	100000       329.6  MB
	*/
    const int numSessions = 100000;
    for (int i=0;i<numSessions;i++) {
        NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration] delegate:nil delegateQueue:[NSOperationQueue mainQueue]];
        [session retain];
	}
	while(1);
    return 0;
}
Comment 4 Brady Eidson 2016-02-02 15:14:13 PST
(In reply to comment #3)
> I estimate each unused NSURLSession to use about 3 KB of memory based on the
> following data:
> 
> // clang++ memtest.mm -framework Foundation && ./a.out
> 
> #import <Foundation/NSOperation.h>
> #import <Foundation/NSURL.h>
> #import <Foundation/NSURLCredential.h>
> #import <Foundation/NSURLSession.h>
> 
> int main() {
> 	/*
> 	numSessions  memory footprint
> 	0              0.69 MB
> 	100            1.4  MB
> 	1000           4.3  MB
> 	10000         33.8  MB
> 	100000       329.6  MB
> 	*/
>     const int numSessions = 100000;
>     for (int i=0;i<numSessions;i++) {
>         NSURLSession *session = [NSURLSession
> sessionWithConfiguration:[NSURLSessionConfiguration
> ephemeralSessionConfiguration] delegate:nil delegateQueue:[NSOperationQueue
> mainQueue]];
>         [session retain];
> 	}
> 	while(1);
>     return 0;
> }

I don't know what the threshold is for "too big", but that's definitely under it.

R+
Comment 5 Alex Christensen 2016-02-02 15:43:06 PST
http://trac.webkit.org/changeset/196034