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

Perf: Make enclave key map lazy initialized #372

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private enum EXECTYPE
// cached metadata
private _SqlMetaDataSet _cachedMetaData;

private Dictionary<int, SqlTceCipherInfoEntry> keysToBeSentToEnclave = new Dictionary<int, SqlTceCipherInfoEntry>();
private Dictionary<int, SqlTceCipherInfoEntry> keysToBeSentToEnclave;
karinazhou marked this conversation as resolved.
Show resolved Hide resolved
private bool requiresEnclaveComputations = false;
internal EnclavePackage enclavePackage = null;
private SqlEnclaveAttestationParameters enclaveAttestationParameters = null;
Expand Down Expand Up @@ -2994,8 +2994,10 @@ private void ResetEncryptionState()
_parameters[i].HasReceivedMetadata = false;
}
}

keysToBeSentToEnclave.Clear();
if (keysToBeSentToEnclave != null)
{
keysToBeSentToEnclave.Clear();
}
enclavePackage = null;
requiresEnclaveComputations = false;
enclaveAttestationParameters = null;
Expand Down Expand Up @@ -3728,10 +3730,14 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
{
throw SQL.InvalidEncryptionKeyOrdinalEnclaveMetadata(requestedKey, columnEncryptionKeyTable.Count);
}

if (!keysToBeSentToEnclave.ContainsKey(currentOrdinal))
if (keysToBeSentToEnclave == null)
{
keysToBeSentToEnclave = new Dictionary<int, SqlTceCipherInfoEntry>();
keysToBeSentToEnclave.Add(currentOrdinal, cipherInfo);
}
else if (!keysToBeSentToEnclave.ContainsKey(currentOrdinal))
{
this.keysToBeSentToEnclave.Add(currentOrdinal, cipherInfo);
keysToBeSentToEnclave.Add(currentOrdinal, cipherInfo);
}

requiresEnclaveComputations = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private enum EXECTYPE
// cached metadata
private _SqlMetaDataSet _cachedMetaData;

private Dictionary<int, SqlTceCipherInfoEntry> keysToBeSentToEnclave = new Dictionary<int, SqlTceCipherInfoEntry>();
private Dictionary<int, SqlTceCipherInfoEntry> keysToBeSentToEnclave;
karinazhou marked this conversation as resolved.
Show resolved Hide resolved
private bool requiresEnclaveComputations = false;
internal EnclaveDelegate.EnclavePackage enclavePackage = null;
private SqlEnclaveAttestationParameters enclaveAttestationParameters = null;
Expand Down Expand Up @@ -3872,7 +3872,10 @@ private void ResetEncryptionState()
}
}

keysToBeSentToEnclave.Clear();
if (keysToBeSentToEnclave != null)
{
keysToBeSentToEnclave.Clear();
}
enclavePackage = null;
requiresEnclaveComputations = false;
enclaveAttestationParameters = null;
Expand Down Expand Up @@ -4666,9 +4669,14 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
throw SQL.InvalidEncryptionKeyOrdinalEnclaveMetadata(requestedKey, columnEncryptionKeyTable.Count);
}

if (!keysToBeSentToEnclave.ContainsKey(currentOrdinal))
if (keysToBeSentToEnclave == null)
{
keysToBeSentToEnclave = new Dictionary<int, SqlTceCipherInfoEntry>();
keysToBeSentToEnclave.Add(currentOrdinal, cipherInfo);
}
else if (!keysToBeSentToEnclave.ContainsKey(currentOrdinal))
{
this.keysToBeSentToEnclave.Add(currentOrdinal, cipherInfo);
keysToBeSentToEnclave.Add(currentOrdinal, cipherInfo);
}

requiresEnclaveComputations = true;
Expand Down