peteraisher commented on PR #538: URL: https://github.com/apache/pdfbox/pull/538#issuecomment-6210104415
In my opinion it's both. We will use this patch anyway — sharing here since it seems likely to benefit others. TL;DR: Previous options: - share font resource, no access serialisation -> fast and low memory usage, potentially unsafe under load - share font resource, serialise access -> safe and low memory usage, potentially slow under load - one font resource per thread -> fast and safe, high memory usage New option: - one font resource per thread, share underlying memory -> fast, safe, low memory usage Right now, people using pdfbox across multiple threads (us included) have to choose between resource duplication or access serialisation if they want a strong guarantee against data corruption when multiple threads use a single font. Reads are mutating in a potentially non-safe way, since they involve seeking, and the seek state is shared across threads and happens behind different locks. To get an independent seek state currently requires copying the underlying `byte[]` too, but since all the accesses are reads, there's nothing to stop the underlying storage being shared. Only the `position` needs to be separate. Putting this change on main makes that choice between safety guarantee and resource sharing go away. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
