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

Kacper/fix/debugging performance #602

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions backend/benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import requests
import concurrent.futures
from collections import Counter

# URL to test
URL = "https://uat-backend.octant.wildland.dev/rewards/projects/estimated"

# Parameters for the load test
CONCURRENT_REQUESTS = 200
TOTAL_REQUESTS = 100

# Function to make a single request
def make_request(_):
try:
response = requests.get(URL, timeout=60)
return response.status_code
except requests.RequestException as e:
return f"Error: {str(e)}"

def main():
# Use a thread pool for concurrent requests
with concurrent.futures.ThreadPoolExecutor(max_workers=CONCURRENT_REQUESTS) as executor:
responses = list(executor.map(make_request, range(TOTAL_REQUESTS)))

# Count occurrences of each HTTP status code
counts = Counter(responses)

# Separate HTTP status codes and errors
status_codes = {k: v for k, v in counts.items() if isinstance(k, int)}
errors = {k: v for k, v in counts.items() if isinstance(k, str)}

# Print HTTP status codes
print("HTTP Status Code Counts:")
for status_code, count in sorted(status_codes.items()):
print(f"{status_code}: {count}")

# Print errors
if errors:
print("\nErrors:")
for error, count in errors.items():
print(f"{error}: {count}")

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion backend/v2/core/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_w3(
class DatabaseSettings(OctantSettings):
db_uri: str = Field(..., alias="db_uri")

pg_pool_size: int = Field(10, alias="sqlalchemy_connection_pool_size")
pg_pool_size: int = Field(70, alias="sqlalchemy_connection_pool_size")
pg_max_overflow: int = Field(0, alias="sqlalchemy_connection_pool_max_overflow")
pg_pool_timeout: int = 60
pg_pool_recycle: int = 30 * 60 # 30 minutes
Expand Down
1 change: 1 addition & 0 deletions backend/v2/epochs/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async def get_open_allocation_window_epoch_number(
"""

epoch_number = await epochs_contracts.get_pending_epoch()
epoch_number = 1
if epoch_number is None:
raise AllocationWindowClosed()

Expand Down
7 changes: 5 additions & 2 deletions backend/v2/project_rewards/services.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
from dataclasses import dataclass

from sqlalchemy.ext.asyncio import AsyncSession
Expand All @@ -9,7 +8,7 @@
capped_quadriatic_funding,
)
from v2.projects.contracts import ProjectsContracts

import asyncio

@dataclass
class ProjectRewardsEstimator:
Expand All @@ -29,6 +28,10 @@ async def get(self) -> CappedQuadriaticFunding:
get_allocations_with_user_uqs(self.session, self.epoch_number),
)

# all_projects = await self.projects_contracts.get_project_addresses(self.epoch_number)
# matched_rewards = await self.matched_rewards_estimator.get()
# allocations = await get_allocations_with_user_uqs(self.session, self.epoch_number)

# Calculate using the Capped Quadriatic Funding formula
return capped_quadriatic_funding(
project_addresses=all_projects,
Expand Down
14 changes: 7 additions & 7 deletions ci/argocd/contracts/uat.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
BLOCK_NUMBER=7297985
BLOCK_NUMBER=7339391
GLM_CONTRACT_ADDRESS=0x71432DD1ae7DB41706ee6a22148446087BdD0906
AUTH_CONTRACT_ADDRESS=0x1D70e8358aF3b1854c5f696317a68B8e65d0ed72
DEPOSITS_CONTRACT_ADDRESS=0x0177EFAA6e2B3Cb264D1CeFdADDA65728227a5AF
EPOCHS_CONTRACT_ADDRESS=0xD48fdD462af8b3a9E0d3A94d890aDCf669f27e8D
PROPOSALS_CONTRACT_ADDRESS=0xBE2C3A87FDBb72Cbb51aE55876fE59894b47882C
WITHDRAWALS_TARGET_CONTRACT_ADDRESS=0xa352A396330eCa21D00d3fb0EA38EF4e6edb2885
VAULT_CONTRACT_ADDRESS=0x24A254404911A2CC4e47895bbc20dafF6B84578c
AUTH_CONTRACT_ADDRESS=0x6B8B39CF452b86f6088632DC940401E0C1C0cCCA
DEPOSITS_CONTRACT_ADDRESS=0x5F196cF464b564BB61F79ec1b37265fEaaCF8F62
EPOCHS_CONTRACT_ADDRESS=0x40b44ba2E65c09c8254C23d6c3bF074a7c9Ed2f7
PROPOSALS_CONTRACT_ADDRESS=0x8f95fFF1181815e9A306614D118e6f553CD2c99d
WITHDRAWALS_TARGET_CONTRACT_ADDRESS=0xb7D9Ba3a1eE1db8bE13EFe6F9a1250F1eeb5c552
VAULT_CONTRACT_ADDRESS=0x9308AD4a4a0416ef6B71b9f708474598F583ed3D
Loading