Skip to content

add attributes caching to OCSP request#14445

Closed
abbra wants to merge 4 commits into
pyca:mainfrom
abbra:perf/ocsp-req-caching
Closed

add attributes caching to OCSP request#14445
abbra wants to merge 4 commits into
pyca:mainfrom
abbra:perf/ocsp-req-caching

Conversation

@abbra

@abbra abbra commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Continuation of #14441

abbra and others added 4 commits March 9, 2026 00:31
Store the Python bytes object in a PyOnceLock so that repeated accesses
return the same object without re-traversing the ASN.1 structure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
Store the Python bytes object in a PyOnceLock so that repeated accesses
return the same object without re-traversing the ASN.1 structure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
Store the computed hash-algorithm object in a PyOnceLock so that repeated
accesses avoid re-traversing the ASN.1 structure and re-constructing the
Python hash object.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
Store the Python integer in a PyOnceLock so that repeated accesses avoid
re-parsing the ASN.1 integer bytes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>

@alex alex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hmm, caching things that are just type conversions/

impl OCSPRequest {
#[getter]
fn issuer_name_hash(&self) -> &[u8] {
self.cert_id().issuer_name_hash

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if we should be returning some sort of buffer here that points into self (while ensuring self is alive, of course). Feels excessive to need to cache something that's just constructing a bytes object...

WDYT @reaperhulk

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(filed PyO3/pyo3#5871 to try to make this cheaper!)

@reaperhulk

Copy link
Copy Markdown
Member

I think this optimization isn't worth it at this time, but thank you for the other contributions!

@reaperhulk reaperhulk closed this Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants