Skip to content

Commit

Permalink
Bumping version from 0.1.240 to 0.1.241
Browse files Browse the repository at this point in the history
  • Loading branch information
fcostaoliveira committed Sep 20, 2024
1 parent a144d2c commit 554f5d8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "redis-benchmarks-specification"
version = "0.1.240"
version = "0.1.241"
description = "The Redis benchmarks specification describes the cross-language/tools requirements and expectations to foster performance and observability standards around redis related technologies. Members from both industry and academia, including organizations and individuals are encouraged to contribute."
authors = ["filipecosta90 <filipecosta.90@gmail.com>","Redis Performance Group <performance@redis.com>"]
readme = "Readme.md"
Expand Down
62 changes: 42 additions & 20 deletions utils/generate_latency_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ruamel.yaml
from ruamel.yaml.scalarstring import DoubleQuotedScalarString


def calculate_rate_limit(p50_value):
if p50_value < 1000:
return 100
Expand All @@ -15,23 +16,26 @@ def calculate_rate_limit(p50_value):
else:
return 10000

def create_new_test_config(original_config_path, new_config_path, test_name, new_test_name, p50_value):

def create_new_test_config(
original_config_path, new_config_path, test_name, new_test_name, p50_value
):
# Check if the original configuration file exists
if not os.path.exists(original_config_path):
return False # Indicate failure

# Load the original test configuration with ruamel.yaml
yaml = ruamel.yaml.YAML()
yaml.preserve_quotes = True # Preserve quotes in scalar values
with open(original_config_path, 'r') as file:
with open(original_config_path, "r") as file:
config = yaml.load(file)

# Calculate the total desired rate limit
total_rate_limit = calculate_rate_limit(p50_value)

# Calculate per-connection rate limit
# Extract the original arguments
original_arguments = config['clientconfig']['arguments']
original_arguments = config["clientconfig"]["arguments"]

# Convert to string if necessary
if not isinstance(original_arguments, str):
Expand All @@ -46,11 +50,15 @@ def create_new_test_config(original_config_path, new_config_path, test_name, new
clients_per_thread = 50 # Default value
threads = 4 # Default value

clients_match = re.search(r'(?:-c|--clients)(?:[=\s]+)(\d+)', original_arguments_str)
clients_match = re.search(
r"(?:-c|--clients)(?:[=\s]+)(\d+)", original_arguments_str
)
if clients_match:
clients_per_thread = int(clients_match.group(1))

threads_match = re.search(r'(?:-t|--threads)(?:[=\s]+)(\d+)', original_arguments_str)
threads_match = re.search(
r"(?:-t|--threads)(?:[=\s]+)(\d+)", original_arguments_str
)
if threads_match:
threads = int(threads_match.group(1))

Expand All @@ -61,28 +69,35 @@ def create_new_test_config(original_config_path, new_config_path, test_name, new
per_connection_rate_limit = max(1, int(total_rate_limit / total_connections))

# Remove existing rate limit arguments using regex
new_arguments = re.sub(r'--rate(?:-limit(?:ing)?)?(?:\s+\S+)?', '', original_arguments_str)
new_arguments = re.sub(
r"--rate(?:-limit(?:ing)?)?(?:\s+\S+)?", "", original_arguments_str
)

# Append the new '--rate-limiting' argument and its value
new_arguments = f'{new_arguments.strip()} --rate-limiting {per_connection_rate_limit}'
new_arguments = (
f"{new_arguments.strip()} --rate-limiting {per_connection_rate_limit}"
)

# Update the test name to reflect the new test
config['name'] = new_test_name
config['description'] += f" Rate limited to {total_rate_limit} ops/sec."
config["name"] = new_test_name
config["description"] += f" Rate limited to {total_rate_limit} ops/sec."

# Update the arguments in the config
config['clientconfig']['arguments'] = DoubleQuotedScalarString(new_arguments)
config["clientconfig"]["arguments"] = DoubleQuotedScalarString(new_arguments)

# Ensure the destination directory exists
os.makedirs(os.path.dirname(new_config_path), exist_ok=True)

# Save the new test configuration
with open(new_config_path, 'w') as file:
with open(new_config_path, "w") as file:
yaml.dump(config, file)

print(f"Created new test configuration for '{test_name}' with total rate limit {total_rate_limit} ops/sec and per-connection rate limit {per_connection_rate_limit} ops/sec.")
print(
f"Created new test configuration for '{test_name}' with total rate limit {total_rate_limit} ops/sec and per-connection rate limit {per_connection_rate_limit} ops/sec."
)
return True # Indicate success


def main():
parser = argparse.ArgumentParser(
description="Create latency benchmarks",
Expand Down Expand Up @@ -141,40 +156,47 @@ def main():
# Execute the TS.REVRANGE command
# "-" and "+" denote the minimal and maximal timestamps
result = rts.execute_command("TS.REVRANGE", ts_key, "-", "+")

# Check if result is not empty
if result:
# Extract values and convert to floats
values = [float(value) for timestamp, value in result]
# Compute the median (p50)
p50_value = np.median(values)

# Output the results
print(f"Results for test case '{test_name}': p50 rate = {p50_value}")
rate = calculate_rate_limit(p50_value)

original_config_path = f'../redis_benchmarks_specification/test-suites/{test_name}.yml' # Original test config file
new_test_name = f'latency-rate-limited-{rate}_qps-{test_name}'
new_config_path = f'../redis_benchmarks_specification/test-suites/{new_test_name}.yaml' # New test config file
success = create_new_test_config(original_config_path, new_config_path, test_name, new_test_name, p50_value)
original_config_path = f"../redis_benchmarks_specification/test-suites/{test_name}.yml" # Original test config file
new_test_name = f"latency-rate-limited-{rate}_qps-{test_name}"
new_config_path = f"../redis_benchmarks_specification/test-suites/{new_test_name}.yaml" # New test config file
success = create_new_test_config(
original_config_path,
new_config_path,
test_name,
new_test_name,
p50_value,
)
if not success:
failed_files.append(test_name)
else:
print(f"No data available for test case '{test_name}'.")
failed_files.append(test_name)

except redis.exceptions.ResponseError as e:
print(f"Error retrieving data for test case '{test_name}': {e}")
failed_files.append(test_name)
except Exception as e:
print(f"An error occurred while processing test case '{test_name}': {e}")
failed_files.append(test_name)

# At the end, print out the list of failed files if any
if failed_files:
print("\nThe following test cases had missing configuration files or errors:")
for test_name in failed_files:
print(f"- {test_name}")


if __name__ == "__main__":
main()

0 comments on commit 554f5d8

Please sign in to comment.