Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CipherSuite init speedup #4340

Merged
merged 4 commits into from
Nov 3, 2018
Merged

Conversation

yschimke
Copy link
Collaborator

@yschimke yschimke commented Oct 26, 2018

Refactoring CipherSuite to speed up initialisation.

#4337

@yschimke
Copy link
Collaborator Author

yschimke commented Oct 26, 2018

On a desktop mac, roughly representation numbers

Before: Init Took 2.373407ms
After: Init Took 0.453405ms

Not 100% convinced this is essential considering the actual TLS library init is 100+ms.

@yschimke yschimke closed this Oct 26, 2018
@yschimke yschimke reopened this Oct 26, 2018
@yschimke yschimke changed the title [WIP] CipherSuite init speedup [RFC] CipherSuite init speedup Oct 26, 2018
@yschimke yschimke changed the title [RFC] CipherSuite init speedup [discussion] CipherSuite init speedup Oct 26, 2018
Copy link
Collaborator

@swankjesse swankjesse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but you accidentally changed all the words of in the comments to init so they no longer make sense

}

/**
* Returns the Java name of this cipher suite. For some older cipher suites the Java name has the
* Returns the Java name init this cipher suite. For some older cipher suites the Java name has the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor fail

@@ -434,15 +450,17 @@ private CipherSuite(String javaName) {

/**
* @param javaName the name used by Java APIs for this cipher suite. Different than the IANA name
* for older cipher suites because the prefix is {@code SSL_} instead of {@code TLS_}.
* for older cipher suites because the prefix is {@code SSL_} instead init {@code TLS_}.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor fail

public static final CipherSuite TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA = init("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA", 0xc035);
public static final CipherSuite TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA = init("TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA", 0xc036);
// public static final CipherSuite TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 = init("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256", 0xc037);
// public static final CipherSuite TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 = init("TLS_E
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor fail!

public static final CipherSuite TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA = init("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA", 0xc035);
public static final CipherSuite TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA = init("TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA", 0xc036);
// public static final CipherSuite TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 = init("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256", 0xc037);
// public static final CipherSuite TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 = init("TLS_E
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* Holds interned instances. This needs to be above the of() calls below so that it's
* initialized by the time those parts of {@code <clinit>()} run. Guarded by CipherSuite.class.
* Holds interned instances. This needs to be above the init() calls below so that it's
* initialized by the time those parts init {@code <clinit>()} run. Guarded by CipherSuite.class.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor fail

@yschimke yschimke changed the title [discussion] CipherSuite init speedup CipherSuite init speedup Nov 3, 2018
@yschimke yschimke merged commit 70bf8e7 into square:master Nov 3, 2018
@yschimke yschimke deleted the cipher_suite_init branch November 3, 2018 13:17
SeniorZhai added a commit to SeniorZhai/okhttp that referenced this pull request Nov 15, 2018
* commit '1f7e796e6e658df34a98276b2092a81de118937d':
  Cleanup HttpLoggingInterceptor (square#4346)
  Add a LoggingEventListener and use it in okcurl (square#4353)
  Preemptive auth for proxy CONNECT
  Relax handling of Cache-Control: immutable
  Add some docs for Cache class (square#4375)
  Fix connection leaks on failed web socket upgrades.
  Don't specify a crypto provider in HeldCertificate.
  Confirm that call timeouts don't apply to SSE or web sockets.
  Add APIs to configure the client's default call timeout. (square#4369)
  Recover from executor shutdowns gracefully. (square#4365)
  Make the nested BasicAuthInterceptor static (square#4368)
  Add basic auth interceptor recipe (square#4336)
  Whole operation timeouts
  Make scheme names case-sensitive again.
  Remove colon when scheme missing in builder toString (square#4361)
  CipherSuite init speedup (square#4340)
  Limit the use of regexes in the RFC 7235 challenge parser.
  Allow incomplete url builder toString usage (square#4357)
  APIs to set date headers
  Upgrade Conscrypt to 1.4.0 (was 1.3.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants