Skip to content

Commit

Permalink
Use crac to start faster
Browse files Browse the repository at this point in the history
  • Loading branch information
ianopolous committed Jan 31, 2024
1 parent f1fd7b7 commit 3942e98
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
4 changes: 1 addition & 3 deletions calculate_average_ianopolousfast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@
# limitations under the License.
#

JAVA_OPTS="--enable-preview --add-modules=jdk.incubator.vector -Djdk.incubator.vector.VECTOR_ACCESS_OOB_CHECK=0 -XX:-UseTransparentHugePages"

java $JAVA_OPTS --class-path target/average-1.0.0-SNAPSHOT.jar dev.morling.onebrc.CalculateAverage_ianopolousfast
java -XX:CRaCRestoreFrom=$HOME/ianopolousfast --class-path target/average-1.0.0-SNAPSHOT.jar dev.morling.onebrc.CalculateAverage_ianopolousfast
23 changes: 23 additions & 0 deletions prepare_ianopolousfast.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
#
# Copyright 2023 The original authors
#
# Licensed 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
#
# http://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.
#

source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk use java 21.0.2.crac-zulu 1>&2

JAVA_OPTS="--enable-preview --add-modules=jdk.incubator.vector -Djdk.incubator.vector.VECTOR_ACCESS_OOB_CHECK=0 -XX:-UseTransparentHugePages -XX:CRaCCheckpointTo=$HOME/ianopolousfast"

java $JAVA_OPTS --class-path target/average-1.0.0-SNAPSHOT.jar dev.morling.onebrc.CalculateAverage_ianopolousfast
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package dev.morling.onebrc;

import jdk.crac.Core;
import jdk.incubator.vector.ByteVector;
import jdk.incubator.vector.VectorOperators;
import jdk.incubator.vector.VectorSpecies;
Expand Down Expand Up @@ -50,6 +51,7 @@ public class CalculateAverage_ianopolousfast {
: ByteVector.SPECIES_64;

public static void main(String[] args) throws Exception {
Core.checkpointRestore();
Arena arena = Arena.global();
Path input = Path.of("measurements.txt");
FileChannel channel = (FileChannel) Files.newByteChannel(input, StandardOpenOption.READ);
Expand Down

0 comments on commit 3942e98

Please sign in to comment.