[ 
https://issues.apache.org/jira/browse/HDDS-2445?focusedWorklogId=340447&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-340447
 ]

ASF GitHub Bot logged work on HDDS-2445:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/Nov/19 11:06
            Start Date: 08/Nov/19 11:06
    Worklog Time Spent: 10m 
      Work Description: adoroszlai commented on pull request #132: HDDS-2445. 
Replace ToStringBuilder in BlockData
URL: https://github.com/apache/hadoop-ozone/pull/132
 
 
   ## What changes were proposed in this pull request?
   
   Eliminate `ToStringBuilder` from `BlockData`.  Use a single `StringBuilder` 
to collect parts of the final result.
   
   Also avoid stream-processing in `setChunks` for the special cases of 0 or 1 
elements.
   
   https://issues.apache.org/jira/browse/HDDS-2445
   
   ## How was this patch tested?
   
   Added benchmark with various implementations.
   
   ```
   bin/ozone genesis -benchmark BenchmarkBlockDataToString
   ```
   
   Normalized GC allocation rates are below (absolute values are not important, 
only relative to one another).  Using a single string builder saves ~78% of 
allocations compared to the current implementation 
(`ToStringBuilderDefaultCapacity`).
   
   ```
   Benchmark                  (capacity)  (count)   Mode  Cnt        Score      
 Error   Units
   PushDownStringBuilder             112     1000  thrpt   20   503403.364 ±    
 6.593    B/op
   InlineStringBuilder               112     1000  thrpt   20   503625.761 ±    
 2.665    B/op
   SimpleStringBuilder               112     1000  thrpt   20  1133643.831 ±    
 4.051    B/op
   ToStringBuilder                   112     1000  thrpt   20  1429626.864 ±    
 7.415    B/op
   Concatenation                     112     1000  thrpt   20  1523808.749 ±    
13.819    B/op
   ToStringBuilderDefaultCapacity    112     1000  thrpt   20  2229699.096 ±    
 6.739    B/op
   ```
   
   Added a simple unit test to verify the output is unchanged.
   
   Stream-processing change is verified by existing 
`TestBlockData#testSetChunks`.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

            Worklog Id:     (was: 340447)
    Remaining Estimate: 0h
            Time Spent: 10m

> Replace ToStringBuilder in BlockData
> ------------------------------------
>
>                 Key: HDDS-2445
>                 URL: https://issues.apache.org/jira/browse/HDDS-2445
>             Project: Hadoop Distributed Data Store
>          Issue Type: Improvement
>            Reporter: Attila Doroszlai
>            Assignee: Attila Doroszlai
>            Priority: Minor
>              Labels: perfomance, pull-request-available
>         Attachments: blockdata.png, setchunks.png
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> {{BlockData#toString}} uses {{ToStringBuilder}} for ease of implementation.  
> This has a few problems:
> # {{ToStringBuilder}} uses {{StringBuffer}}, which is synchronized
> # the default buffer is 512 bytes, more than needed here
> # {{BlockID}} and {{ContainerBlockID}} both use another {{StringBuilder}} or 
> {{StringBuffer}} for their {{toString}} implementation, leading to several 
> allocations and copies
> The flame graph shows that {{BlockData#toString}} may be responsible for 1.5% 
> of total allocations while putting keys.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to