[
https://issues.apache.org/jira/browse/CASSANDRA-1244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12884478#action_12884478
]
Folke Behrens commented on CASSANDRA-1244:
------------------------------------------
Well, premature optimization is optimization none the less. It's just a waste
of time because profilers show the actual slow parts of a program. However, if
someone already wasted time on this ...
Not premature optimization:
- LongType: faster, because no object instantiation and fewer (virtual) method
calls.
- Double.valueOf() creates a "Double", .parseDouble() returns "double".
- Dropped bitwise "and" operations with 0xFF.
- writeShortByteArray() explicitly throws IOException as its siblings do.
- hexvalue()/hexchar() faster than Integer.parseInt(str.substring())
- new StringBuilder(bytes.length * 2): initial capacity prevents array copying
- append("0") -> append('0'): this one is obvious?
- CodingErrorAction: make sure that CharsetDecoder throws exception
What's left?
- compareByteArrays(): No speed-up, just cleaner.
- toByteArray(long)/toByteArray(int): Unrolled loops contain one less shift op.
Insignificant speed-up.
- asserts gone. NPE will be thrown.
- encodedUTF8Length gone: See issue description.
- class finalized + private default constructor: Accepted pattern for utility
classes.
If you think this patch makes FBUtilities slower then don't apply it. I started
with the byte array operations and then did some other changes. No harm done.
> FBUtilities: small performance fixes and clean-ups
> --------------------------------------------------
>
> Key: CASSANDRA-1244
> URL: https://issues.apache.org/jira/browse/CASSANDRA-1244
> Project: Cassandra
> Issue Type: Improvement
> Components: Core
> Reporter: Folke Behrens
> Priority: Trivial
> Attachments: FBUtilities-minor-perf-fixes.txt
>
>
> The following patch (against trunk) changes several methods in FBUtilities.
> Makes them faster and/or cleaner.
> One method will be removed: encodedUTF8Length(). It does not detect surrogate
> pairs (4-bytes sequences) and isn't used anywhere.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.