Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: Add benchmarking for encryption/decryption #32

Merged
merged 7 commits into from
Nov 7, 2024

Conversation

Anupam-1208
Copy link
Contributor

@Anupam-1208 Anupam-1208 commented Nov 1, 2024

original issue: [https://github.com/juspay/hyperswitch/issues/6228]

Added benchmarking for Single and Batch data for variable input sizes

Features:

  • Single data of variable sizes
  • Batch data of variable number of Input for fixed size data
  • Input size can be adjusted before benchmarking

Sample Benchmark:
Screenshot 2024-11-04 at 11 45 58 AM

pub fn criterion_data_encryption_decryption(c: &mut Criterion) {
let rt = Runtime::new().unwrap();
let custodian = Custodian::new(Some(("key".to_string(),"value".to_string())));
let config = config::Config::with_config_path(config::Environment::which(), None);
Copy link
Member

Choose a reason for hiding this comment

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

You can directly use Environment::Dev

Copy link
Contributor Author

@Anupam-1208 Anupam-1208 Nov 4, 2024

Choose a reason for hiding this comment

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

Sure, Will update code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, please check the code, also create Key using the curl below

let identifier = Identifier::User(String::from("user_12345"));

{
let mut group = c.benchmark_group("data-encryption-single");
Copy link
Member

Choose a reason for hiding this comment

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

Can you create the key user_12345 in the DB before running the bench

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I created a new DataKey using the following api and ran the benchmark, will update the description

curl --location 'localhost:5000/key/create' \
--header 'Content-type: application/json' \
--data '{
  "data_identifier": "User",
  "key_identifier": "user_12345"
}'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2024-11-04 at 11 45 58 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dracarys18 added the logic to create user at the time of running benchmark. Can you review it again?

@dracarys18
Copy link
Member

Hey @Anupam-1208 Thanks for the PR! I am getting the following error during my first ever run, Likely due to my second comment, Please take a look

Failed while encrypting: Failed to Get the data key
├╴at src/errors/crypto.rs:40:32
│
╰─▶ Failed to get the value from the database
    ╰╴at src/errors/db.rs:45:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

dracarys18
dracarys18 previously approved these changes Nov 6, 2024
Copy link
Member

@dracarys18 dracarys18 left a comment

Choose a reason for hiding this comment

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

LGTM!

@dracarys18 dracarys18 changed the title [FEAT] Add benchmarking for encryption/decryption #6228 feat: Add benchmarking for encryption/decryption Nov 6, 2024
@dracarys18 dracarys18 linked an issue Nov 6, 2024 that may be closed by this pull request
@dracarys18
Copy link
Member

@Anupam-1208 Please fix formatting and clippy errors

Copy link
Collaborator

@ArjunKarthik ArjunKarthik left a comment

Choose a reason for hiding this comment

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

@Anupam-1208 Please fix failing CI checks.

@Anupam-1208
Copy link
Contributor Author

@dracarys18 @ArjunKarthik added formatting changes

Copy link
Collaborator

@ArjunKarthik ArjunKarthik left a comment

Choose a reason for hiding this comment

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

LGTM

@dracarys18
Copy link
Member

Thanks for the contribution @Anupam-1208

@dracarys18 dracarys18 merged commit 22c0f64 into juspay:main Nov 7, 2024
2 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] Add benchmarking for encryption/decryption
5 participants