diff --git a/misc/experiments.md b/misc/experiments.md index 2e47336..b5a1cd4 100644 --- a/misc/experiments.md +++ b/misc/experiments.md @@ -28,5 +28,105 @@ Docker image: tugraph/tugraph-compile-centos8:1.3.1 - Baseline: - Optimized: - Datasets: + - SF100:https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/datasets/finbench/v0.2.0/sf100/sf100.tar.xz + - Parameter of SF100:https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/datasets/finbench/v0.2.0/sf100/substitute_parameters.tar.gz. -## Experiment Steps \ No newline at end of file +## Experiment Steps + +### Move to directory +Download dataset and parameter and move them to the dataset directory, for example, the directory '/data/dataset'. + +Modify docker-compose.yml to attach local file to volume '/root/datasets/' in container, for example, +``` +volumes: + - /data/dataset:/root/datasets/ + - ./scripts:/root/scripts/ +``` + +Start docker containers. +``` +docker-compose up -d +``` + +After that, will see two containers. +- [directory name]_tugraph_1 +- [directory name]_finbench_1 + +Benchmark is based on a large-scale SF100 dataset, and the following scripts are required. + +### Install package +First, attach to the 'finbench-easyrun_tugraph_1' container. + +Then install the package. +``` +rpm -i base.rpm +``` + +### Import data +Enter the '/root/scripts' directory. +``` +bash sf100_import.sh +``` + +### Start tugraph server +Also in the same container 'finbench-easyrun_tugraph_1' and same directory'/root/scripts', start the server. +``` +bash sf100_start.sh +``` + +### C++ Plugin +Switch to another container 'finbench'. + +Enter the '/root/scripts' directory. +``` +bash load_procedure.sh +``` +To install C++ plugins. + +### Benchmark Baseline +Before benchmark, in the container 'finbench', copy the file 'benchmark_sf100.properties' in scripts to the directory '/root/ldbc/ldbc_finbench_transaction_impls/tugraph/benchmark.properties'. + +Also in the 'finbench' container and enter the '/root/scripts' directory. +``` +bash sf100_benchmark.sh +``` + +### Benchmark Opt +Attach to container 'tugraph'. + +Uninstall the baseline package. +``` +rpm -e tugraph-4.0.0-1.x86_64 +``` +Install the opt version. +``` +rpm -i opt.rpm +``` + +Switch to '/root/scripts'. + +Delete the old data directory. + +``` +rm -r /root/lgraph_db_sf100 +rm -r /root/lgraph_log_sf100 + +bash sf100_import.sh +bash sf100_start.sh +``` + +Attach to 'finbench' container, and enter '/root/scripts'. +``` +bash load_procedure.sh +``` + +Before benchmark, comment the line +``` +# cd data && ln -s /root/datasets/sf100 ./sf100 && cd .. +``` +in the file 'sf100_benchmark.properties' + +Then run the benchmark. +``` +bash sf100_benchmark.sh +``` diff --git a/misc/opt_recursive/docker-compose.yml b/misc/opt_recursive/docker-compose.yml new file mode 100644 index 0000000..2afb660 --- /dev/null +++ b/misc/opt_recursive/docker-compose.yml @@ -0,0 +1,22 @@ +version: "3" +services: + tugraph: + image: tugraph/tugraph-compile-centos8:1.2.9 + command: tail -f + tty: true + volumes: + - /data/dataset:/root/datasets/ + - ./scripts:/root/scripts/ + expose: + - 7070 + - 9090 + + finbench: + depends_on: + - tugraph + image: tugraph/tugraph-bdci-finbench:cent8 + command: tail -f + tty: true + volumes: + - /data/dataset:/root/datasets/ + - ./scripts:/root/scripts/ diff --git a/misc/opt_recursive/scripts/benchmark_sf100.properties b/misc/opt_recursive/scripts/benchmark_sf100.properties new file mode 100644 index 0000000..baea693 --- /dev/null +++ b/misc/opt_recursive/scripts/benchmark_sf100.properties @@ -0,0 +1,91 @@ +############################################################ +# SUT defined configurations # +############################################################ +uri=list://172.21.189.228:9090 +user=admin +pass=73@TuGraph + +############################################################ +# Driver configurations # +############################################################ +status=1 +thread_count=16 +name=LDBC-FinBench +# Modes available: 1.CREATE_VALIDATION 2.VALIDATE_DATABASE 3.EXECUTE_BENCHMARK +mode=EXECUTE_BENCHMARK +results_log=true +time_unit=MICROSECONDS +time_compression_ratio=0.1 +peer_identifiers= +workload_statistics=false +spinner_wait_duration=1 +help=false +ignore_scheduled_start_times=false +workload=org.ldbcouncil.finbench.driver.workloads.transaction.LdbcFinBenchTransactionWorkload +db=org.ldbcouncil.finbench.impls.tugraph.TuGraphTransactionDb +operation_count=1800000 +validation_parameters_size=100 +validate_workload=true +validate_database=validation_params.csv +warmup=450000 +ldbc.finbench.transaction.queries.parameters_dir=data/sf100/read_params +ldbc.finbench.transaction.queries.updates_dir=data/sf100/incremental +# param and update files suffix, `csv` or `parquet`, default is `csv` +ldbc.finbench.transaction.queries.files_suffix=csv +ldbc.finbench.transaction.queries.simple_read_dissipation=0.2 +ldbc.finbench.transaction.queries.update_interleave=500 +ldbc.finbench.transaction.queries.scale_factor=1 +# Frequency of complex read queries +ldbc.finbench.transaction.queries.ComplexRead1_freq=12 +ldbc.finbench.transaction.queries.ComplexRead2_freq=45 +ldbc.finbench.transaction.queries.ComplexRead3_freq=23 +ldbc.finbench.transaction.queries.ComplexRead4_freq=57 +ldbc.finbench.transaction.queries.ComplexRead5_freq=83 +ldbc.finbench.transaction.queries.ComplexRead6_freq=21 +ldbc.finbench.transaction.queries.ComplexRead7_freq=36 +ldbc.finbench.transaction.queries.ComplexRead8_freq=51 +ldbc.finbench.transaction.queries.ComplexRead9_freq=21 +ldbc.finbench.transaction.queries.ComplexRead10_freq=6 +ldbc.finbench.transaction.queries.ComplexRead11_freq=12 +ldbc.finbench.transaction.queries.ComplexRead12_freq=34 +# For debugging purposes +ldbc.finbench.transaction.queries.ComplexRead1_enable=true +ldbc.finbench.transaction.queries.ComplexRead2_enable=true +ldbc.finbench.transaction.queries.ComplexRead3_enable=true +ldbc.finbench.transaction.queries.ComplexRead4_enable=true +ldbc.finbench.transaction.queries.ComplexRead5_enable=true +ldbc.finbench.transaction.queries.ComplexRead6_enable=true +ldbc.finbench.transaction.queries.ComplexRead7_enable=true +ldbc.finbench.transaction.queries.ComplexRead8_enable=true +ldbc.finbench.transaction.queries.ComplexRead9_enable=true +ldbc.finbench.transaction.queries.ComplexRead10_enable=true +ldbc.finbench.transaction.queries.ComplexRead11_enable=true +ldbc.finbench.transaction.queries.ComplexRead12_enable=true +ldbc.finbench.transaction.queries.SimpleRead1_enable=true +ldbc.finbench.transaction.queries.SimpleRead2_enable=true +ldbc.finbench.transaction.queries.SimpleRead3_enable=true +ldbc.finbench.transaction.queries.SimpleRead4_enable=true +ldbc.finbench.transaction.queries.SimpleRead5_enable=true +ldbc.finbench.transaction.queries.SimpleRead6_enable=true +ldbc.finbench.transaction.queries.Write1_enable=true +ldbc.finbench.transaction.queries.Write2_enable=true +ldbc.finbench.transaction.queries.Write3_enable=true +ldbc.finbench.transaction.queries.Write4_enable=true +ldbc.finbench.transaction.queries.Write5_enable=true +ldbc.finbench.transaction.queries.Write6_enable=true +ldbc.finbench.transaction.queries.Write7_enable=true +ldbc.finbench.transaction.queries.Write8_enable=true +ldbc.finbench.transaction.queries.Write9_enable=true +ldbc.finbench.transaction.queries.Write10_enable=true +ldbc.finbench.transaction.queries.Write11_enable=true +ldbc.finbench.transaction.queries.Write12_enable=true +ldbc.finbench.transaction.queries.Write13_enable=true +ldbc.finbench.transaction.queries.Write14_enable=true +ldbc.finbench.transaction.queries.Write15_enable=true +ldbc.finbench.transaction.queries.Write16_enable=true +ldbc.finbench.transaction.queries.Write17_enable=true +ldbc.finbench.transaction.queries.Write18_enable=true +ldbc.finbench.transaction.queries.Write19_enable=true +ldbc.finbench.transaction.queries.ReadWrite1_enable=true +ldbc.finbench.transaction.queries.ReadWrite2_enable=true +ldbc.finbench.transaction.queries.ReadWrite3_enable=true diff --git a/misc/opt_recursive/scripts/import.config b/misc/opt_recursive/scripts/import.config new file mode 100644 index 0000000..598edd6 --- /dev/null +++ b/misc/opt_recursive/scripts/import.config @@ -0,0 +1,693 @@ +{ + "schema": [ + { + "label": "Person", + "type": "VERTEX", + "primary": "id", + "properties": [ + { + "name": "id", + "type": "INT64" + }, + { + "name": "name", + "type": "STRING" + }, + { + "name": "isBlocked", + "type": "BOOL" + }, + { + "name": "createTime", + "type": "STRING", + "optional": true + }, + { + "name": "gender", + "type": "STRING", + "optional": true + }, + { + "name": "birthday", + "type": "STRING", + "optional": true + }, + { + "name": "country", + "type": "STRING", + "optional": true + }, + { + "name": "city", + "type": "STRING", + "optional": true + } + ] + }, + { + "label": "Account", + "type": "VERTEX", + "primary": "id", + "properties": [ + { + "name": "id", + "type": "INT64" + }, + { + "name": "createTime", + "type": "INT64" + }, + { + "name": "isBlocked", + "type": "BOOL" + }, + { + "name": "type", + "type": "STRING" + }, + { + "name": "nickname", + "type": "STRING", + "optional": true + }, + { + "name": "phonenum", + "type": "STRING", + "optional": true + }, + { + "name": "email", + "type": "STRING", + "optional": true + }, + { + "name": "freqLoginType", + "type": "STRING", + "optional": true + }, + { + "name": "lastLoginTime", + "type": "STRING", + "optional": true + }, + { + "name": "accountLevel", + "type": "STRING", + "optional": true + } + ] + }, + { + "label": "Medium", + "type": "VERTEX", + "primary": "id", + "properties": [ + { + "name": "id", + "type": "INT64" + }, + { + "name": "type", + "type": "STRING" + }, + { + "name": "isBlocked", + "type": "BOOL" + }, + { + "name": "createTime", + "type": "STRING", + "optional": true + }, + { + "name": "lastLoginTime", + "type": "STRING", + "optional": true + }, + { + "name": "riskLevel", + "type": "STRING", + "optional": true + } + ] + }, + { + "label": "Loan", + "type": "VERTEX", + "primary": "id", + "properties": [ + { + "name": "id", + "type": "INT64" + }, + { + "name": "loanAmount", + "type": "DOUBLE" + }, + { + "name": "balance", + "type": "DOUBLE" + }, + { + "name": "createTime", + "type": "STRING", + "optional": true + }, + { + "name": "loanUsage", + "type": "STRING", + "optional": true + }, + { + "name": "interestRate", + "type": "STRING", + "optional": true + } + ] + }, + { + "label": "Company", + "type": "VERTEX", + "primary": "id", + "properties": [ + { + "name": "id", + "type": "INT64" + }, + { + "name": "name", + "type": "STRING" + }, + { + "name": "isBlocked", + "type": "BOOL" + }, + { + "name": "createTime", + "type": "STRING", + "optional": true + }, + { + "name": "country", + "type": "STRING", + "optional": true + }, + { + "name": "city", + "type": "STRING", + "optional": true + }, + { + "name": "business", + "type": "STRING", + "optional": true + }, + { + "name": "description", + "type": "STRING", + "optional": true + }, + { + "name": "url", + "type": "STRING", + "optional": true + } + ] + }, + { + "label": "transfer", + "type": "EDGE", + "temporal": "timestamp", + "temporal_order": "DESC", + "properties": [ + { + "name": "timestamp", + "type": "INT64" + }, + { + "name": "amount", + "type": "DOUBLE" + }, + { + "name": "orderNum", + "type": "STRING", + "optional": true + }, + { + "name": "comment", + "type": "STRING", + "optional": true + }, + { + "name": "payType", + "type": "STRING", + "optional": true + }, + { + "name": "goodsType", + "type": "STRING", + "optional": true + } + ] + }, + { + "label": "withdraw", + "type": "EDGE", + "temporal": "timestamp", + "temporal_order": "DESC", + "properties": [ + { + "name": "fromType", + "type": "STRING" + }, + { + "name": "toType", + "type": "STRING" + }, + { + "name": "timestamp", + "type": "INT64" + }, + { + "name": "amount", + "type": "DOUBLE" + }, + { + "name": "comment", + "type": "STRING" + } + ] + }, + { + "label": "repay", + "type": "EDGE", + "temporal": "timestamp", + "temporal_order": "DESC", + "properties": [ + { + "name": "timestamp", + "type": "INT64" + }, + { + "name": "amount", + "type": "DOUBLE" + }, + { + "name": "comment", + "type": "STRING" + } + ] + }, + { + "label": "deposit", + "type": "EDGE", + "temporal": "timestamp", + "temporal_order": "DESC", + "properties": [ + { + "name": "timestamp", + "type": "INT64" + }, + { + "name": "amount", + "type": "DOUBLE" + }, + { + "name": "comment", + "type": "STRING" + } + ] + }, + { + "label": "signIn", + "type": "EDGE", + "temporal": "timestamp", + "temporal_order": "DESC", + "properties": [ + { + "name": "timestamp", + "type": "INT64" + }, + { + "name": "comment", + "type": "STRING" + }, + { + "name": "location", + "type": "STRING", + "optional": true + } + ] + }, + { + "label": "invest", + "type": "EDGE", + "temporal": "timestamp", + "temporal_order": "DESC", + "properties": [ + { + "name": "timestamp", + "type": "INT64" + }, + { + "name": "ratio", + "type": "DOUBLE" + }, + { + "name": "comment", + "type": "STRING" + } + ] + }, + { + "label": "apply", + "type": "EDGE", + "temporal": "timestamp", + "temporal_order": "DESC", + "properties": [ + { + "name": "timestamp", + "type": "INT64" + }, + { + "name": "comment", + "type": "STRING" + }, + { + "name": "loanAmount", + "type": "DOUBLE" + }, + { + "name": "org", + "type": "STRING", + "optional": true + } + ] + }, + { + "label": "guarantee", + "type": "EDGE", + "temporal": "timestamp", + "temporal_order": "DESC", + "properties": [ + { + "name": "timestamp", + "type": "INT64" + }, + { + "name": "comment", + "type": "STRING" + }, + { + "name": "relation", + "type": "STRING", + "optional": true + } + ] + }, + { + "label": "own", + "type": "EDGE", + "properties": [ + { + "name": "comment", + "type": "STRING", + "optional": true + }, + { + "name": "timestamp", + "type": "INT64", + "optional": true + } + ] + }, + { + "label": "workIn", + "type": "EDGE", + "properties": [] + } + ], + "files": [ + { + "path": "Person.csv", + "header":1,"format": "CSV", + "label": "Person", + "columns": [ + "id", + "name", + "isBlocked", + "createTime", + "gender", + "birthday", + "country", + "city" + ] + }, + { + "path": "Account.csv", + "header":1,"format": "CSV", + "label": "Account", + "columns": [ + "id", + "createTime", + "isBlocked", + "type", + "nickname", + "phonenum", + "email", + "freqLoginType", + "lastLoginTime", + "accountLevel" + ] + }, + { + "path": "Medium.csv", + "header":1,"format": "CSV", + "label": "Medium", + "columns": [ + "id", + "type", + "isBlocked", + "createTime", + "lastLoginTime", + "riskLevel" + ] + }, + { + "path": "Loan.csv", + "header":1,"format": "CSV", + "label": "Loan", + "columns": [ + "id", + "loanAmount", + "balance", + "createTime", + "loanUsage", + "interestRate" + ] + }, + { + "path": "Company.csv", + "header":1,"format": "CSV", + "label": "Company", + "columns": [ + "id", + "name", + "isBlocked", + "createTime", + "country", + "city", + "business", + "description", + "url" + ] + }, + { + "path": "AccountTransferAccount.csv", + "header":1,"format": "CSV", + "label": "transfer", + "SRC_ID": "Account", + "DST_ID": "Account", + "columns": [ + "SRC_ID", + "DST_ID", + "amount", + "timestamp", + "orderNum", + "comment", + "payType", + "goodsType" + ] + }, + { + "path": "AccountWithdrawAccount.csv", + "header":1,"format": "CSV", + "label": "withdraw", + "SRC_ID": "Account", + "DST_ID": "Account", + "columns": [ + "SRC_ID", + "DST_ID", + "fromType", + "toType", + "amount", + "timestamp", + "comment" + ] + }, + { + "path": "AccountRepayLoan.csv", + "header":1,"format": "CSV", + "label": "repay", + "SRC_ID": "Account", + "DST_ID": "Loan", + "columns": [ + "SRC_ID", + "DST_ID", + "amount", + "timestamp", + "comment" + ] + }, + { + "path": "LoanDepositAccount.csv", + "header":1,"format": "CSV", + "label": "deposit", + "SRC_ID": "Loan", + "DST_ID": "Account", + "columns": [ + "SRC_ID", + "DST_ID", + "amount", + "timestamp", + "comment" + ] + }, + { + "path": "MediumSignInAccount.csv", + "header":1,"format": "CSV", + "label": "signIn", + "SRC_ID": "Medium", + "DST_ID": "Account", + "columns": [ + "SRC_ID", + "DST_ID", + "timestamp", + "location", + "comment" + ] + }, + { + "path": "PersonInvestCompany.csv", + "header":1,"format": "CSV", + "label": "invest", + "SRC_ID": "Person", + "DST_ID": "Company", + "columns": [ + "SRC_ID", + "DST_ID", + "ratio", + "timestamp", + "comment" + ] + }, + { + "path": "CompanyInvestCompany.csv", + "header":1,"format": "CSV", + "label": "invest", + "SRC_ID": "Company", + "DST_ID": "Company", + "columns": [ + "SRC_ID", + "DST_ID", + "ratio", + "timestamp", + "comment" + ] + }, + { + "path": "PersonApplyLoan.csv", + "header":1,"format": "CSV", + "label": "apply", + "SRC_ID": "Person", + "DST_ID": "Loan", + "columns": [ + "SRC_ID", + "DST_ID", + "loanAmount", + "timestamp", + "org", + "comment" + ] + }, + { + "path": "CompanyApplyLoan.csv", + "header":1,"format": "CSV", + "label": "apply", + "SRC_ID": "Company", + "DST_ID": "Loan", + "columns": [ + "SRC_ID", + "DST_ID", + "loanAmount", + "timestamp", + "org", + "comment" + ] + }, + { + "path": "PersonGuaranteePerson.csv", + "header":1,"format": "CSV", + "label": "guarantee", + "SRC_ID": "Person", + "DST_ID": "Person", + "columns": [ + "SRC_ID", + "DST_ID", + "timestamp", + "relation", + "comment" + ] + }, + { + "path": "CompanyGuaranteeCompany.csv", + "header":1,"format": "CSV", + "label": "guarantee", + "SRC_ID": "Company", + "DST_ID": "Company", + "columns": [ + "SRC_ID", + "DST_ID", + "timestamp", + "relation", + "comment" + ] + }, + { + "path": "CompanyOwnAccount.csv", + "header":1,"format": "CSV", + "label": "own", + "SRC_ID": "Company", + "DST_ID": "Account", + "columns": [ + "SRC_ID", + "DST_ID", + "timestamp", + "comment" + ] + }, + { + "path": "PersonOwnAccount.csv", + "header":1,"format": "CSV", + "label": "own", + "SRC_ID": "Person", + "DST_ID": "Account", + "columns": [ + "SRC_ID", + "DST_ID", + "timestamp", + "comment" + ] + } + ] +} diff --git a/misc/opt_recursive/scripts/load_procedure.sh b/misc/opt_recursive/scripts/load_procedure.sh new file mode 100644 index 0000000..df252dc --- /dev/null +++ b/misc/opt_recursive/scripts/load_procedure.sh @@ -0,0 +1,14 @@ +ENDPOINT="tugraph:7070" +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +PROCEDURES_DIR=/root/ldbc/ldbc_finbench_transaction_impls/tugraph/procedures/cpp + +cd $PROCEDURES_DIR + +for i in trw1 trw2 trw3; do + python3 install.py $ENDPOINT $i RW +done +for i in tcr8; do + python3 install.py $ENDPOINT $i RO +done + +cd $SCRIPT_DIR diff --git a/misc/opt_recursive/scripts/sf100_benchmark.sh b/misc/opt_recursive/scripts/sf100_benchmark.sh new file mode 100644 index 0000000..da48fa5 --- /dev/null +++ b/misc/opt_recursive/scripts/sf100_benchmark.sh @@ -0,0 +1,12 @@ +# validate on SF100 dataset + +cd /root/ldbc/ldbc_finbench_transaction_impls/tugraph/ + +if ! [ -f ./target/tugraph-0.1.0-alpha.jar ]; then + mvn clean package +fi + +cd data && ln -s /root/datasets/sf100 ./sf100 && cd .. +sed -i 's/172.21.189.228/tugraph/g' benchmark_sf100.properties + +bash run.sh benchmark_sf100.properties \ No newline at end of file diff --git a/misc/opt_recursive/scripts/sf100_import.sh b/misc/opt_recursive/scripts/sf100_import.sh new file mode 100644 index 0000000..a1b7b2c --- /dev/null +++ b/misc/opt_recursive/scripts/sf100_import.sh @@ -0,0 +1,8 @@ +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +# Import SF100 +cd /root/datasets/sf100/snapshot +lgraph_import -c ${SCRIPT_DIR}/import.conf --overwrite 1 \ + --dir /root/lgraph_db_sf100 --delimiter "|" --v3 0 + +cd $SCRIPT_DIR diff --git a/misc/opt_recursive/scripts/sf100_start.sh b/misc/opt_recursive/scripts/sf100_start.sh new file mode 100644 index 0000000..e69de29