Skip to content

GH-49720: [C++] Optimize base64_decode validation using lookup table#49748

Open
Reranko05 wants to merge 1 commit intoapache:mainfrom
Reranko05:optimize-base64-lookup
Open

GH-49720: [C++] Optimize base64_decode validation using lookup table#49748
Reranko05 wants to merge 1 commit intoapache:mainfrom
Reranko05:optimize-base64-lookup

Conversation

@Reranko05
Copy link
Copy Markdown
Contributor

@Reranko05 Reranko05 commented Apr 14, 2026

Rationale for this change

The current implementation of base64_decode validates characters using std::string::find for each byte, which introduces unnecessary overhead due to repeated linear searches.

This change replaces those lookups with a precomputed 256-entry lookup table, enabling constant-time validation and value lookup per character.

What changes are included in this PR?

  • Introduced a static lookup table (kBase64Lookup) to map base64 characters to their corresponding values
  • Replaced std::string::find with constant-time table lookup for character validation

Are these changes tested?

Yes. Existing base64 decoding behavior remains unchanged and continues to pass all current tests. This change is a performance optimization and does not alter functional output.

Are there any user-facing changes?

No.

This change is internal and does not affect public APIs.

GitHub Issue: #49720

@github-actions github-actions bot added the awaiting review Awaiting review label Apr 14, 2026
@github-actions
Copy link
Copy Markdown

⚠️ GitHub issue #49720 has been automatically assigned in GitHub to PR creator.

@Reranko05 Reranko05 force-pushed the optimize-base64-lookup branch from 9c55ff0 to e48fd5c Compare April 14, 2026 20:41
@Reranko05
Copy link
Copy Markdown
Contributor Author

Hi @kou @dmitry-chirkov-dremio, this implements the lookup-table optimization we discussed in PR #49660 .
Would appreciate your feedback when convenient. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant