Skip to content

fix: optimize base64 decoding and reduce string allocations in ConnectorRest - #712

Merged
luisremis merged 4 commits into
developfrom
fix/issue-232
May 22, 2026
Merged

fix: optimize base64 decoding and reduce string allocations in ConnectorRest#712
luisremis merged 4 commits into
developfrom
fix/issue-232

Conversation

@ad-claw000

Copy link
Copy Markdown
Contributor

Summary

This PR optimizes base64 decoding for REST connectors, which improves CPU utilization in client side during stress tests.

Fixes

Fixes #232

Verification

  • Ran cProfile on isolated base64 decode and JSON loads. Using pybase64 reduces base64 decoding time significantly (about 50% CPU savings locally compared to Python's built-in base64.b64decode).
  • Changed json.loads(response.text) to response.json() which leverages Requests' optimized paths and reduces string overhead.
  • Passed local unit tests for ConnectorRest.py module and no syntax errors are introduced.

…torRest

Fixes #232 by:
- using pybase64 for faster decoding operations
- utilizing response.json() instead of json.loads(response.text) to reduce redundant string parsing
Copilot AI review requested due to automatic review settings May 20, 2026 08:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to reduce client-side CPU usage for REST queries by optimizing how REST responses are parsed and how blobs are base64-decoded in ConnectorRest.

Changes:

  • Add pybase64 as a dependency and prefer it for base64 decoding (with stdlib fallback).
  • Replace json.loads(response.text) with response.json() to reduce intermediate string allocations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pyproject.toml Adds pybase64 to project dependencies.
aperturedb/ConnectorRest.py Prefers pybase64 for decoding and switches REST response parsing to response.json().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread aperturedb/ConnectorRest.py Outdated
Comment thread pyproject.toml
Copilot AI review requested due to automatic review settings May 20, 2026 16:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@luisremis
luisremis merged commit 48ca416 into develop May 22, 2026
2 checks passed
@luisremis
luisremis deleted the fix/issue-232 branch May 22, 2026 18:08
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.

Investigate why using ConnectorRest in stress runs uses more CPU at the client side.

3 participants