-
Notifications
You must be signed in to change notification settings - Fork 926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle a fragment in a client-side URI properly #4789
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
40bf116
Handle a fragment in a client-side URI
trustin b1f64f6
Deduplicate as per @ikhoon's comment
trustin 75c5f45
Fix a bug where an empty query is translated into `/`
trustin 288899e
Made `RequestContext.updateRequest()` disallow an absolute-form target
trustin 8b07e7c
Update core/src/main/java/com/linecorp/armeria/server/HttpServerHandl…
minwoox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
79 changes: 0 additions & 79 deletions
79
benchmarks/jmh/src/jmh/java/com/linecorp/armeria/internal/common/PathParsingBenchmark.java
This file was deleted.
Oops, something went wrong.
119 changes: 119 additions & 0 deletions
119
benchmarks/jmh/src/jmh/java/com/linecorp/armeria/internal/common/RequestTargetBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* Copyright 2017 LINE Corporation | ||
* | ||
* LINE Corporation licenses this file to you under the Apache License, | ||
* version 2.0 (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.linecorp.armeria.internal.common; | ||
|
||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Level; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
import com.linecorp.armeria.common.RequestTarget; | ||
|
||
/** | ||
* Microbenchmarks for {@link RequestTarget}. | ||
*/ | ||
@State(Scope.Thread) | ||
public class RequestTargetBenchmark { | ||
|
||
private static final String NO_CACHE_JVM_OPTS = "-Dcom.linecorp.armeria.parsedPathCacheSpec=off"; | ||
|
||
private String path1; | ||
private String path2; | ||
|
||
@Setup(Level.Invocation) | ||
@SuppressWarnings("StringOperationCanBeSimplified") | ||
public void setUp() { | ||
// Create a new String for paths every time to avoid constant folding. | ||
path1 = new String("/armeria/services/hello-world"); | ||
path2 = new String("/armeria/services/goodbye-world"); | ||
} | ||
|
||
@Benchmark | ||
public RequestTarget serverCached() { | ||
return doServer(); | ||
} | ||
|
||
@Benchmark | ||
@Fork(jvmArgsAppend = NO_CACHE_JVM_OPTS) | ||
public RequestTarget serverUncached() { | ||
return doServer(); | ||
} | ||
|
||
private RequestTarget doServer() { | ||
final RequestTarget parsed = RequestTarget.forServer(path1); | ||
RequestTargetCache.putForServer(path1, parsed); | ||
return parsed; | ||
} | ||
|
||
@Benchmark | ||
public RequestTarget serverCachedAndUncached(Blackhole bh) { | ||
return doServerCachedAndUncached(bh); | ||
} | ||
|
||
@Benchmark | ||
@Fork(jvmArgsAppend = NO_CACHE_JVM_OPTS) | ||
public RequestTarget serverUncachedAndUncached(Blackhole bh) { | ||
return doServerCachedAndUncached(bh); | ||
} | ||
|
||
private RequestTarget doServerCachedAndUncached(Blackhole bh) { | ||
final RequestTarget parsed = RequestTarget.forServer(path1); | ||
RequestTargetCache.putForServer(path1, parsed); | ||
final RequestTarget parsed2 = RequestTarget.forServer(path2); | ||
bh.consume(parsed2); | ||
return parsed; | ||
} | ||
|
||
@Benchmark | ||
public RequestTarget clientCached() { | ||
return doServer(); | ||
} | ||
|
||
@Benchmark | ||
@Fork(jvmArgsAppend = NO_CACHE_JVM_OPTS) | ||
public RequestTarget clientUncached() { | ||
return doClient(); | ||
} | ||
|
||
private RequestTarget doClient() { | ||
final RequestTarget parsed = RequestTarget.forClient(path1); | ||
RequestTargetCache.putForClient(path1, parsed); | ||
return parsed; | ||
} | ||
|
||
@Benchmark | ||
public RequestTarget clientCachedAndUncached(Blackhole bh) { | ||
return doClientCachedAndUncached(bh); | ||
} | ||
|
||
@Benchmark | ||
@Fork(jvmArgsAppend = NO_CACHE_JVM_OPTS) | ||
public RequestTarget clientUncachedAndUncached(Blackhole bh) { | ||
return doClientCachedAndUncached(bh); | ||
} | ||
|
||
private RequestTarget doClientCachedAndUncached(Blackhole bh) { | ||
final RequestTarget parsed = RequestTarget.forClient(path1); | ||
RequestTargetCache.putForClient(path1, parsed); | ||
final RequestTarget parsed2 = RequestTarget.forClient(path2); | ||
bh.consume(parsed2); | ||
return parsed; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file was actually renamed from
PathParsingBenchmark
.