Skip to content

Incorrect calculation of nats bench sub stats #1441

@alexbozhenko

Description

@alexbozhenko

Observed behavior

nats bench sub should not have a --size= flag?
(see below)

Expected behavior

Message size that we receive is something God-given, so we can not specify it, right?

Server and client version

main, main

# nats --version
v0.2.5-0.20250730153159-37671e28664b

Host environment

No response

Steps to reproduce

publish messages of ~250KB size:

# nats bench  pub worker.inbox.0 --msgs 10000 --size=250000
22:44:18 Starting Core NATS publish benchmark [clients=1, msg-size=244 KiB, msgs=10,000, multi-subject=false, multi-subject-max=100,000, sleep=0s, subject=worker.inbox.0]
22:44:18 Starting publisher, publishing 10,000 messages
Finished      1s [==============================================================================================] 100%

Pub stats: 5,814 msgs/sec ~ 1.35 GB/sec

Do sub for 10000 messages:

# nats bench sub worker.inbox.0 --msgs 10000  
22:45:52 Starting Core NATS subscribe benchmark [clients=1, msg-size=128 B, msgs=10,000, multi-subject=false, subject=worker.inbox.0]
Finished      1s [==============================================================================================] 100%

Sub stats: 5,884 msgs/sec ~ 735.51 KB/sec

  1. What is the meaning of msg-size=128 B in this output?
  2. Why it says `735.51 KB/sec? It bulitplies the message rate by incorrect size
# echo  "5884*128 / 1024" | bc -l
735.50000000000000000000

3.I can also specify bogus size there, and get 5.69PB/sec :-)

# nats bench sub worker.inbox.0 --msgs 10000  --size="1T"
22:49:04 Starting Core NATS subscribe benchmark [clients=1, msg-size=1.0 TiB, msgs=10,000, multi-subject=false, subject=worker.inbox.0]
Finished      1s [==============================================================================================] 100%

Sub stats: 5,825 msgs/sec ~ 5.69 PB/sec

Metadata

Metadata

Assignees

Labels

defectSuspected defect such as a bug or regression

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions