-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Go implementation by AlexanderYastrebov
This is a proof-of-concept to demonstrate non-java submission. It requires Docker with BuildKit plugin to build and export binary. Updates * #67 * #253
- Loading branch information
1 parent
3127962
commit 2e26992
Showing
9 changed files
with
491 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -46,3 +46,4 @@ out/ | |
/measurements*.txt | ||
/*.out | ||
out_expected.txt | ||
/*-timing.json |
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,20 @@ | ||
#!/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. | ||
# | ||
|
||
INPUT=${1:-"measurements.txt"} | ||
|
||
target/AlexanderYastrebov/1brc "$INPUT" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/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. | ||
# | ||
|
||
DOCKER_BUILDKIT=1 docker build -o target/AlexanderYastrebov src/main/go/AlexanderYastrebov |
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,22 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
FROM golang AS build-stage | ||
COPY . src/ | ||
RUN cd src && go build . | ||
|
||
FROM scratch AS export-stage | ||
COPY --from=build-stage /go/src/1brc / |
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,58 @@ | ||
# 1brc in go | ||
|
||
It uses Docker with BuildKit plugin to build and [export binary](https://docs.docker.com/engine/reference/commandline/build/#output) binary, | ||
see [prepare_AlexanderYastrebov.sh](../../../../prepare_AlexanderYastrebov.sh) | ||
and [calculate_average_AlexanderYastrebov.sh](../../../../calculate_average_AlexanderYastrebov.sh). | ||
|
||
Demo: | ||
```sh | ||
$ ./test.sh AlexanderYastrebov | ||
[+] Building 0.2s (9/9) FINISHED | ||
=> [internal] load .dockerignore 0.0s | ||
=> => transferring context: 2B 0.0s | ||
=> [internal] load build definition from Dockerfile 0.0s | ||
=> => transferring dockerfile: 172B 0.0s | ||
=> [internal] load metadata for docker.io/library/golang:latest 0.0s | ||
=> [internal] load build context 0.0s | ||
=> => transferring context: 145B 0.0s | ||
=> [build-stage 1/3] FROM docker.io/library/golang 0.0s | ||
=> CACHED [build-stage 2/3] COPY . src/ 0.0s | ||
=> CACHED [build-stage 3/3] RUN cd src && go build . 0.0s | ||
=> CACHED [export-stage 1/1] COPY --from=build-stage /go/src/1brc / 0.0s | ||
=> exporting to client directory 0.1s | ||
=> => copying files 2.03MB 0.0s | ||
Validating calculate_average_AlexanderYastrebov.sh -- src/test/resources/samples/measurements-10000-unique-keys.txt | ||
Validating calculate_average_AlexanderYastrebov.sh -- src/test/resources/samples/measurements-10.txt | ||
Validating calculate_average_AlexanderYastrebov.sh -- src/test/resources/samples/measurements-1.txt | ||
Validating calculate_average_AlexanderYastrebov.sh -- src/test/resources/samples/measurements-20.txt | ||
Validating calculate_average_AlexanderYastrebov.sh -- src/test/resources/samples/measurements-2.txt | ||
Validating calculate_average_AlexanderYastrebov.sh -- src/test/resources/samples/measurements-3.txt | ||
Validating calculate_average_AlexanderYastrebov.sh -- src/test/resources/samples/measurements-boundaries.txt | ||
Validating calculate_average_AlexanderYastrebov.sh -- src/test/resources/samples/measurements-complex-utf8.txt | ||
Validating calculate_average_AlexanderYastrebov.sh -- src/test/resources/samples/measurements-dot.txt | ||
Validating calculate_average_AlexanderYastrebov.sh -- src/test/resources/samples/measurements-shortest.txt | ||
Validating calculate_average_AlexanderYastrebov.sh -- src/test/resources/samples/measurements-short.txt | ||
|
||
# Run once to setup the benchmark | ||
# ./create_measurements.sh 1000000000 | ||
# mv measurements.txt measurements_1B.txt | ||
# ln -s measurements_1B.txt measurements.txt | ||
# ./calculate_average_baseline.sh > out_expected.txt | ||
|
||
$ wc -l measurements_1B.txt | ||
1000000000 measurements_1B.txt | ||
|
||
$ ./evaluate2.sh AlexanderYastrebov royvanrijn | ||
... 0.0s | ||
Benchmark 1: ./calculate_average_AlexanderYastrebov.sh 2>&1 | ||
Time (mean ± σ): 16.786 s ± 0.545 s [User: 56.030 s, System: 10.068 s] | ||
Range (min … max): 15.918 s … 17.309 s 5 runs | ||
... | ||
Benchmark 1: ./calculate_average_royvanrijn.sh 2>&1 | ||
Time (mean ± σ): 16.731 s ± 0.190 s [User: 56.485 s, System: 10.279 s] | ||
Range (min … max): 16.490 s … 16.951 s 5 runs | ||
|
||
Summary | ||
AlexanderYastrebov: trimmed mean 16.901712789513336, raw times 16.69836470718,17.30911065018,16.83413600418,15.91787706218,17.17263765718 | ||
royvanrijn: trimmed mean 16.738037123633333, raw times 16.4900939703,16.9513459953,16.5794539913,16.8297746273,16.8048827523 | ||
``` |
Oops, something went wrong.