DO NOT REPLY [Bug 35037] - [PATCH] Some Field methods use Classcast check instead of instanceof which is slow

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

DO NOT REPLY [Bug 35037] - [PATCH] Some Field methods use Classcast check instead of instanceof which is slow

Bugzilla from bugzilla@apache.org
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG?
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=35037>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND?
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35037





------- Additional Comments From [hidden email]  2005-05-30 00:30 -------
Thanks for you test case Daniel, I appreciate your time in analysing this
(pardon the pun... maybe only a little... :) ).  

I ran your test and got similar results, as in, with class cast or instanceof,
they were about the same, which I thought odd indeed...

Then I spotted something.  You're test case uses Field.Index.NO for the
non-stringreader case.  This ends up bypassing the bit of code I mentioned in
DocumentWriter (see the if() block on line 140 of DocumentWriter, for our test
the Field has to be an Indexed, tokenized field) .

Try these lines instead:

    doc.add(new Field("body", "laber", Field.Store.YES, Field.Index.TOKENIZED));
    doc.add(new Field("body2", "blubb", Field.Store.YES, Field.Index.TOKENIZED));
    doc.add(new Field("body3", "bla", Field.Store.YES, Field.Index.TOKENIZED));

I got about 10-30% slower results with class cast because using this example of
Tokenised text, the class cast does actually get thrown and caught.  Yes,
results are quite broad, but the instanceof test slowest result was always
better than the faster classcast results.

Modern VM's exception creation is miles better than it used to be, but older
VM's were pretty awful.  I wonder what the difference is with, say, JDK 1.3.

At the end of the day, this is only a minor performance improvement, but it can
add up when doing a LOT of documents with a lot of fields, hence I thought this
would be a worth while improvement.




--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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