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

refactor #3294

Merged
merged 15 commits into from
Jan 19, 2025
23 changes: 0 additions & 23 deletions benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@
<artifactId>fastjson2-extension</artifactId>
<version>${project.version}</version>
</dependency>
<!--
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-incubator-vector</artifactId>
<version>${project.version}</version>
</dependency>
-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
Expand Down Expand Up @@ -217,20 +210,4 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>enable-incubators-for-jdk17+</id>
<activation>
<jdk>[17,)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-incubator-vector</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static void fastjson2() {
}
long millis = System.currentTimeMillis() - start;
System.out.println("fastjson2 millis : " + millis);
// zulu8.70.0.23 : 5569 5630 4435
// zulu8.70.0.23 : 5569 5630 4435 4199 3851
// zulu11.64.19 : 5022 5033 3754
// zulu17.42.19 : 5377 5193 5222 5154 5116 5083 4987 4079
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static void fastjson2() {
}
long millis = System.currentTimeMillis() - start;
System.out.println("fastjson2 millis : " + millis);
// zulu8.62.0.19 : 703 746 710 706 700 682 717 698 526 500 474
// zulu8.62.0.19 : 703 746 710 706 700 682 717 698 526 500 474 445
// zulu11.52.13 : 579 565 552 541 554 553 554 538 420 424 434
// zulu17.40.19 : 600 604 597 593 578 567 447 420
}
Expand Down Expand Up @@ -63,8 +63,8 @@ public static void jackson() throws Exception {
}

public static void main(String[] args) throws Exception {
// fastjson2();
fastjson2_features();
fastjson2();
// fastjson2_features();
// dsljson();
// jackson();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void fastjson2() {
System.out.println("fastjson2 millis : " + millis);
// zulu8.70.0.23 : 3001 2795
// zulu11.62.17 : 3288 2549
// zulu17.32.13 : 3305 2909 2503
// zulu17.32.13 : 3305 2909 2503 2353
// zulu17.40.91_vec : 2527 2536
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static void fastjson2() {
long millis = System.currentTimeMillis() - start;
System.out.println("ClientsWriteUTF8Bytes-fastjson2 millis : " + millis);
// zulu8.70.0.23 : 1533 1493 1374 1353
// zulu17.40.19 : 1419 1361 1356 1356 1317 1224 1212 1202 1182 979
// zulu17.40.19 : 1419 1361 1356 1356 1317 1224 1212 1202 1182 979 949
// zulu17.40.19_vec : 1116
// zulu17.40.19_reflect : 1427
}
Expand Down
56 changes: 0 additions & 56 deletions core/src/main/java/com/alibaba/fastjson2/JSONFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.function.Function;
import java.util.function.Supplier;

import static com.alibaba.fastjson2.util.JDKUtils.VECTOR_BIT_LENGTH;

public final class JSONFactory {
public static final class Conf {
static final Properties DEFAULT_PROPERTIES;
Expand Down Expand Up @@ -93,11 +90,6 @@ public static String getProperty(String key) {
static final NameCacheEntry[] NAME_CACHE = new NameCacheEntry[8192];
static final NameCacheEntry2[] NAME_CACHE2 = new NameCacheEntry2[8192];

static final Function<JSONWriter.Context, JSONWriter> INCUBATOR_VECTOR_WRITER_CREATOR_UTF16;
static final JSONReaderUTF8Creator INCUBATOR_VECTOR_READER_CREATOR_ASCII;
static final JSONReaderUTF8Creator INCUBATOR_VECTOR_READER_CREATOR_UTF8;
static final JSONReaderUTF16Creator INCUBATOR_VECTOR_READER_CREATOR_UTF16;

static int defaultDecimalMaxScale = 2048;

interface JSONReaderUTF8Creator {
Expand Down Expand Up @@ -164,8 +156,6 @@ public NameCacheEntry2(String name, long value0, long value1) {
1.0e20, 1.0e21, 1.0e22
};

static final Double DOUBLE_ZERO = (double) 0;

static {
Properties properties = Conf.DEFAULT_PROPERTIES;
{
Expand Down Expand Up @@ -227,52 +217,6 @@ public NameCacheEntry2(String name, long value0, long value1) {
useJacksonAnnotation = getPropertyBool(properties, "fastjson2.useJacksonAnnotation", true);
useGsonAnnotation = getPropertyBool(properties, "fastjson2.useGsonAnnotation", true);
defaultWriterAlphabetic = getPropertyBool(properties, "fastjson2.writer.alphabetic", true);

boolean readerVector = getPropertyBool(properties, "fastjson2.readerVector", false);

Function<JSONWriter.Context, JSONWriter> incubatorVectorCreatorUTF16 = null;
JSONReaderUTF8Creator readerCreatorASCII = null;
JSONReaderUTF8Creator readerCreatorUTF8 = null;
JSONReaderUTF16Creator readerCreatorUTF16 = null;
if (JDKUtils.VECTOR_SUPPORT) {
if (VECTOR_BIT_LENGTH >= 64) {
try {
Class<?> factoryClass = Class.forName("com.alibaba.fastjson2.JSONWriterUTF16Vector$Factory");
incubatorVectorCreatorUTF16 = (Function<JSONWriter.Context, JSONWriter>) factoryClass.newInstance();
} catch (Throwable e) {
initErrorLast = e;
}

if (readerVector) {
try {
Class<?> factoryClass = Class.forName("com.alibaba.fastjson2.JSONReaderASCIIVector$Factory");
readerCreatorASCII = (JSONReaderUTF8Creator) factoryClass.newInstance();
} catch (Throwable e) {
initErrorLast = e;
}

try {
Class<?> factoryClass = Class.forName("com.alibaba.fastjson2.JSONReaderUTF8Vector$Factory");
readerCreatorUTF8 = (JSONReaderUTF8Creator) factoryClass.newInstance();
} catch (Throwable e) {
initErrorLast = e;
}
}
}

if (VECTOR_BIT_LENGTH >= 128 && readerVector) {
try {
Class<?> factoryClass = Class.forName("com.alibaba.fastjson2.JSONReaderUTF16Vector$Factory");
readerCreatorUTF16 = (JSONReaderUTF16Creator) factoryClass.newInstance();
} catch (Throwable e) {
initErrorLast = e;
}
}
}
INCUBATOR_VECTOR_WRITER_CREATOR_UTF16 = incubatorVectorCreatorUTF16;
INCUBATOR_VECTOR_READER_CREATOR_ASCII = readerCreatorASCII;
INCUBATOR_VECTOR_READER_CREATOR_UTF8 = readerCreatorUTF8;
INCUBATOR_VECTOR_READER_CREATOR_UTF16 = readerCreatorUTF16;
}

private static boolean getPropertyBool(Properties properties, String name, boolean defaultValue) {
Expand Down
Loading
Loading