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

Optimization: encode hash to hex only on log TRACE level set #6338

Merged
merged 6 commits into from
Nov 14, 2024

Conversation

cristure
Copy link
Contributor

@cristure cristure commented Jul 29, 2024

Reasoning behind the pull request

Reasonable optimization on trie updates. Improved update times by roughly 30%.

Before fix:

cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
BenchmarkPatriciaMerkleTrie_Update-8   	      50	2007485284 ns/op
ok  	github.com/multiversx/mx-chain-go/trie	131.749s

BenchmarkPatriciaMerkleTrie_Update-8   	      50	1991358120 ns/op
ok  	github.com/multiversx/mx-chain-go/trie	132.290s

After fix:

BenchmarkPatriciaMerkleTrie_Update-8   	      50	1342203572 ns/op
ok  	github.com/multiversx/mx-chain-go/trie	95.049s

BenchmarkPatriciaMerkleTrie_Update-8   	      50	1381106022 ns/op
ok  	github.com/multiversx/mx-chain-go/trie	97.326s

Proposed changes

  • Added if statement before logging.

Testing procedure

  • go test -run=^$ -bench ^BenchmarkPatriciaMerkleTrie_Update$ -benchtime=10x
  • Observe times with from the target branch and compare with the times from this branch.
  • Standard testing

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

andreibancioiu
andreibancioiu previously approved these changes Jul 29, 2024
@cristure cristure changed the title calculate hash only on log trace level set. Encode hash to hex only on log trace level set. Jul 29, 2024
@AdoAdoAdo AdoAdoAdo changed the base branch from master to rc/v1.7.next1 September 3, 2024 12:16
@@ -1708,3 +1709,32 @@ func BenchmarkPatriciaMerkleTrie_RootHashAfterChanging30000NodesInBatchesOf200(b
}
}
}

func TestTrieUpdateTimer(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This unit test:

  • is skipped
  • has no assertions
  • does a print line

Instead, let's get the output of this test, or of the existing benchmarks - before & after the fix, and put the output (textual) in the PR description. Then, we can drop this test.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, we can remove the test after we have the results.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fixed (transformed into a benchmark test).

Copy link

github-actions bot commented Sep 3, 2024

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: 79eb08c6d7da0182703b1e69001a08e112416247
  • Current Branch: benchmark_trie
  • mx-chain-go Target Branch: rc/v1.7.next1
  • mx-chain-simulator-go Target Branch: rc/v1.7.next1
  • mx-chain-testing-suite Target Branch: rc/v1.7.next1

🚀 Environment Variables:

  • TIMESTAMP: 03092024-122609
  • PYTEST_EXIT_CODE: 0
    🎉 MultiversX CI/CD Workflow Complete!

Copy link

github-actions bot commented Sep 6, 2024

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: 1ec7c5c3d5100fcce8efd2ea26ac317ffd1c2307
  • Current Branch: benchmark_trie
  • mx-chain-go Target Branch: rc/v1.7.next1
  • mx-chain-simulator-go Target Branch: rc/v1.7.next1
  • mx-chain-testing-suite Target Branch: rc/v1.7.next1

🚀 Environment Variables:

  • TIMESTAMP: 06092024-100651
  • PYTEST_EXIT_CODE: 0
    🎉 MultiversX CI/CD Workflow Complete!

@andreibancioiu andreibancioiu changed the title Encode hash to hex only on log trace level set. Optimization: encode hash to hex only on log TRACE level set Sep 6, 2024
Copy link

github-actions bot commented Sep 6, 2024

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: af01f4a9e49a2630c1bd2fe5332b827de5026906
  • Current Branch: benchmark_trie
  • mx-chain-go Target Branch: rc/v1.7.next1
  • mx-chain-simulator-go Target Branch: rc/v1.7.next1
  • mx-chain-testing-suite Target Branch: rc/v1.7.next1

🚀 Environment Variables:

  • TIMESTAMP: 06092024-121259
  • PYTEST_EXIT_CODE: 0
    🎉 MultiversX CI/CD Workflow Complete!

@andreibancioiu andreibancioiu changed the base branch from rc/v1.7.next1 to MX-16107-no-more-notify November 14, 2024 17:25
@andreibancioiu andreibancioiu merged commit 6a80857 into MX-16107-no-more-notify Nov 14, 2024
6 checks passed
@andreibancioiu andreibancioiu deleted the benchmark_trie branch November 14, 2024 17:25
Copy link

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: bc70dccf1e96200e88b3dd4e7af9f1a3da6dc5da
  • Current Branch: benchmark_trie
  • mx-chain-go Target Branch: rc/v1.7.next1
  • mx-chain-simulator-go Target Branch: rc/v1.7.next1
  • mx-chain-testing-suite Target Branch: rc/v1.7.next1

🚀 Environment Variables:

  • TIMESTAMP: 14112024-173533
  • PYTEST_EXIT_CODE: 0
    🎉 MultiversX CI/CD Workflow Complete!

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.

4 participants