-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split CHIPClusters.cpp to speed up compilation. (#11091)
* Split CHIPClusters.cpp This splits up CHIPClusters.cpp into a couple of different files: - CHIPClusters.cpp contains no template specialized methods. - CHIPClustersInvoke.cpp contains all template specialized methods for invoking commands. - CHIPClustersWrite.cpp contains all template specialized methods for doing writes. This resulted in a speed-up of about 30s (from 1m50s to 1m20s) when doing an incremental compilation of chip-tool after touching CHIPClusters.cpp. It does this by better leveraging -jX builds to parallelize compilation. More importantly, this might also provide a pattern for others (like Android) that is running into OOM issues with clang compiling CHIPClusters.cpp. * Apply suggestions from code review Co-authored-by: Boris Zbarsky <[email protected]> * Fix regen breakaga * Address review feedback Co-authored-by: Justin Wood <[email protected]> Co-authored-by: Boris Zbarsky <[email protected]>
- Loading branch information
1 parent
e7c1d2b
commit 1e27d92
Showing
40 changed files
with
2,786 additions
and
1,975 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/app/zap-templates/templates/app/CHIPClustersInvoke-src.zapt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{{> header}} | ||
|
||
{{#if (chip_has_client_clusters)}} | ||
#include "CHIPClusters.h" | ||
|
||
#include <app-common/zap-generated/cluster-objects.h> | ||
#include <app-common/zap-generated/ids/Attributes.h> | ||
|
||
namespace chip { | ||
|
||
using namespace app::Clusters; | ||
using namespace System; | ||
using namespace Encoding::LittleEndian; | ||
|
||
namespace Controller { | ||
|
||
{{#chip_client_clusters}} | ||
|
||
{{#chip_cluster_commands}} | ||
{{#*inline "requestType"}}chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::Type{{/inline}} | ||
{{#*inline "responseType"}}chip::app::{{#if hasSpecificResponse}}Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase response.name}}::DecodableType{{else}}DataModel::NullObjectType{{/if}}{{/inline}} | ||
template CHIP_ERROR ClusterBase::InvokeCommand<{{>requestType}}, {{>responseType}}>(const {{>requestType}} &, void *, CommandResponseSuccessCallback<{{>responseType}}>, CommandResponseFailureCallback); | ||
{{/chip_cluster_commands}} | ||
{{/chip_client_clusters}} | ||
|
||
template <typename RequestDataT, typename ResponseDataT> | ||
CHIP_ERROR ClusterBase::InvokeCommand(const RequestDataT & requestData, void * context, | ||
CommandResponseSuccessCallback<ResponseDataT> successCb, CommandResponseFailureCallback failureCb) | ||
{ | ||
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); | ||
ReturnErrorOnFailure(mDevice->LoadSecureSessionParametersIfNeeded()); | ||
|
||
auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const app::StatusIB & aStatus, const ResponseDataT & responseData) { | ||
successCb(context, responseData); | ||
}; | ||
|
||
auto onFailureCb = [context, failureCb](const app::StatusIB & aStatus, CHIP_ERROR aError) { | ||
failureCb(context, app::ToEmberAfStatus(aStatus.mStatus)); | ||
}; | ||
|
||
return InvokeCommandRequest<ResponseDataT>(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(), mEndpoint, | ||
requestData, onSuccessCb, onFailureCb); | ||
}; | ||
|
||
} // namespace Controller | ||
} // namespace chip | ||
{{/if}} |
57 changes: 57 additions & 0 deletions
57
src/app/zap-templates/templates/app/CHIPClustersWrite-src.zapt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{{> header}} | ||
|
||
{{#if (chip_has_client_clusters)}} | ||
#include "CHIPClusters.h" | ||
|
||
#include <app-common/zap-generated/cluster-objects.h> | ||
#include <app-common/zap-generated/ids/Attributes.h> | ||
|
||
namespace chip { | ||
|
||
using namespace app::Clusters; | ||
using namespace System; | ||
using namespace Encoding::LittleEndian; | ||
|
||
namespace Controller { | ||
|
||
{{#chip_client_clusters}} | ||
|
||
// {{asUpperCamelCase name}} Cluster Attributes | ||
{{#chip_server_cluster_attributes}} | ||
{{#if isWritableAttribute}} | ||
{{#*inline "attributeTypeInfo"}}chip::app::Clusters::{{asUpperCamelCase parent.name}}::Attributes::{{asUpperCamelCase name}}::TypeInfo{{/inline}} | ||
template CHIP_ERROR ClusterBase::WriteAttribute<{{>attributeTypeInfo}}>(const {{>attributeTypeInfo}}::Type & requestData, void *context, | ||
WriteResponseSuccessCallback successCb, WriteResponseFailureCallback failureCb); | ||
{{/if}} | ||
{{/chip_server_cluster_attributes}} | ||
{{/chip_client_clusters}} | ||
|
||
template <typename AttributeInfo> | ||
CHIP_ERROR ClusterBase::WriteAttribute(const typename AttributeInfo::Type & requestData, void * context, | ||
WriteResponseSuccessCallback successCb, WriteResponseFailureCallback failureCb) | ||
{ | ||
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); | ||
ReturnErrorOnFailure(mDevice->LoadSecureSessionParametersIfNeeded()); | ||
|
||
auto onSuccessCb = [context, successCb](const app::ConcreteAttributePath & commandPath) { | ||
if (successCb != nullptr) | ||
{ | ||
successCb(context); | ||
} | ||
}; | ||
|
||
auto onFailureCb = [context, failureCb](const app::ConcreteAttributePath * commandPath, | ||
app::StatusIB status, CHIP_ERROR aError) { | ||
if (failureCb != nullptr) | ||
{ | ||
failureCb(context, app::ToEmberAfStatus(status.mStatus)); | ||
} | ||
}; | ||
|
||
return chip::Controller::WriteAttribute<AttributeInfo>(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(), mEndpoint, | ||
requestData, onSuccessCb, onFailureCb); | ||
} | ||
|
||
} // namespace Controller | ||
} // namespace chip | ||
{{/if}} |
18 changes: 18 additions & 0 deletions
18
zzz_generated/all-clusters-app/zap-generated/CHIPClustersInvoke.cpp
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
zzz_generated/all-clusters-app/zap-generated/CHIPClustersWrite.cpp
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
zzz_generated/bridge-app/zap-generated/CHIPClustersInvoke.cpp
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
zzz_generated/bridge-app/zap-generated/CHIPClustersWrite.cpp
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.