-
Notifications
You must be signed in to change notification settings - Fork 17
[loadgen] LoadGen without committer #70
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,17 @@ | ||
| # Copyright IBM Corp. All Rights Reserved. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # This is a partial template. It contains only the orderer client configurations. | ||
| # It should be complimented by the common load generator configuration. | ||
|
|
||
| orderer-client: | ||
| orderer: | ||
| connection: | ||
| endpoints: | ||
| {{- range .Endpoints.Orderer }} | ||
| - {{ .Server }} | ||
| {{- end }} | ||
| consensus-type: BFT | ||
| channel-id: {{ .ChannelID }} | ||
| broadcast-parallelism: 5 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -24,37 +24,56 @@ import ( | |
| "github.com/hyperledger/fabric-x-committer/utils/serialization" | ||
| ) | ||
|
|
||
| type receiverConfig struct { | ||
| type sidecarReceiverConfig struct { | ||
| Endpoint *connection.Endpoint | ||
| ChannelID string | ||
| Res *ClientResources | ||
| } | ||
|
|
||
| const committedBlocksQueueSize = 1024 | ||
| const statusIdx = int(common.BlockMetadataIndex_TRANSACTIONS_FILTER) | ||
|
|
||
| // runReceiver start receiving blocks from the sidecar. | ||
| func runReceiver(ctx context.Context, config *receiverConfig) error { | ||
| // runSidecarReceiver start receiving blocks from the sidecar. | ||
| func runSidecarReceiver(ctx context.Context, config *sidecarReceiverConfig) error { | ||
| ledgerReceiver, err := sidecarclient.New(&sidecarclient.Config{ | ||
| ChannelID: config.ChannelID, | ||
| Endpoint: config.Endpoint, | ||
| }) | ||
| if err != nil { | ||
| return errors.Wrap(err, "failed to create ledger receiver") | ||
| } | ||
|
|
||
| g, gCtx := errgroup.WithContext(ctx) | ||
| committedBlock := make(chan *common.Block, committedBlocksQueueSize) | ||
| g.Go(func() error { | ||
| return runDeliveryReceiver(ctx, config.Res, func(gCtx context.Context, committedBlock chan *common.Block) error { | ||
| return ledgerReceiver.Deliver(gCtx, &sidecarclient.DeliverConfig{ | ||
| EndBlkNum: broadcastdeliver.MaxBlockNum, | ||
| OutputBlock: committedBlock, | ||
| }) | ||
| }) | ||
| } | ||
|
|
||
| // runOrdererReceiver start receiving blocks from the orderer. | ||
| func runOrdererReceiver(ctx context.Context, res *ClientResources, client *broadcastdeliver.Client) error { | ||
| return runDeliveryReceiver(ctx, res, func(gCtx context.Context, committedBlock chan *common.Block) error { | ||
| return client.Deliver(gCtx, &broadcastdeliver.DeliverConfig{ | ||
| EndBlkNum: broadcastdeliver.MaxBlockNum, | ||
| OutputBlock: committedBlock, | ||
| }) | ||
| }) | ||
| } | ||
|
|
||
| // runDeliveryReceiver start receiving blocks from a delivery service. | ||
| func runDeliveryReceiver( | ||
| ctx context.Context, res *ClientResources, deliver func(context.Context, chan *common.Block) error, | ||
| ) error { | ||
| g, gCtx := errgroup.WithContext(ctx) | ||
| committedBlock := make(chan *common.Block, committedBlocksQueueSize) | ||
| g.Go(func() error { | ||
| receiveCommittedBlock(gCtx, committedBlock, config.Res) | ||
| return deliver(gCtx, committedBlock) | ||
| }) | ||
| g.Go(func() error { | ||
| receiveCommittedBlock(gCtx, committedBlock, res) | ||
| return context.Canceled | ||
| }) | ||
| return errors.Wrap(g.Wait(), "sidecar receiver done") | ||
| return errors.Wrap(g.Wait(), "receiver done") | ||
|
liran-funaro marked this conversation as resolved.
|
||
| } | ||
|
|
||
| func receiveCommittedBlock( | ||
|
|
@@ -74,29 +93,7 @@ func receiveCommittedBlock( | |
| if !ok { | ||
| return | ||
| } | ||
|
|
||
| statusCodes := block.Metadata.Metadata[common.BlockMetadataIndex_TRANSACTIONS_FILTER] | ||
| logger.Infof("Received block #%d with %d TXs and %d statuses [%s]", | ||
| block.Header.Number, len(block.Data.Data), len(statusCodes), recapStatusCodes(statusCodes), | ||
| ) | ||
|
|
||
| statusBatch := make([]metrics.TxStatus, 0, len(block.Data.Data)) | ||
| for i, data := range block.Data.Data { | ||
| _, channelHeader, err := serialization.UnwrapEnvelope(data) | ||
| if err != nil { | ||
| logger.Warnf("Failed to unmarshal envelope: %v", err) | ||
| continue | ||
| } | ||
| if common.HeaderType(channelHeader.Type) == common.HeaderType_CONFIG { | ||
| // We can ignore config transactions as we only count data transactions. | ||
| continue | ||
| } | ||
| statusBatch = append(statusBatch, metrics.TxStatus{ | ||
| TxID: channelHeader.TxId, | ||
| Status: protoblocktx.Status(statusCodes[i]), | ||
| }) | ||
| } | ||
| processedBlocks.Write(statusBatch) | ||
| processedBlocks.Write(mapToStatusBatch(block)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use multiple goroutines to process the committed status as we are unmarshaling the envelope. Otherwise, this could increase the latency unnecessarily. |
||
| } | ||
| }() | ||
|
|
||
|
|
@@ -112,6 +109,44 @@ func receiveCommittedBlock( | |
| } | ||
| } | ||
|
|
||
| // mapToStatusBatch creates a status batch from a given block. | ||
| func mapToStatusBatch(block *common.Block) []metrics.TxStatus { | ||
| if block.Data == nil || len(block.Data.Data) == 0 { | ||
| return nil | ||
| } | ||
| blockSize := len(block.Data.Data) | ||
|
|
||
| var statusCodes []byte | ||
| if block.Metadata != nil && len(block.Metadata.Metadata) > statusIdx { | ||
| statusCodes = block.Metadata.Metadata[statusIdx] | ||
| } | ||
| logger.Infof("Received block #%d with %d TXs and %d statuses [%s]", | ||
| block.Header.Number, len(block.Data.Data), len(statusCodes), recapStatusCodes(statusCodes), | ||
| ) | ||
|
|
||
| statusBatch := make([]metrics.TxStatus, 0, blockSize) | ||
| for i, data := range block.Data.Data { | ||
| _, channelHeader, err := serialization.UnwrapEnvelope(data) | ||
| if err != nil { | ||
| logger.Warnf("Failed to unmarshal envelope: %v", err) | ||
| continue | ||
| } | ||
| if common.HeaderType(channelHeader.Type) == common.HeaderType_CONFIG { | ||
| // We can ignore config transactions as we only count data transactions. | ||
| continue | ||
| } | ||
| status := protoblocktx.Status_COMMITTED | ||
| if len(statusCodes) > i { | ||
| status = protoblocktx.Status(statusCodes[i]) | ||
| } | ||
| statusBatch = append(statusBatch, metrics.TxStatus{ | ||
| TxID: channelHeader.TxId, | ||
| Status: status, | ||
| }) | ||
| } | ||
| return statusBatch | ||
| } | ||
|
|
||
| // recapStatusCodes recaps of the status codes of a block. | ||
| func recapStatusCodes(statusCodes []byte) string { | ||
| codes := make(map[byte]uint64) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have an issue to parallelize this. This change may make it hard to achieve that.