You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Bryan Duxbury (JIRA)" <ji...@apache.org> on 2009/01/29 03:40:59 UTC
[jira] Created: (THRIFT-288) Generated code iterates maps during
write inefficiently
Generated code iterates maps during write inefficiently
-------------------------------------------------------
Key: THRIFT-288
URL: https://issues.apache.org/jira/browse/THRIFT-288
Project: Thrift
Issue Type: Improvement
Components: Compiler (Java)
Reporter: Bryan Duxbury
Priority: Minor
If you look at the way that TBase#write serializes maps, it iterates the keySet and then calls get on the map to actually get the value. This is inefficient for a few reasons. First, if the map keys are base types (byte, int, etc), it will autounbox to get the key, and then re-box the data to do the get() call. Second, even with boxing issues equalized, iterating a map's entrySet instead of its keySet is almost 2x as fast on a HashMap and over 5x as fast with a TreeMap.
Improvements to this iteration code would benefit protocols.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (THRIFT-288) Generated code iterates maps during
write inefficiently
Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-288?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bryan Duxbury reassigned THRIFT-288:
------------------------------------
Assignee: Bryan Duxbury
> Generated code iterates maps during write inefficiently
> -------------------------------------------------------
>
> Key: THRIFT-288
> URL: https://issues.apache.org/jira/browse/THRIFT-288
> Project: Thrift
> Issue Type: Improvement
> Components: Compiler (Java)
> Reporter: Bryan Duxbury
> Assignee: Bryan Duxbury
> Priority: Minor
>
> If you look at the way that TBase#write serializes maps, it iterates the keySet and then calls get on the map to actually get the value. This is inefficient for a few reasons. First, if the map keys are base types (byte, int, etc), it will autounbox to get the key, and then re-box the data to do the get() call. Second, even with boxing issues equalized, iterating a map's entrySet instead of its keySet is almost 2x as fast on a HashMap and over 5x as fast with a TreeMap.
> Improvements to this iteration code would benefit protocols.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (THRIFT-288) Generated code iterates maps during
write inefficiently
Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-288?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bryan Duxbury updated THRIFT-288:
---------------------------------
Patch Info: [Patch Available]
> Generated code iterates maps during write inefficiently
> -------------------------------------------------------
>
> Key: THRIFT-288
> URL: https://issues.apache.org/jira/browse/THRIFT-288
> Project: Thrift
> Issue Type: Improvement
> Components: Compiler (Java)
> Reporter: Bryan Duxbury
> Assignee: Bryan Duxbury
> Priority: Minor
> Attachments: thrift-288.patch
>
>
> If you look at the way that TBase#write serializes maps, it iterates the keySet and then calls get on the map to actually get the value. This is inefficient for a few reasons. First, if the map keys are base types (byte, int, etc), it will autounbox to get the key, and then re-box the data to do the get() call. Second, even with boxing issues equalized, iterating a map's entrySet instead of its keySet is almost 2x as fast on a HashMap and over 5x as fast with a TreeMap.
> Improvements to this iteration code would benefit protocols.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (THRIFT-288) Generated code iterates maps during
write inefficiently
Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-288?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bryan Duxbury updated THRIFT-288:
---------------------------------
Attachment: thrift-288.patch
This changes the iteration to use entrySet instead of keySet. The java tests still pass after this change.
> Generated code iterates maps during write inefficiently
> -------------------------------------------------------
>
> Key: THRIFT-288
> URL: https://issues.apache.org/jira/browse/THRIFT-288
> Project: Thrift
> Issue Type: Improvement
> Components: Compiler (Java)
> Reporter: Bryan Duxbury
> Assignee: Bryan Duxbury
> Priority: Minor
> Attachments: thrift-288.patch
>
>
> If you look at the way that TBase#write serializes maps, it iterates the keySet and then calls get on the map to actually get the value. This is inefficient for a few reasons. First, if the map keys are base types (byte, int, etc), it will autounbox to get the key, and then re-box the data to do the get() call. Second, even with boxing issues equalized, iterating a map's entrySet instead of its keySet is almost 2x as fast on a HashMap and over 5x as fast with a TreeMap.
> Improvements to this iteration code would benefit protocols.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (THRIFT-288) Generated code iterates maps during
write inefficiently
Posted by "David Reiss (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12668353#action_12668353 ]
David Reiss commented on THRIFT-288:
------------------------------------
LG. I hope it gives a good performance boost.
> Generated code iterates maps during write inefficiently
> -------------------------------------------------------
>
> Key: THRIFT-288
> URL: https://issues.apache.org/jira/browse/THRIFT-288
> Project: Thrift
> Issue Type: Improvement
> Components: Compiler (Java)
> Reporter: Bryan Duxbury
> Assignee: Bryan Duxbury
> Priority: Minor
> Attachments: thrift-288.patch
>
>
> If you look at the way that TBase#write serializes maps, it iterates the keySet and then calls get on the map to actually get the value. This is inefficient for a few reasons. First, if the map keys are base types (byte, int, etc), it will autounbox to get the key, and then re-box the data to do the get() call. Second, even with boxing issues equalized, iterating a map's entrySet instead of its keySet is almost 2x as fast on a HashMap and over 5x as fast with a TreeMap.
> Improvements to this iteration code would benefit protocols.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (THRIFT-288) Generated code iterates maps during
write inefficiently
Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-288?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bryan Duxbury resolved THRIFT-288.
----------------------------------
Resolution: Fixed
Committed.
> Generated code iterates maps during write inefficiently
> -------------------------------------------------------
>
> Key: THRIFT-288
> URL: https://issues.apache.org/jira/browse/THRIFT-288
> Project: Thrift
> Issue Type: Improvement
> Components: Compiler (Java)
> Reporter: Bryan Duxbury
> Assignee: Bryan Duxbury
> Priority: Minor
> Attachments: thrift-288.patch
>
>
> If you look at the way that TBase#write serializes maps, it iterates the keySet and then calls get on the map to actually get the value. This is inefficient for a few reasons. First, if the map keys are base types (byte, int, etc), it will autounbox to get the key, and then re-box the data to do the get() call. Second, even with boxing issues equalized, iterating a map's entrySet instead of its keySet is almost 2x as fast on a HashMap and over 5x as fast with a TreeMap.
> Improvements to this iteration code would benefit protocols.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.