https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
John Engebretson changed:
What|Removed |Added
CC||jeng...@amazon.com
--- Comment #1 f
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #2 from Christopher Schultz ---
I haven't studied what the Java compiler does with switch(String) statements,
but I believe that numeric-based switch statements have two flavors: lookup vs
table. One of them is faster but is only po
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #3 from John Engebretson ---
I used javap to examine the bytecode of the reproducer - the full output is
attached but the critical portion is below. In short, it hashes each constant
and switches based on that hash.
This is superi
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #4 from John Engebretson ---
Created attachment 38938
--> https://bz.apache.org/bugzilla/attachment.cgi?id=38938&action=edit
decompiled reproducer
--
You are receiving this mail because:
You are the assignee for the bug.
---
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
Anurag Dubey changed:
What|Removed |Added
CC||anura...@amazon.com
--
You are receivi
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #5 from Anurag Dubey ---
Create Pull Request for the proposed change, have also shared the performance
comparison for Old vs Switch implementation vs Hashmap implementation -
https://github.com/apache/tomcat/pull/666
--
You are re
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #6 from John Engebretson ---
Anurag's solution is clearly faster than mine, I like it.
--
You are receiving this mail because:
You are the assignee for the bug.
-
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #7 from Anurag Dubey ---
Hey Christopher Schultz, can you help out with the Pull Request i raised.
--
You are receiving this mail because:
You are the assignee for the bug.
-
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #8 from Mark Thomas ---
The alternative approach is not faster. The test that showed it was was not a
fair test. I will be applying a variation of the original patch.
--
You are receiving this mail because:
You are the assignee fo
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #9 from Christopher Schultz ---
Created attachment 39050
--> https://bz.apache.org/bugzilla/attachment.cgi?id=39050&action=edit
JMH test to compare binarySearch to switch(scope)
# JMH version: 1.37
# VM version: JDK 21, OpenJDK 6
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #10 from Christopher Schultz ---
This test seems to show that there is indeed a speed improvement by using a
switch statement instead of a binary search, somewhere in the 30% range, and it
seems consistent. I didn't get the kind of
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #11 from Mark Thomas ---
(In reply to Mark Thomas from comment #8)
> The alternative approach is not faster. The test that showed it was was not
> a fair test. I will be applying a variation of the original patch.
To be clear the o
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #12 from Anurag Dubey ---
Created attachment 39051
--> https://bz.apache.org/bugzilla/attachment.cgi?id=39051&action=edit
Alternative enum lookup approach JMH
--
You are receiving this mail because:
You are the assignee for the
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #13 from Anurag Dubey ---
(In reply to Mark Thomas from comment #11)
> (In reply to Mark Thomas from comment #8)
> > The alternative approach is not faster. The test that showed it was was not
> > a fair test. I will be applying a v
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #14 from Christopher Schultz ---
The fromLookupAndSwitch technique seems to be implemented in an awkward way.
Why bother converting from String -> Enum and then using a switch on the enum,
instead of just (a) implementing a getScope
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #15 from Christopher Schultz ---
... also what about Scope.valueOf(scopeName) and then you don't have to
implement your own map? It's possible that a manually-constructed Map would be
faster than the default mapping provided by java
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #16 from Anurag Dubey ---
(In reply to Christopher Schultz from comment #14)
> The fromLookupAndSwitch technique seems to be implemented in an awkward way.
> Why bother converting from String -> Enum and then using a switch on the
>
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #17 from Christopher Schultz ---
Fair enough, but if we are going to try to squeeze as much performance out of
this, then the correct process is with delegated dispatch:
enum Scope {
applicationScope(0) {
public Object getSco
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #18 from Mark Thomas ---
(In reply to Christopher Schultz from comment #17)
> If you are going to perform a lookup, make sure you get the best bang for
> your buck.
+1
I'll put together a patch along those lines.
--
You are rec
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
Mark Thomas changed:
What|Removed |Added
Resolution|--- |FIXED
Status|NEW
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
--- Comment #20 from John Engebretson ---
Thank you to everyone involved!
--
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail:
https://bz.apache.org/bugzilla/show_bug.cgi?id=67080
John Engebretson changed:
What|Removed |Added
Status|RESOLVED|VERIFIED
--- Comment #21 from John
22 matches
Mail list logo