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

producer_worker: revert use of ValueGenerator::Generate() #63

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

WillemKauf
Copy link
Contributor

@WillemKauf WillemKauf commented Dec 12, 2024

Using the modified ValueGenerator::Generate() function for each record in the producer_worker was a lot slower than just simply making an empty payload.

The following benchmarks were generated:

Benchmark_random_payload10-32           	 2445903	        485.2 ns/op
Benchmark_random_payload100-32           	  678870	         1773 ns/op
Benchmark_random_payload1000-32           	  105667	        13700 ns/op
Benchmark_random_payload1e4-32          	    9104	       126782 ns/op
Benchmark_random_payload1e5-32          	    1135	      1151425 ns/op
Benchmark_random_payload1e6-32          	     100	     13046547 ns/op
====================================================================================
Benchmark_empty_payload10-32            	79950942	        20.54 ns/op
Benchmark_empty_payload100-32            	24089101	        54.78 ns/op
Benchmark_empty_payload1000-32            	 3789248	        366.1 ns/op
Benchmark_empty_payload1e4-32           	  670096	         2059 ns/op
Benchmark_empty_payload1e5-32           	   58912	        23021 ns/op
Benchmark_empty_payload1e6-32           	    5600	       290045 ns/op

As can be seen, generating the random payload and ensuring it is UTF-8 valid is orders of magnitude slower than the empty payload.

Revert the use of Generate() here in place of the empty payload.

However, if the user has indicated they want to validate the latest key-value pair produced, generate a (value-{%018d}, offset) message in the record.

This does mean that message sizes that are less than 24 bytes are not honored if the validate-latest-values flag is passed.

andrwng
andrwng previously approved these changes Dec 12, 2024
Copy link

@andrwng andrwng left a comment

Choose a reason for hiding this comment

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

nit: the numbers would go well in the commit message too IMO, for git history spelunking

andrwng
andrwng previously approved these changes Dec 12, 2024
Using the modified `Generate()` function was a lot slower than just simply making
an empty payload:

```
Benchmark_random_payload10-32    2445903       485.2 ns/op
Benchmark_random_payload100-32    678870        1773 ns/op
Benchmark_random_payload1000-32   105667       13700 ns/op
Benchmark_random_payload1e4-32      9104      126782 ns/op
Benchmark_random_payload1e5-32      1135     1151425 ns/op
Benchmark_random_payload1e6-32       100    13046547 ns/op
==========================================================
Benchmark_empty_payload10-32    79950942       20.54 ns/op
Benchmark_empty_payload100-32   24089101       54.78 ns/op
Benchmark_empty_payload1000-32   3789248       366.1 ns/op
Benchmark_empty_payload1e4-32     670096        2059 ns/op
Benchmark_empty_payload1e5-32      58912       23021 ns/op
Benchmark_empty_payload1e6-32       5600      290045 ns/op
```

As can be seen, generating the random payload and ensuring it is UTF-8 valid
is orders of magnitude slower than the empty payload.

Revert the use of `Generate()` here in place of the empty payload.

However, if the user has indicated they want to validate the latest key-value
pair produced, generate a `(value-{%018d}, offset)` message in the record.

This does mean that message sizes that are less than 24 bytes are not honored
if the `validate-latest-values` flag is passed.
@WillemKauf
Copy link
Contributor Author

Testing CI here: redpanda-data/redpanda#24558

@WillemKauf
Copy link
Contributor Author

Redpanda CI is green.

@WillemKauf WillemKauf requested a review from andrwng December 13, 2024 15:52
@WillemKauf WillemKauf merged commit fd8b208 into redpanda-data:main Dec 13, 2024
2 checks passed
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.

2 participants