[ 
https://issues.apache.org/jira/browse/PDFBOX-2882?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14630447#comment-14630447
 ] 

Timo Boehme commented on PDFBOX-2882:
-------------------------------------

Thanks for having a look at the code. I chose the usage of AtomicBoolean and 
the synchronization deliberately to minimize synchronization overhead and to 
minimize blocking of parallel access (while currently it may only be one thread 
but this could be changed in the future and the memory backend should be 
capable of handling this). The nice thing with AtomicBoolean is that it does 
not use 'normal' synchronization and comes with lower overhead. Thus where 
possible I use this, e.g. for 'isClosed'-checking so this is more lightweight 
as synchronizing the whole method. Additionally if the page is in-memory the 
read/write operation does not need any further synchronization which means it 
can run in parallel providing very fast parallel page access to in-memory 
pages. Only the file access needs to be synchronized. In principle the file I/O 
is the operation which will take most of the time thus it is crucial that such 
an operation does not block any other parallel page access not using the file.

I will have a look if using only one lock for isClosed+raf is enough without 
sacrifying performance of parallel access.

> Improve performance when using scratch file
> -------------------------------------------
>
>                 Key: PDFBOX-2882
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2882
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: Parsing
>    Affects Versions: 2.0.0
>            Reporter: Timo Boehme
>            Assignee: Timo Boehme
>            Priority: Minor
>         Attachments: ScratchFile.java, ScratchFileBuffer.java
>
>
> The current scratch file implementation uses many direct I/O calls which 
> slows down parsing compared with in-memory scratch buffer considerably.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to