You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org> on 2016/03/11 03:44:40 UTC
[jira] [Commented] (MYFACES-3477) [perf] Review amount of byte []
arrays created during state saving
[ https://issues.apache.org/jira/browse/MYFACES-3477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15190387#comment-15190387 ]
Leonardo Uribe commented on MYFACES-3477:
-----------------------------------------
I have been checking this one and it could be an opportunity of improvement here.
The use of ByteArrayOutputStream involves two arrays: one that is dynamically expanded (initial size 32) and the other that is created when toByteArray() method is called, copying the content from the internal created buffer. This is inefficient because it uses the double or even more memory than it really needs.
The situations where ByteArrayOutputStream is used are:
- Serialize the component tree into a byte array
- Compress the serialized byte array.
- Encrypt the final array (a byte array is created).
The objective could be to create an algorithm that uses only 2 buffers and keep track of the max size of the buffer, to avoid new allocations.
The performance gain could depend of the size of the view state. I would say with the current PSS algorithm, in almost all cases the size is really small, but that depends on the application, how the views are built and so on. It is worth a shot.
> [perf] Review amount of byte [] arrays created during state saving
> -------------------------------------------------------------------
>
> Key: MYFACES-3477
> URL: https://issues.apache.org/jira/browse/MYFACES-3477
> Project: MyFaces Core
> Issue Type: Improvement
> Reporter: Martin Kočí
> Priority: Trivial
>
> instances of byte [] are created in:
> 1) org.apache.myfaces.shared.util.StateUtils.getAsByteArray(Object, ExternalContext)
> 2) org.apache.myfaces.shared.util.serial.DefaultSerialFactory.getObjectOutputStream
> 3) writer.writeObject(object); in org.apache.myfaces.shared.util.StateUtils.getAsByteArray
> 4) org.apache.myfaces.shared.util.StateUtils.encode(byte[])
> 5) org.apache.myfaces.shared.util.serial.DefaultSerialFactory.getObjectInputStream(InputStream)
> 6) org.apache.myfaces.shared.util.StateUtils.reconstruct(String, ExternalContext)
> those allocations are not performance problem; only in cumulative time are those methods #1 source of byte [] in myfaces - maybe can be some of them removed.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)