Bug 78831 - [Patch] Faster AES decryption
Summary: [Patch] Faster AES decryption
Status: RESOLVED MOVED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-17 13:28 UTC by Jan Ziak (http://atom-symbol.net)
Modified: 2018-08-20 21:48 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
faster-aes.diff (5.16 KB, patch)
2014-05-17 13:28 UTC, Jan Ziak (http://atom-symbol.net)
Details | Splinter Review

Description Jan Ziak (http://atom-symbol.net) 2014-05-17 13:28:04 UTC
Created attachment 99221 [details] [review]
faster-aes.diff

Please incorporate the attached patch into the mainline tree. The patch provides faster AES decryption, for example when loading a PDF document in Okular. Thanks.
Comment 1 Albert Astals Cid 2014-05-19 18:23:57 UTC
Can you provide the PDF file you tried it on and some benchmark results before and after?
Comment 2 Jan Ziak (http://atom-symbol.net) 2014-05-19 19:18:03 UTC
(In reply to comment #1)
> Can you provide the PDF file you tried it on and some benchmark results
> before and after?

The PDF is http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html?iid=tech_vt_tech+64-32_manuals, Combined Volumes 2A, 2B, 2C.

With -O0 passed to the C compiler: opening the PDF takes 5.9 seconds without the patch, 4.1 seconds with the patch. This was measured on a 4.0 GHz AMD CPU.
Comment 3 Jan Ziak (http://atom-symbol.net) 2014-05-21 08:23:30 UTC
Any news on merging this patch?
Comment 4 Fabio D'Urso 2014-05-21 09:38:35 UTC
Hi, I'm not sure that initializing the arrays through that MulTableInit class is a good idea.

Relying on a global/static variable ctor is usually discouraged, because it's hard to predict the order those variables are initialized. In order words, what happens if you open an encrypted document from another global/static variable's ctor? Has the decryption table been initialized already or not?

http://www.parashift.com/c++-faq/static-init-order-on-first-use.html
Comment 5 Jan Ziak (http://atom-symbol.net) 2014-05-21 10:59:19 UTC
(In reply to comment #4)
> Hi, I'm not sure that initializing the arrays through that MulTableInit
> class is a good idea.
> 
> Relying on a global/static variable ctor is usually discouraged, because
> it's hard to predict the order those variables are initialized. In order
> words, what happens if you open an encrypted document from another
> global/static variable's ctor? Has the decryption table been initialized
> already or not?

I see. I suggest we introduce a boolean variable that we would check before every AES decryption. Would this be OK with you? Does the variable need to be thread-safe?
Comment 6 Albert Astals Cid 2014-07-20 22:42:48 UTC
Why would you use O0? HAve you tried with O2?

For file you mean http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf no? I'm a bit surprised opening the file takes 4 seconds, can you define what "opnening the file" means since i basically open it in no time (0,008 seconds).
Comment 7 Jan Ziak (http://atom-symbol.net) 2014-07-21 16:46:43 UTC
(In reply to comment #6)
> Why would you use O0? HAve you tried with O2?

This has no significance.

> For file you mean
> http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-
> architectures-software-developer-instruction-set-reference-manual-325383.pdf
> no? I'm a bit surprised opening the file takes 4 seconds, can you define
> what "opnening the file" means since i basically open it in no time (0,008
> seconds).

You used "open it" in your sentence without defining it.

The measured time refers to userspace time as reported by "time okular some.pdf".
Comment 8 Albert Astals Cid 2014-07-21 21:28:44 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > Why would you use O0? HAve you tried with O2?
> 
> This has no significance.

Have you tried?

> > For file you mean
> > http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-
> > architectures-software-developer-instruction-set-reference-manual-325383.pdf
> > no? I'm a bit surprised opening the file takes 4 seconds, can you define
> > what "opnening the file" means since i basically open it in no time (0,008
> > seconds).
> 
> You used "open it" in your sentence without defining it.
> 
> The measured time refers to userspace time as reported by "time okular
> some.pdf".

Well, i don't need to define what open means, open a file is opening, basically the time that glib/demo/poppler-glib-demo reports it took in opening it. What you mention is pretty unscientific.
Comment 9 GitLab Migration User 2018-08-20 21:48:45 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/poppler/poppler/issues/85.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.