Skip to content
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

Add QueryParams which deprecates HttpParameters #2307

Merged
merged 49 commits into from
Dec 20, 2019
Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
959f402
Add `QueryParams` which deprecates `HttpParameters`
trustin Dec 10, 2019
dfa5d11
Merge branch 'master' into immutable_http_params
trustin Dec 11, 2019
eb6bf37
Checkstyle
trustin Dec 11, 2019
8c47f62
Share the common logic between `QueryParamsBase` and `HttpHeadersBase`
trustin Dec 11, 2019
a70b113
Add some tests to ensure API consistency
trustin Dec 11, 2019
7863cca
Fix test failure
trustin Dec 11, 2019
6687a81
Rename a bunch of stuff for consistency
trustin Dec 11, 2019
acea7ff
Fix import
trustin Dec 11, 2019
48751d6
AbstractStringMultimapBuilder -> StringMultimapBuilder
trustin Dec 11, 2019
f7ae4e9
Add `QueryParamGetters.toQueryString()` and `appendQueryString()`
trustin Dec 12, 2019
5613b6d
Checkstyle and cleanup
trustin Dec 12, 2019
3f5a874
Documentation
trustin Dec 12, 2019
79ffa65
Add Javadoc return tag
trustin Dec 12, 2019
4a27a93
Merge branch 'master' into immutable_http_params
trustin Dec 14, 2019
c3ea71c
Address the comments from @anuraaga and @ikhoon
trustin Dec 14, 2019
b8c6d5e
Fix comment, inspired by @ikhoon's comment
trustin Dec 14, 2019
3663f03
Checkstyle
trustin Dec 14, 2019
b365e6d
Clean-up
trustin Dec 15, 2019
df1a365
Address the comments from @minwoox
trustin Dec 16, 2019
a041106
Address one more comment from @minwoox
trustin Dec 16, 2019
c5c096a
Address yet another comment from @minwoox
trustin Dec 16, 2019
7eea42f
Address some of the comments from @anuraaga
trustin Dec 16, 2019
39521ff
Replace `ThreadLocalByteArray` with `TemporaryThreadLocals` / Optimiz…
trustin Dec 16, 2019
ce90fe5
Optimization
trustin Dec 17, 2019
bfd2196
Simplify
trustin Dec 17, 2019
0ef906b
Clean-up
trustin Dec 18, 2019
1bc56ae
Fix encoder bug / Optimize decoder / More tests
trustin Dec 18, 2019
b8c5e91
Add benchmark for `QueryStringDecoder`
trustin Dec 18, 2019
937779c
Switch to traditional decoding loop as advised by @anuraaga
trustin Dec 18, 2019
2cac19f
Optimization and fix
trustin Dec 18, 2019
266cdc2
Further optimization of ASCII decoding
trustin Dec 18, 2019
9240e84
Optimize the decoder tad bit more, allowing us to win at any case
trustin Dec 18, 2019
b4956d0
Slightly more compact lookup table
trustin Dec 18, 2019
47f448d
Use `hashName()` instead of `.hashCode()` for names
trustin Dec 18, 2019
1e78f95
Clean-up benchmarks and add test for long query string
trustin Dec 18, 2019
e44d3b3
Improve safe octet scanning in `QueryStringEncoder` as advised by @an…
trustin Dec 18, 2019
ba0e903
Optimize percent encoding
trustin Dec 18, 2019
3d9123c
Borrow more from Guava
trustin Dec 18, 2019
c67ffb7
Checkstyle
trustin Dec 18, 2019
541796b
Experiment: Pre-inflate `StringBuilder`
trustin Dec 18, 2019
fd1c4e5
Micro clean-up
trustin Dec 18, 2019
c399ff9
Checkstyle
trustin Dec 19, 2019
8383ef9
Experiment: Make `char[]` stack-allocated by JVM
trustin Dec 19, 2019
5d17e4a
Checkstyle
trustin Dec 19, 2019
959793f
Merge branches
trustin Dec 19, 2019
59b00d5
Add Guava copyright header
trustin Dec 19, 2019
5b7dfaf
Checkstyle
trustin Dec 19, 2019
1cb66cb
Address the comments from @anuraaga
trustin Dec 19, 2019
4ae61e4
Address the comments from @minwoox
trustin Dec 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add benchmark for QueryStringDecoder
  • Loading branch information
trustin committed Dec 18, 2019
commit b8c5e9157cd4ef7de1c4b9234fc8aa431b1a6fa8
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright 2018 LINE Corporation
trustin marked this conversation as resolved.
Show resolved Hide resolved
*
* 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.common;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.infra.Blackhole;

import com.google.common.escape.Escaper;
import com.google.common.net.UrlEscapers;

import com.linecorp.armeria.internal.TemporaryThreadLocals;

import io.netty.handler.codec.http.QueryStringDecoder;

/**
* Microbenchmarks for encoding query parameters.
*/
public class QueryStringDecoderBenchmark {

private static final Escaper guavaEscaper = UrlEscapers.urlFormParameterEscaper();

private static final String ASCII_PARAMS;
private static final String UNICODE_PARAMS;
private static final String MIXED_PARAMS;

static {
final QueryParamsBuilder ascii = QueryParams.builder();
for (int i = 0; i < 10; i++) {
ascii.add("alpha", "beta_gamma")
.add("delta", "epsilon_zeta")
.add("eta", "theta_iota")
.add("kappa", "lambda_mu");
}
ASCII_PARAMS = ascii.build().toQueryString();

final QueryParamsBuilder unicode = QueryParams.builder();
for (int i = 0; i < 10; i++) {
unicode.add("알파", "베타・감마") // Hangul
.add("アルファ", "ベータ・ガンマ") // Katakana
.add("电买车红", "无东马风") // Simplified Chinese
.add("🎄❤️😂", "🎅🔥😊🎁"); // Emoji
}
UNICODE_PARAMS = unicode.build().toQueryString();

final QueryParamsBuilder mixed = QueryParams.builder();
for (int i = 0; i < 10; i++) {
mixed.add("foo", "alpha・ベータ")
.add("bar", "ガンマ・delta")
.add("baz", "nothing_无_east_东_horse_马_wind_风")
.add("qux", "santa_🎅_fire_🔥_smile_😊_present_🎁");
}
MIXED_PARAMS = mixed.build().toQueryString();
}

@Benchmark
public void armeriaAscii(Blackhole bh) {
bh.consume(QueryParams.fromQueryString(ASCII_PARAMS));
}

@Benchmark
public void armeriaUnicode(Blackhole bh) {
bh.consume(QueryParams.fromQueryString(UNICODE_PARAMS));
}

@Benchmark
public void armeriaMixed(Blackhole bh) {
bh.consume(QueryParams.fromQueryString(MIXED_PARAMS));
}

@Benchmark
public void nettyAscii(Blackhole bh) {
bh.consume(nettyDecode(ASCII_PARAMS));
}

@Benchmark
public void nettyUnicode(Blackhole bh) {
bh.consume(nettyDecode(UNICODE_PARAMS));
}

@Benchmark
public void nettyMixed(Blackhole bh) {
bh.consume(nettyDecode(MIXED_PARAMS));
}

private static Map<String, List<String>> nettyDecode(String queryString) {
return new QueryStringDecoder(queryString, false).parameters();
}
}