Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed performance issue #12

Open
FlorentGhilain opened this issue Feb 13, 2024 · 4 comments
Open

Speed performance issue #12

FlorentGhilain opened this issue Feb 13, 2024 · 4 comments

Comments

@FlorentGhilain
Copy link

Hi,

First thanks for the library,

In our business case we only need to read partially the BEID data (ie. national_number, surname and firstnames).
I spotted that in any case, we are reading near everything via objs = sess.findObjects([(CKA_CLASS, CKO_DATA)]) and that's why the process can take some times.

Is there a way to speed up the read by selecting only the fields we are interested in ?
(Shoud we dig on the PKCS11 API side, any hint ?)

Thanks

@lsaffre
Copy link
Member

lsaffre commented Feb 14, 2024

Pleased to read that it's useful to others as well. I am quite convinced that the photo is the only field that actually takes a noticeable time. So I imagine a command-line option --nophoto would be the solution to your problem.

@lsaffre
Copy link
Member

lsaffre commented Feb 14, 2024

Yes, as you said, we need to dig into the PKCS11 API and then review our two calls to sess.findObjects() to make them more granular. Ideally we should add test cases before doing this change, but that would be another issue.

@FlorentGhilain
Copy link
Author

@lsaffre Thanks for the quick advice!

I found the way to do it by digging in the samples offered by the python library PyKCS11.

We can simply add more template filter to the findObjects method.

fields_filter = [
	(CKA_LABEL, "national_number"),
	(CKA_LABEL, "surname"),
	(CKA_LABEL, "firstnames"),
]
...
objs = []
for field_filter in fields_filter:
  objs += sess.findObjects([(CKA_CLASS, CKO_DATA), field_filter])

It took now ~100ms compared to the previous ~2/3 seconds.

At the moment I hardcoded the fields we really need, but we could easily pass them as a command line parameter and only retrieve those label. If i find some times, I will open a PR for this feature.

@lsaffre
Copy link
Member

lsaffre commented Feb 16, 2024

Yes, that looks great. Yes, a PR would be great.

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

No branches or pull requests

2 participants