Skip to content

Enhance logging, improve templates, and optimize performance - #222

Merged
david-lev merged 36 commits into
masterfrom
dev
Aug 11, 2026
Merged

Enhance logging, improve templates, and optimize performance#222
david-lev merged 36 commits into
masterfrom
dev

Conversation

@david-lev

Copy link
Copy Markdown
Owner

No description provided.

david-lev and others added 30 commits July 19, 2026 14:59
…_FAKE_GEN_STREAM` flag when uploading media from url
# Conflicts:
#	pywa/cli.py
default_flow_request_decryptor called load_pem_private_key on every
flow data exchange. Parsing a PEM is expensive — cryptography validates
the RSA key material on load — and it dominated the cost of the
decryption it exists to enable: ~56ms against ~2.8ms for the rest of
the request, with or without a password on the key.

That put a ceiling of roughly 18 exchanges per second per core on any
flow endpoint, in synchronous CPU work, to re-answer a question whose
answer never changes for the life of the process.

The key is now parsed once per (private_key, password) pair through a
bounded lru_cache, taking the same request to ~2.8ms — about 20x, and a
ceiling nearer 355/s/core. The cache keys come from the developer's own
configuration and never from a request.
Cache the flow private key instead of parsing it on every request
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.67920% with 113 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.86%. Comparing base (2b550f6) to head (480bb4d).
⚠️ Report is 335 commits behind head on master.

Files with missing lines Patch % Lines
pywa/_helpers.py 41.25% 47 Missing ⚠️
pywa/server.py 31.25% 22 Missing ⚠️
pywa/cli.py 84.81% 12 Missing ⚠️
pywa/client.py 36.84% 12 Missing ⚠️
pywa/types/message.py 41.66% 7 Missing ⚠️
pywa/_logging.py 93.87% 6 Missing ⚠️
pywa/types/flows.py 50.00% 3 Missing ⚠️
pywa/listeners.py 85.71% 1 Missing ⚠️
pywa/types/base_update.py 75.00% 1 Missing ⚠️
pywa/types/media.py 75.00% 1 Missing ⚠️
... and 1 more

❗ There is a different number of reports uploaded between BASE (2b550f6) and HEAD (480bb4d). Click for more details.

HEAD has 10 uploads less than BASE
Flag BASE (2b550f6) HEAD (480bb4d)
12 2
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #222       +/-   ##
===========================================
- Coverage   87.81%   58.86%   -28.96%     
===========================================
  Files          15       29       +14     
  Lines        3407     2076     -1331     
===========================================
- Hits         2992     1222     -1770     
- Misses        415      854      +439     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread pywa/_helpers.py Dismissed
Comment thread pywa/api.py Dismissed
Comment thread pywa_async/api.py Dismissed
@david-lev
david-lev merged commit 5e67168 into master Aug 11, 2026
28 of 30 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.

3 participants