Skip to content

add attributes caching to OCSP request#14445

Open
abbra wants to merge 4 commits intopyca:mainfrom
abbra:perf/ocsp-req-caching
Open

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

Conversation

@abbra
Copy link
Contributor

@abbra abbra commented Mar 8, 2026

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>
Copy link
Member

@alex alex left a comment

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
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
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!)

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.

2 participants