GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing github.com — Optimize HTTP startline validation by franz1981 · Pull Request #16030 · netty/netty ConversationMotivation: netty#16020 has introduced too many math operations for something which should really be to handle an exceptional case, impacting performance Modification: Simplify the validation logic and allow the JVM to do its magic Result: Fixes netty#16020 with less perf impacts
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
IDK, i suggest to check this first. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| for (int i = 0; i < lenBytes; i++) { | ||
| char ch = token.charAt(i); | ||
| // this is to help AOT compiled code which cannot profile the switch | ||
| if (ch <= ' ') { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I could have similarly use a lookup table with 128 boolean and handle the US-ASCII case as
If (c < 128) {
If (invalid[c & 0x7F]) return false;
}
In case is frequent that chars are below SPACE
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@chrisvest @vietj PTAL... this looks much simpler |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
FYI @normanmaurer @chrisvest with this PR: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@chrisvest I'm waiting the CI to be green and I'm going to merge it to make sure will be in ....[Hottest Region 1].............................................................................. c2, level 4, io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri, version 2, compile id 1214 ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@-1 (line 35) 0.46% 0x00007f7cc8236eaa: mov $0x1,%eax 0x00007f7cc8236eaf: movabs $0x45d37b5d0,%r10 ; {oop([B{0x000000045d37b5d0})} 0x00007f7cc8236eb9: mov $0x1,%r11d ╭ 0x00007f7cc8236ebf: jmp 0x00007f7cc8236ed3 │ 0x00007f7cc8236ec1: nopl 0x0(%rax,%rax,1) │ 0x00007f7cc8236ec9: nopl 0x0(%rax) │ ↗ 0x00007f7cc8236ed0: mov %r8d,%r11d ;*aload_0 {reexecute=0 rethrow=0 return_oop=0} │ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@14 (line 108) │ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) 0.10% ↘ │ 0x00007f7cc8236ed3: movslq %r11d,%r8 ;*baload {reexecute=0 rethrow=0 return_oop=0} │ ; - java.lang.StringLatin1::charAt@8 (line 46) │ ; - java.lang.String::charAt@12 (line 1624) │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@16 (line 108) │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) 0.36% │ 0x00007f7cc8236ed6: movzbl 0x10(%r10,%r8,1),%ecx ;*iand {reexecute=0 rethrow=0 return_oop=0} │ ; - java.lang.StringLatin1::charAt@12 (line 46) │ ; - java.lang.String::charAt@12 (line 1624) │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@16 (line 108) │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) 8.81% │ 0x00007f7cc8236edc: cmp $0x20,%ecx │ 0x00007f7cc8236edf: jle 0x00007f7cc8236f91 ;*if_icmpgt {reexecute=0 rethrow=0 return_oop=0} │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@25 (line 110) │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) │ 0x00007f7cc8236ee5: movzbl 0x11(%r10,%r8,1),%ecx ;*iand {reexecute=0 rethrow=0 return_oop=0} │ ; - java.lang.StringLatin1::charAt@12 (line 46) │ ; - java.lang.String::charAt@12 (line 1624) │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@16 (line 108) │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) 9.51% │ 0x00007f7cc8236eeb: cmp $0x20,%ecx ╭ │ 0x00007f7cc8236eee: jle 0x00007f7cc8236f84 ;*if_icmpgt {reexecute=0 rethrow=0 return_oop=0} │ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@25 (line 110) │ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) │ │ 0x00007f7cc8236ef4: movzbl 0x12(%r10,%r8,1),%ecx ;*iand {reexecute=0 rethrow=0 return_oop=0} │ │ ; - java.lang.StringLatin1::charAt@12 (line 46) │ │ ; - java.lang.String::charAt@12 (line 1624) │ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@16 (line 108) │ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) 9.52% │ │ 0x00007f7cc8236efa: cmp $0x20,%ecx │ │ 0x00007f7cc8236efd: jle 0x00007f7cc8236f8d ;*if_icmpgt {reexecute=0 rethrow=0 return_oop=0} │ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@25 (line 110) │ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) │ │ 0x00007f7cc8236f03: movzbl 0x13(%r10,%r8,1),%ecx ;*iand {reexecute=0 rethrow=0 return_oop=0} │ │ ; - java.lang.StringLatin1::charAt@12 (line 46) │ │ ; - java.lang.String::charAt@12 (line 1624) │ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@16 (line 108) │ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) 10.66% │ │ 0x00007f7cc8236f09: cmp $0x20,%ecx │╭ │ 0x00007f7cc8236f0c: jle 0x00007f7cc8236f7a ;*if_icmpgt {reexecute=0 rethrow=0 return_oop=0} ││ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@25 (line 110) ││ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) ││ │ 0x00007f7cc8236f0e: movzbl 0x14(%r10,%r8,1),%ecx ;*iand {reexecute=0 rethrow=0 return_oop=0} ││ │ ; - java.lang.StringLatin1::charAt@12 (line 46) ││ │ ; - java.lang.String::charAt@12 (line 1624) ││ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@16 (line 108) ││ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) 9.51% ││ │ 0x00007f7cc8236f14: cmp $0x20,%ecx ││ │ 0x00007f7cc8236f17: jle 0x00007f7cc8236fac ;*if_icmpgt {reexecute=0 rethrow=0 return_oop=0} ││ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@25 (line 110) ││ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) ││ │ 0x00007f7cc8236f1d: movzbl 0x15(%r10,%r8,1),%ecx ;*iand {reexecute=0 rethrow=0 return_oop=0} ││ │ ; - java.lang.StringLatin1::charAt@12 (line 46) ││ │ ; - java.lang.String::charAt@12 (line 1624) ││ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@16 (line 108) ││ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) 9.40% ││ │ 0x00007f7cc8236f23: cmp $0x20,%ecx ││╭ │ 0x00007f7cc8236f26: jle 0x00007f7cc8236f80 ;*if_icmpgt {reexecute=0 rethrow=0 return_oop=0} │││ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@25 (line 110) │││ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) │││ │ 0x00007f7cc8236f28: movzbl 0x16(%r10,%r8,1),%ecx ;*iand {reexecute=0 rethrow=0 return_oop=0} │││ │ ; - java.lang.StringLatin1::charAt@12 (line 46) │││ │ ; - java.lang.String::charAt@12 (line 1624) │││ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@16 (line 108) │││ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) 9.51% │││ │ 0x00007f7cc8236f2e: cmp $0x20,%ecx │││╭ │ 0x00007f7cc8236f31: jle 0x00007f7cc8236f89 ;*if_icmpgt {reexecute=0 rethrow=0 return_oop=0} ││││ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@25 (line 110) ││││ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) ││││ │ 0x00007f7cc8236f33: movzbl 0x17(%r10,%r8,1),%ecx ;*iand {reexecute=0 rethrow=0 return_oop=0} ││││ │ ; - java.lang.StringLatin1::charAt@12 (line 46) ││││ │ ; - java.lang.String::charAt@12 (line 1624) ││││ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@16 (line 108) ││││ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) 7.54% ││││ │ 0x00007f7cc8236f39: cmp $0x20,%ecx ││││╭│ 0x00007f7cc8236f3c: jle 0x00007f7cc8236f76 ;*if_icmpgt {reexecute=0 rethrow=0 return_oop=0} ││││││ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@25 (line 110) ││││││ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) ││││││ 0x00007f7cc8236f3e: lea 0x8(%r11),%r8d 9.93% ││││││ 0x00007f7cc8236f42: cmp $0x9e,%r8d │││││╰ 0x00007f7cc8236f49: jl 0x00007f7cc8236ed0 ;*if_icmpge {reexecute=0 rethrow=0 return_oop=0} │││││ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@11 (line 107) │││││ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) │││││ 0x00007f7cc8236f4b: add $0x8,%r11d ;*aload_0 {reexecute=0 rethrow=0 return_oop=0} │││││ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@14 (line 108) │││││ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) │││││ ↗ 0x00007f7cc8236f4f: movzbl 0x10(%r10,%r11,1),%ecx ;*iand {reexecute=0 rethrow=0 return_oop=0} │││││ │ ; - java.lang.StringLatin1::charAt@12 (line 46) │││││ │ ; - java.lang.String::charAt@12 (line 1624) │││││ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@16 (line 108) │││││ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) 0.06% │││││ │ 0x00007f7cc8236f55: cmp $0x20,%ecx 0.52% │││││ │ 0x00007f7cc8236f58: jle 0x00007f7cc8236f91 ;*if_icmpgt {reexecute=0 rethrow=0 return_oop=0} │││││ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@25 (line 110) │││││ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) │││││ │ 0x00007f7cc8236f5a: inc %r11d ;*iinc {reexecute=0 rethrow=0 return_oop=0} │││││ │ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@66 (line 107) │││││ │ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) 3.71% │││││ │ 0x00007f7cc8236f5d: cmp $0xa5,%r11d │││││ ╰ 0x00007f7cc8236f64: jl 0x00007f7cc8236f4f ;*if_icmpge {reexecute=0 rethrow=0 return_oop=0} │││││ ; - io.netty.handler.codec.http.HttpUtil::isEncodingSafeStartLineToken@11 (line 107) │││││ ; - io.netty.microbench.http.HttpUtilBenchmark::checkIsEncodingSafeUri@2 (line 35) │││││ 0x00007f7cc8236f66: add $0x20,%rsp │││││ 0x00007f7cc8236f6a: pop %rbp 6.91% │││││ 0x00007f7cc8236f6b: cmp 0x28(%r15),%rsp ; {poll_return} │││││ 0x00007f7cc8236f6f: ja 0x00007f7cc8236fb2 │││││ 0x00007f7cc8236f75: ret ││││↘ 0x00007f7cc8236f76: add $0x4,%r11d │↘││ 0x00007f7cc8236f7a: add $0x2,%r11d │ ││ ╭ 0x00007f7cc8236f7e: jmp 0x00007f7cc8236f84 │ ↘│ │ 0x00007f7cc8236f80: add $0x4,%r11d ↘ │ ↘ 0x00007f7cc8236f84: inc %r11d │ 0x00007f7cc8236f87: jmp 0x00007f7cc8236f91 ↘ 0x00007f7cc8236f89: add $0x4,%r11d 0x00007f7cc8236f8d: add $0x2,%r11d ;*if_icmpgt {reexecute=0 rethrow=0 return_oop=0} .................................................................................................... 96.05% <total for region 1> Clearly this is the best case scenario with 8 unrolling factor, but is rather unlikely we would get less than 4 as each step of the unrolled body is as simple as movzbl 0x10(%r10,%r8,1),%ecx cmp $0x20,%ecx jle 0x00007f7cc8236f91 which there's no way could be made any faster since it doesn't perform any math ( |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@franz1981 ready to go in ? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Go for it @normanmaurer |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Motivation: should really be to handle an exceptional case, impacting performance Modification: Simplify the validation logic and allow the JVM to do its magic Result: Fixes #16020 with less perf impacts
Motivation: #16020 has introduced too many math operations for something which should really be to handle an exceptional case, impacting performance Modification: Simplify the validation logic and allow the JVM to do its magic Result: Fixes #16020 with less perf impacts --------- Co-authored-by: Francesco Nigro <[email protected]>
Motivation: #16020 has introduced too many math operations for something which should really be to handle an exceptional case, impacting performance Modification: Simplify the validation logic and allow the JVM to do its magic Result: Fixes #16020 with less perf impacts Co-authored-by: Francesco Nigro <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Exception will be thrown if uri string contains the character 'M'.
There was an error while loading. Please reload this page.