repo
stringlengths 1
152
⌀ | file
stringlengths 15
205
| code
stringlengths 0
41.6M
| file_length
int64 0
41.6M
| avg_line_length
float64 0
1.81M
| max_line_length
int64 0
12.7M
| extension_type
stringclasses 90
values |
---|---|---|---|---|---|---|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/prepare-for-build.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# prepare-for-build.sh - is called inside a Docker container; prepares
# the environment inside a Docker container for
# running build of PMDK project.
#
set -e
# This should be run only on CIs
if [ "$CI_RUN" == "YES" ]; then
# Make sure $WORKDIR has correct access rights
# - set them to the current UID and GID
echo $USERPASS | sudo -S chown -R $(id -u).$(id -g) $WORKDIR
fi
# Configure tests (e.g. ssh for remote tests) unless the current configuration
# should be preserved
KEEP_TEST_CONFIG=${KEEP_TEST_CONFIG:-0}
if [[ "$KEEP_TEST_CONFIG" == 0 ]]; then
./configure-tests.sh
fi
| 739 | 27.461538 | 78 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/set-ci-vars.sh
|
#!/usr/bin/env bash
#
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2020, Intel Corporation
#
# set-ci-vars.sh -- set CI variables common for both:
# Travis and GitHub Actions CIs
#
set -e
function get_commit_range_from_last_merge {
# get commit id of the last merge
LAST_MERGE=$(git log --merges --pretty=%H -1)
LAST_COMMIT=$(git log --pretty=%H -1)
if [ "$LAST_MERGE" == "$LAST_COMMIT" ]; then
# GitHub Actions commits its own merge in case of pull requests
# so the first merge commit has to be skipped.
LAST_MERGE=$(git log --merges --pretty=%H -2 | tail -n1)
fi
if [ "$LAST_MERGE" == "" ]; then
# possible in case of shallow clones
# or new repos with no merge commits yet
# - pick up the first commit
LAST_MERGE=$(git log --pretty=%H | tail -n1)
fi
COMMIT_RANGE="$LAST_MERGE..HEAD"
# make sure it works now
if ! git rev-list $COMMIT_RANGE >/dev/null; then
COMMIT_RANGE=""
fi
echo $COMMIT_RANGE
}
COMMIT_RANGE_FROM_LAST_MERGE=$(get_commit_range_from_last_merge)
if [ -n "$TRAVIS" ]; then
CI_COMMIT=$TRAVIS_COMMIT
CI_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE/.../..}"
CI_BRANCH=$TRAVIS_BRANCH
CI_EVENT_TYPE=$TRAVIS_EVENT_TYPE
CI_REPO_SLUG=$TRAVIS_REPO_SLUG
# CI_COMMIT_RANGE is usually invalid for force pushes - fix it when used
# with non-upstream repository
if [ -n "$CI_COMMIT_RANGE" -a "$CI_REPO_SLUG" != "$GITHUB_REPO" ]; then
if ! git rev-list $CI_COMMIT_RANGE; then
CI_COMMIT_RANGE=$COMMIT_RANGE_FROM_LAST_MERGE
fi
fi
case "$TRAVIS_CPU_ARCH" in
"amd64")
CI_CPU_ARCH="x86_64"
;;
*)
CI_CPU_ARCH=$TRAVIS_CPU_ARCH
;;
esac
elif [ -n "$GITHUB_ACTIONS" ]; then
CI_COMMIT=$GITHUB_SHA
CI_COMMIT_RANGE=$COMMIT_RANGE_FROM_LAST_MERGE
CI_BRANCH=$(echo $GITHUB_REF | cut -d'/' -f3)
CI_REPO_SLUG=$GITHUB_REPOSITORY
CI_CPU_ARCH="x86_64" # GitHub Actions supports only x86_64
case "$GITHUB_EVENT_NAME" in
"schedule")
CI_EVENT_TYPE="cron"
;;
*)
CI_EVENT_TYPE=$GITHUB_EVENT_NAME
;;
esac
else
CI_COMMIT=$(git log --pretty=%H -1)
CI_COMMIT_RANGE=$COMMIT_RANGE_FROM_LAST_MERGE
CI_CPU_ARCH="x86_64"
fi
export CI_COMMIT=$CI_COMMIT
export CI_COMMIT_RANGE=$CI_COMMIT_RANGE
export CI_BRANCH=$CI_BRANCH
export CI_EVENT_TYPE=$CI_EVENT_TYPE
export CI_REPO_SLUG=$CI_REPO_SLUG
export CI_CPU_ARCH=$CI_CPU_ARCH
echo CI_COMMIT=$CI_COMMIT
echo CI_COMMIT_RANGE=$CI_COMMIT_RANGE
echo CI_BRANCH=$CI_BRANCH
echo CI_EVENT_TYPE=$CI_EVENT_TYPE
echo CI_REPO_SLUG=$CI_REPO_SLUG
echo CI_CPU_ARCH=$CI_CPU_ARCH
| 2,481 | 24.587629 | 73 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/build-CI.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# build-CI.sh - runs a Docker container from a Docker image with environment
# prepared for building PMDK project and starts building PMDK
#
# this script is used for building PMDK on Travis and GitHub Actions CIs
#
set -e
source $(dirname $0)/set-ci-vars.sh
source $(dirname $0)/set-vars.sh
source $(dirname $0)/valid-branches.sh
if [[ "$CI_EVENT_TYPE" != "cron" && "$CI_BRANCH" != "coverity_scan" \
&& "$COVERITY" -eq 1 ]]; then
echo "INFO: Skip Coverity scan job if build is triggered neither by " \
"'cron' nor by a push to 'coverity_scan' branch"
exit 0
fi
if [[ ( "$CI_EVENT_TYPE" == "cron" || "$CI_BRANCH" == "coverity_scan" )\
&& "$COVERITY" -ne 1 ]]; then
echo "INFO: Skip regular jobs if build is triggered either by 'cron'" \
" or by a push to 'coverity_scan' branch"
exit 0
fi
if [[ -z "$OS" || -z "$OS_VER" ]]; then
echo "ERROR: The variables OS and OS_VER have to be set properly " \
"(eg. OS=ubuntu, OS_VER=16.04)."
exit 1
fi
if [[ -z "$HOST_WORKDIR" ]]; then
echo "ERROR: The variable HOST_WORKDIR has to contain a path to " \
"the root of the PMDK project on the host machine"
exit 1
fi
if [[ -z "$TEST_BUILD" ]]; then
TEST_BUILD=all
fi
imageName=${DOCKERHUB_REPO}:1.9-${OS}-${OS_VER}-${CI_CPU_ARCH}
containerName=pmdk-${OS}-${OS_VER}
if [[ $MAKE_PKG -eq 0 ]] ; then command="./run-build.sh"; fi
if [[ $MAKE_PKG -eq 1 ]] ; then command="./run-build-package.sh"; fi
if [[ $COVERAGE -eq 1 ]] ; then command="./run-coverage.sh"; ci_env=`bash <(curl -s https://codecov.io/env)`; fi
if [[ ( "$CI_EVENT_TYPE" == "cron" || "$CI_BRANCH" == "coverity_scan" )\
&& "$COVERITY" -eq 1 ]]; then
command="./run-coverity.sh"
fi
if [ -n "$DNS_SERVER" ]; then DNS_SETTING=" --dns=$DNS_SERVER "; fi
if [[ -f $CI_FILE_SKIP_BUILD_PKG_CHECK ]]; then BUILD_PACKAGE_CHECK=n; else BUILD_PACKAGE_CHECK=y; fi
if [ -z "$NDCTL_ENABLE" ]; then ndctl_enable=; else ndctl_enable="--env NDCTL_ENABLE=$NDCTL_ENABLE"; fi
if [[ $UBSAN -eq 1 ]]; then for x in C CPP LD; do declare EXTRA_${x}FLAGS=-fsanitize=undefined; done; fi
# Only run doc update on $GITHUB_REPO master or stable branch
if [[ -z "${CI_BRANCH}" || -z "${TARGET_BRANCHES[${CI_BRANCH}]}" || "$CI_EVENT_TYPE" == "pull_request" || "$CI_REPO_SLUG" != "${GITHUB_REPO}" ]]; then
AUTO_DOC_UPDATE=0
fi
# Check if we are running on a CI (Travis or GitHub Actions)
[ -n "$GITHUB_ACTIONS" -o -n "$TRAVIS" ] && CI_RUN="YES" || CI_RUN="NO"
# We have a blacklist only for ppc64le arch
if [[ "$CI_CPU_ARCH" == ppc64le ]] ; then BLACKLIST_FILE=../../utils/docker/ppc64le.blacklist; fi
# docker on travis + ppc64le runs inside an LXD container and for security
# limits what can be done inside it, and as such, `docker run` fails with
# > the input device is not a TTY
# when using -t because of limited permissions to /dev imposed by LXD.
if [[ -n "$TRAVIS" && "$CI_CPU_ARCH" == ppc64le ]] || [[ -n "$GITHUB_ACTIONS" ]]; then
TTY=''
else
TTY='-t'
fi
WORKDIR=/pmdk
SCRIPTSDIR=$WORKDIR/utils/docker
# Run a container with
# - environment variables set (--env)
# - host directory containing PMDK source mounted (-v)
# - a tmpfs /tmp with the necessary size and permissions (--tmpfs)*
# - working directory set (-w)
#
# * We need a tmpfs /tmp inside docker but we cannot run it with --privileged
# and do it from inside, so we do using this docker-run option.
# By default --tmpfs add nosuid,nodev,noexec to the mount flags, we don't
# want that and just to make sure we add the usually default rw,relatime just
# in case docker change the defaults.
docker run --rm --name=$containerName -i $TTY \
$DNS_SETTING \
$ci_env \
--env http_proxy=$http_proxy \
--env https_proxy=$https_proxy \
--env AUTO_DOC_UPDATE=$AUTO_DOC_UPDATE \
--env CC=$PMDK_CC \
--env CXX=$PMDK_CXX \
--env VALGRIND=$VALGRIND \
--env EXTRA_CFLAGS=$EXTRA_CFLAGS \
--env EXTRA_CXXFLAGS=$EXTRA_CXXFLAGS \
--env EXTRA_LDFLAGS=$EXTRA_LDFLAGS \
--env REMOTE_TESTS=$REMOTE_TESTS \
--env TEST_BUILD=$TEST_BUILD \
--env WORKDIR=$WORKDIR \
--env EXPERIMENTAL=$EXPERIMENTAL \
--env BUILD_PACKAGE_CHECK=$BUILD_PACKAGE_CHECK \
--env SCRIPTSDIR=$SCRIPTSDIR \
--env TRAVIS=$TRAVIS \
--env CI_COMMIT_RANGE=$CI_COMMIT_RANGE \
--env CI_COMMIT=$CI_COMMIT \
--env CI_REPO_SLUG=$CI_REPO_SLUG \
--env CI_BRANCH=$CI_BRANCH \
--env CI_EVENT_TYPE=$CI_EVENT_TYPE \
--env DOC_UPDATE_GITHUB_TOKEN=$DOC_UPDATE_GITHUB_TOKEN \
--env COVERITY_SCAN_TOKEN=$COVERITY_SCAN_TOKEN \
--env COVERITY_SCAN_NOTIFICATION_EMAIL=$COVERITY_SCAN_NOTIFICATION_EMAIL \
--env FAULT_INJECTION=$FAULT_INJECTION \
--env GITHUB_ACTION=$GITHUB_ACTION \
--env GITHUB_HEAD_REF=$GITHUB_HEAD_REF \
--env GITHUB_REPO=$GITHUB_REPO \
--env GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
--env GITHUB_REF=$GITHUB_REF \
--env GITHUB_RUN_ID=$GITHUB_RUN_ID \
--env GITHUB_SHA=$GITHUB_SHA \
--env CI_RUN=$CI_RUN \
--env SRC_CHECKERS=$SRC_CHECKERS \
--env BLACKLIST_FILE=$BLACKLIST_FILE \
$ndctl_enable \
--tmpfs /tmp:rw,relatime,suid,dev,exec,size=6G \
-v $HOST_WORKDIR:$WORKDIR \
-v /etc/localtime:/etc/localtime \
-w $SCRIPTSDIR \
$imageName $command
| 5,193 | 35.069444 | 150 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/run-build-package.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2019, Intel Corporation
#
# run-build-package.sh - is called inside a Docker container; prepares
# the environment and starts a build of PMDK project.
#
set -e
# Prepare build enviromnent
./prepare-for-build.sh
# Create fake tag, so that package has proper 'version' field
git config user.email "[email protected]"
git config user.name "test package"
git tag -a 1.4.99 -m "1.4" HEAD~1 || true
# Build all and run tests
cd $WORKDIR
export PCHECK_OPTS="-j2 BLACKLIST_FILE=${BLACKLIST_FILE}"
make -j$(nproc) $PACKAGE_MANAGER
# Install packages
if [[ "$PACKAGE_MANAGER" == "dpkg" ]]; then
cd $PACKAGE_MANAGER
echo $USERPASS | sudo -S dpkg --install *.deb
else
RPM_ARCH=$(uname -m)
cd $PACKAGE_MANAGER/$RPM_ARCH
echo $USERPASS | sudo -S rpm --install *.rpm
fi
# Compile and run standalone test
cd $WORKDIR/utils/docker/test_package
make -j$(nproc) LIBPMEMOBJ_MIN_VERSION=1.4
./test_package testfile1
# Use pmreorder installed in the system
pmreorder_version="$(pmreorder -v)"
pmreorder_pattern="pmreorder\.py .+$"
(echo "$pmreorder_version" | grep -Ev "$pmreorder_pattern") && echo "pmreorder version failed" && exit 1
touch testfile2
touch logfile1
pmreorder -p testfile2 -l logfile1
| 1,293 | 25.958333 | 104 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/run-doc-update.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2019-2020, Intel Corporation
set -e
source `dirname $0`/valid-branches.sh
BOT_NAME="pmem-bot"
USER_NAME="pmem"
REPO_NAME="pmdk"
ORIGIN="https://${DOC_UPDATE_GITHUB_TOKEN}@github.com/${BOT_NAME}/${REPO_NAME}"
UPSTREAM="https://github.com/${USER_NAME}/${REPO_NAME}"
# master or stable-* branch
TARGET_BRANCH=${CI_BRANCH}
VERSION=${TARGET_BRANCHES[$TARGET_BRANCH]}
if [ -z $VERSION ]; then
echo "Target location for branch $TARGET_BRANCH is not defined."
exit 1
fi
# Clone bot repo
git clone ${ORIGIN}
cd ${REPO_NAME}
git remote add upstream ${UPSTREAM}
git config --local user.name ${BOT_NAME}
git config --local user.email "[email protected]"
git remote update
git checkout -B ${TARGET_BRANCH} upstream/${TARGET_BRANCH}
# Copy man & PR web md
cd ./doc
make -j$(nproc) web
cd ..
mv ./doc/web_linux ../
mv ./doc/web_windows ../
mv ./doc/generated/libs_map.yml ../
# Checkout gh-pages and copy docs
GH_PAGES_NAME="gh-pages-for-${TARGET_BRANCH}"
git checkout -B $GH_PAGES_NAME upstream/gh-pages
git clean -dfx
rsync -a ../web_linux/ ./manpages/linux/${VERSION}/
rsync -a ../web_windows/ ./manpages/windows/${VERSION}/ \
--exclude='librpmem' \
--exclude='rpmemd' --exclude='pmreorder' \
--exclude='daxio'
rm -r ../web_linux
rm -r ../web_windows
if [ $TARGET_BRANCH = "master" ]; then
[ ! -d _data ] && mkdir _data
cp ../libs_map.yml _data
fi
# Add and push changes.
# git commit command may fail if there is nothing to commit.
# In that case we want to force push anyway (there might be open pull request
# with changes which were reverted).
git add -A
git commit -m "doc: automatic gh-pages docs update" && true
git push -f ${ORIGIN} $GH_PAGES_NAME
GITHUB_TOKEN=${DOC_UPDATE_GITHUB_TOKEN} hub pull-request -f \
-b ${USER_NAME}:gh-pages \
-h ${BOT_NAME}:${GH_PAGES_NAME} \
-m "doc: automatic gh-pages docs update" && true
exit 0
| 1,924 | 24 | 79 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/pull-or-rebuild-image.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# pull-or-rebuild-image.sh - rebuilds the Docker image used in the
# current Travis build if necessary.
#
# The script rebuilds the Docker image if the Dockerfile for the current
# OS version (Dockerfile.${OS}-${OS_VER}) or any .sh script from the directory
# with Dockerfiles were modified and committed.
#
# If the Travis build is not of the "pull_request" type (i.e. in case of
# merge after pull_request) and it succeed, the Docker image should be pushed
# to the Docker Hub repository. An empty file is created to signal that to
# further scripts.
#
# If the Docker image does not have to be rebuilt, it will be pulled from
# Docker Hub.
#
set -e
source $(dirname $0)/set-ci-vars.sh
source $(dirname $0)/set-vars.sh
if [[ "$CI_EVENT_TYPE" != "cron" && "$CI_BRANCH" != "coverity_scan" \
&& "$COVERITY" -eq 1 ]]; then
echo "INFO: Skip Coverity scan job if build is triggered neither by " \
"'cron' nor by a push to 'coverity_scan' branch"
exit 0
fi
if [[ ( "$CI_EVENT_TYPE" == "cron" || "$CI_BRANCH" == "coverity_scan" )\
&& "$COVERITY" -ne 1 ]]; then
echo "INFO: Skip regular jobs if build is triggered either by 'cron'" \
" or by a push to 'coverity_scan' branch"
exit 0
fi
if [[ -z "$OS" || -z "$OS_VER" ]]; then
echo "ERROR: The variables OS and OS_VER have to be set properly " \
"(eg. OS=ubuntu, OS_VER=16.04)."
exit 1
fi
if [[ -z "$HOST_WORKDIR" ]]; then
echo "ERROR: The variable HOST_WORKDIR has to contain a path to " \
"the root of the PMDK project on the host machine"
exit 1
fi
# Find all the commits for the current build
if [ -n "$CI_COMMIT_RANGE" ]; then
commits=$(git rev-list $CI_COMMIT_RANGE)
else
commits=$CI_COMMIT
fi
echo "Commits in the commit range:"
for commit in $commits; do echo $commit; done
# Get the list of files modified by the commits
files=$(for commit in $commits; do git diff-tree --no-commit-id --name-only \
-r $commit; done | sort -u)
echo "Files modified within the commit range:"
for file in $files; do echo $file; done
# Path to directory with Dockerfiles and image building scripts
images_dir_name=images
base_dir=utils/docker/$images_dir_name
# Check if committed file modifications require the Docker image to be rebuilt
for file in $files; do
# Check if modified files are relevant to the current build
if [[ $file =~ ^($base_dir)\/Dockerfile\.($OS)-($OS_VER)$ ]] \
|| [[ $file =~ ^($base_dir)\/.*\.sh$ ]]
then
# Rebuild Docker image for the current OS version
echo "Rebuilding the Docker image for the Dockerfile.$OS-$OS_VER"
pushd $images_dir_name
./build-image.sh ${OS}-${OS_VER} ${CI_CPU_ARCH}
popd
# Check if the image has to be pushed to Docker Hub
# (i.e. the build is triggered by commits to the $GITHUB_REPO
# repository's stable-* or master branch, and the Travis build is not
# of the "pull_request" type). In that case, create the empty
# file.
if [[ "$CI_REPO_SLUG" == "$GITHUB_REPO" \
&& ($CI_BRANCH == stable-* || $CI_BRANCH == devel-* || $CI_BRANCH == master) \
&& $CI_EVENT_TYPE != "pull_request" \
&& $PUSH_IMAGE == "1" ]]
then
echo "The image will be pushed to Docker Hub"
touch $CI_FILE_PUSH_IMAGE_TO_REPO
else
echo "Skip pushing the image to Docker Hub"
fi
if [[ $PUSH_IMAGE == "1" ]]
then
echo "Skip build package check if image has to be pushed"
touch $CI_FILE_SKIP_BUILD_PKG_CHECK
fi
exit 0
fi
done
# Getting here means rebuilding the Docker image is not required.
# Pull the image from Docker Hub.
docker pull ${DOCKERHUB_REPO}:1.9-${OS}-${OS_VER}-${CI_CPU_ARCH}
| 3,681 | 31.584071 | 81 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/valid-branches.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018-2020, Intel Corporation
declare -A TARGET_BRANCHES=( \
["master"]="master" \
["stable-1.5"]="v1.5" \
["stable-1.6"]="v1.6" \
["stable-1.7"]="v1.7" \
["stable-1.8"]="v1.8" \
["stable-1.9"]="v1.9" \
)
| 291 | 21.461538 | 40 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/configure-tests.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# configure-tests.sh - is called inside a Docker container; configures tests
# and ssh server for use during build of PMDK project.
#
set -e
# Configure tests
cat << EOF > $WORKDIR/src/test/testconfig.sh
LONGDIR=LoremipsumdolorsitametconsecteturadipiscingelitVivamuslacinianibhattortordictumsollicitudinNullamvariusvestibulumligulaetegestaselitsemperidMaurisultriciesligulaeuipsumtinciduntluctusMorbimaximusvariusdolorid
# this path is ~3000 characters long
DIRSUFFIX="$LONGDIR/$LONGDIR/$LONGDIR/$LONGDIR/$LONGDIR"
NON_PMEM_FS_DIR=/tmp
PMEM_FS_DIR=/tmp
PMEM_FS_DIR_FORCE_PMEM=1
TEST_BUILD="debug nondebug"
ENABLE_SUDO_TESTS=y
TM=1
EOF
# Configure remote tests
if [[ $REMOTE_TESTS -eq 1 ]]; then
echo "Configuring remote tests"
cat << EOF >> $WORKDIR/src/test/testconfig.sh
NODE[0]=127.0.0.1
NODE_WORKING_DIR[0]=/tmp/node0
NODE_ADDR[0]=127.0.0.1
NODE_ENV[0]="PMEM_IS_PMEM_FORCE=1"
NODE[1]=127.0.0.1
NODE_WORKING_DIR[1]=/tmp/node1
NODE_ADDR[1]=127.0.0.1
NODE_ENV[1]="PMEM_IS_PMEM_FORCE=1"
NODE[2]=127.0.0.1
NODE_WORKING_DIR[2]=/tmp/node2
NODE_ADDR[2]=127.0.0.1
NODE_ENV[2]="PMEM_IS_PMEM_FORCE=1"
NODE[3]=127.0.0.1
NODE_WORKING_DIR[3]=/tmp/node3
NODE_ADDR[3]=127.0.0.1
NODE_ENV[3]="PMEM_IS_PMEM_FORCE=1"
TEST_BUILD="debug nondebug"
TEST_PROVIDERS=sockets
EOF
mkdir -p ~/.ssh/cm
cat << EOF >> ~/.ssh/config
Host 127.0.0.1
StrictHostKeyChecking no
ControlPath ~/.ssh/cm/%r@%h:%p
ControlMaster auto
ControlPersist 10m
EOF
if [ ! -f /etc/ssh/ssh_host_rsa_key ]
then
(echo $USERPASS | sudo -S ssh-keygen -t rsa -C $USER@$HOSTNAME -P '' -f /etc/ssh/ssh_host_rsa_key)
fi
echo $USERPASS | sudo -S sh -c 'cat /etc/ssh/ssh_host_rsa_key.pub >> /etc/ssh/authorized_keys'
ssh-keygen -t rsa -C $USER@$HOSTNAME -P '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod -R 700 ~/.ssh
chmod 640 ~/.ssh/authorized_keys
chmod 600 ~/.ssh/config
# Start ssh service
echo $USERPASS | sudo -S $START_SSH_COMMAND
ssh 127.0.0.1 exit 0
else
echo "Skipping remote tests"
echo
echo "Removing all libfabric.pc files in order to simulate that libfabric is not installed:"
find /usr -name "libfabric.pc" 2>/dev/null || true
echo $USERPASS | sudo -S sh -c 'find /usr -name "libfabric.pc" -exec rm -f {} + 2>/dev/null'
fi
# Configure python tests
cat << EOF >> $WORKDIR/src/test/testconfig.py
config = {
'unittest_log_level': 1,
'cacheline_fs_dir': '/tmp',
'force_cacheline': True,
'page_fs_dir': '/tmp',
'force_page': False,
'byte_fs_dir': '/tmp',
'force_byte': True,
'tm': True,
'test_type': 'check',
'granularity': 'all',
'fs_dir_force_pmem': 0,
'keep_going': False,
'timeout': '3m',
'build': ['debug', 'release'],
'force_enable': None,
'device_dax_path': [],
'fail_on_skip': False,
'enable_admin_tests': True
}
EOF
| 2,886 | 26.235849 | 216 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/set-vars.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2019, Intel Corporation
#
# set-vars.sh - set required environment variables
#
set -e
export CI_FILE_PUSH_IMAGE_TO_REPO=/tmp/push_image_to_repo_flag
export CI_FILE_SKIP_BUILD_PKG_CHECK=/tmp/skip_build_package_check
| 290 | 21.384615 | 65 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/run-coverity.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2020, Intel Corporation
#
# run-coverity.sh - runs the Coverity scan build
#
set -e
if [[ "$CI_REPO_SLUG" != "$GITHUB_REPO" \
&& ( "$COVERITY_SCAN_NOTIFICATION_EMAIL" == "" \
|| "$COVERITY_SCAN_TOKEN" == "" ) ]]; then
echo
echo "Skipping Coverity build:"\
"COVERITY_SCAN_TOKEN=\"$COVERITY_SCAN_TOKEN\" or"\
"COVERITY_SCAN_NOTIFICATION_EMAIL="\
"\"$COVERITY_SCAN_NOTIFICATION_EMAIL\" is not set"
exit 0
fi
# Prepare build environment
./prepare-for-build.sh
CERT_FILE=/etc/ssl/certs/ca-certificates.crt
TEMP_CF=$(mktemp)
cp $CERT_FILE $TEMP_CF
# Download Coverity certificate
echo -n | openssl s_client -connect scan.coverity.com:443 | \
sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | \
tee -a $TEMP_CF
echo $USERPASS | sudo -S mv $TEMP_CF $CERT_FILE
export COVERITY_SCAN_PROJECT_NAME="$CI_REPO_SLUG"
[[ "$CI_EVENT_TYPE" == "cron" ]] \
&& export COVERITY_SCAN_BRANCH_PATTERN="master" \
|| export COVERITY_SCAN_BRANCH_PATTERN="coverity_scan"
export COVERITY_SCAN_BUILD_COMMAND="make -j$(nproc) all"
cd $WORKDIR
#
# Run the Coverity scan
#
# The 'travisci_build_coverity_scan.sh' script requires the following
# environment variables to be set:
# - TRAVIS_BRANCH - has to contain the name of the current branch
# - TRAVIS_PULL_REQUEST - has to be set to 'true' in case of pull requests
#
export TRAVIS_BRANCH=${CI_BRANCH}
[ "${CI_EVENT_TYPE}" == "pull_request" ] && export TRAVIS_PULL_REQUEST="true"
# XXX: Patch the Coverity script.
# Recently, this script regularly exits with an error, even though
# the build is successfully submitted. Probably because the status code
# is missing in response, or it's not 201.
# Changes:
# 1) change the expected status code to 200 and
# 2) print the full response string.
#
# This change should be reverted when the Coverity script is fixed.
#
# The previous version was:
# curl -s https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh | bash
wget https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh
patch < utils/docker/0001-travis-fix-travisci_build_coverity_scan.sh.patch
bash ./travisci_build_coverity_scan.sh
| 2,196 | 29.513889 | 82 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/run-coverage.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2019, Intel Corporation
#
# run-coverage.sh - is called inside a Docker container; runs the coverage
# test
#
set -e
# Get and prepare PMDK source
./prepare-for-build.sh
# Hush error messages, mainly from Valgrind
export UT_DUMP_LINES=0
# Skip printing mismatched files for tests with Valgrind
export UT_VALGRIND_SKIP_PRINT_MISMATCHED=1
# Build all and run tests
cd $WORKDIR
make -j$(nproc) COVERAGE=1
make -j$(nproc) test COVERAGE=1
# XXX: unfortunately valgrind raports issues in coverage instrumentation
# which we have to ignore (-k flag), also there is dependency between
# local and remote tests (which cannot be easily removed) we have to
# run local and remote tests separately
cd src/test
# do not change -j2 to -j$(nproc) in case of tests (make check/pycheck)
make -kj2 pcheck-local-quiet TEST_BUILD=debug || true
make check-remote-quiet TEST_BUILD=debug || true
# do not change -j2 to -j$(nproc) in case of tests (make check/pycheck)
make -j2 pycheck TEST_BUILD=debug || true
cd ../..
bash <(curl -s https://codecov.io/bash)
| 1,138 | 28.973684 | 74 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/images/install-valgrind.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# install-valgrind.sh - installs valgrind for persistent memory
#
set -e
OS=$1
install_upstream_from_distro() {
case "$OS" in
fedora) dnf install -y valgrind ;;
ubuntu) apt-get install -y --no-install-recommends valgrind ;;
*) return 1 ;;
esac
}
install_upstream_3_16_1() {
git clone git://sourceware.org/git/valgrind.git
cd valgrind
# valgrind v3.16.1 upstream
git checkout VALGRIND_3_16_BRANCH
./autogen.sh
./configure
make -j$(nproc)
make -j$(nproc) install
cd ..
rm -rf valgrind
}
install_custom-pmem_from_source() {
git clone https://github.com/pmem/valgrind.git
cd valgrind
# valgrind v3.15 with pmemcheck
# 2020.04.01 Merge pull request #78 from marcinslusarz/opt3
git checkout 759686fd66cc0105df8311cfe676b0b2f9e89196
./autogen.sh
./configure
make -j$(nproc)
make -j$(nproc) install
cd ..
rm -rf valgrind
}
ARCH=$(uname -m)
case "$ARCH" in
ppc64le) install_upstream_3_16_1 ;;
*) install_custom-pmem_from_source ;;
esac
| 1,099 | 19.754717 | 66 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/images/build-image.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# build-image.sh <OS-VER> <ARCH> - prepares a Docker image with <OS>-based
# environment intended for the <ARCH> CPU architecture
# designed for building PMDK project, according to
# the Dockerfile.<OS-VER> file located in the same directory.
#
# The script can be run locally.
#
set -e
OS_VER=$1
CPU_ARCH=$2
function usage {
echo "Usage:"
echo " build-image.sh <OS-VER> <ARCH>"
echo "where:"
echo " <OS-VER> - can be for example 'ubuntu-19.10' provided "\
"a Dockerfile named 'Dockerfile.ubuntu-19.10' "\
"exists in the current directory and"
echo " <ARCH> - is a CPU architecture, for example 'x86_64'"
}
# Check if two first arguments are not empty
if [[ -z "$2" ]]; then
usage
exit 1
fi
# Check if the file Dockerfile.OS-VER exists
if [[ ! -f "Dockerfile.$OS_VER" ]]; then
echo "Error: Dockerfile.$OS_VER does not exist."
echo
usage
exit 1
fi
if [[ -z "${DOCKERHUB_REPO}" ]]; then
echo "Error: DOCKERHUB_REPO environment variable is not set"
exit 1
fi
# Build a Docker image tagged with ${DOCKERHUB_REPO}:OS-VER-ARCH
tag=${DOCKERHUB_REPO}:1.9-${OS_VER}-${CPU_ARCH}
docker build -t $tag \
--build-arg http_proxy=$http_proxy \
--build-arg https_proxy=$https_proxy \
-f Dockerfile.$OS_VER .
| 1,373 | 24.444444 | 76 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/images/install-libfabric.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# install-libfabric.sh - installs a customized version of libfabric
#
set -e
OS=$1
# Keep in sync with requirements in src/common.inc.
libfabric_ver=1.4.2
libfabric_url=https://github.com/ofiwg/libfabric/archive
libfabric_dir=libfabric-$libfabric_ver
libfabric_tarball=v${libfabric_ver}.zip
wget "${libfabric_url}/${libfabric_tarball}"
unzip $libfabric_tarball
cd $libfabric_dir
# XXX HACK HACK HACK
# Disable use of spin locks in libfabric.
#
# spinlocks do not play well (IOW at all) with cpu-constrained environments,
# like GitHub Actions, and this leads to timeouts of some PMDK's tests.
# This change speeds up pmempool_sync_remote/TEST28-31 by a factor of 20-30.
#
perl -pi -e 's/have_spinlock=1/have_spinlock=0/' configure.ac
# XXX HACK HACK HACK
./autogen.sh
./configure --prefix=/usr --enable-sockets
make -j$(nproc)
make -j$(nproc) install
cd ..
rm -f ${libfabric_tarball}
rm -rf ${libfabric_dir}
| 1,019 | 23.878049 | 76 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/images/install-libndctl.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2019, Intel Corporation
#
# install-libndctl.sh - installs libndctl
#
set -e
OS=$2
echo "==== clone ndctl repo ===="
git clone https://github.com/pmem/ndctl.git
cd ndctl
git checkout $1
if [ "$OS" = "fedora" ]; then
echo "==== setup rpmbuild tree ===="
rpmdev-setuptree
RPMDIR=$HOME/rpmbuild/
VERSION=$(./git-version)
SPEC=./rhel/ndctl.spec
echo "==== create source tarball ====="
git archive --format=tar --prefix="ndctl-${VERSION}/" HEAD | gzip > "$RPMDIR/SOURCES/ndctl-${VERSION}.tar.gz"
echo "==== build ndctl ===="
./autogen.sh
./configure --disable-docs
make -j$(nproc)
echo "==== build ndctl packages ===="
rpmbuild -ba $SPEC
echo "==== install ndctl packages ===="
RPM_ARCH=$(uname -m)
rpm -i $RPMDIR/RPMS/$RPM_ARCH/*.rpm
echo "==== cleanup ===="
rm -rf $RPMDIR
else
echo "==== build ndctl ===="
./autogen.sh
./configure --disable-docs
make -j$(nproc)
echo "==== install ndctl ===="
make -j$(nproc) install
echo "==== cleanup ===="
fi
cd ..
rm -rf ndctl
| 1,057 | 16.344262 | 109 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/pmdk-sd/utils/docker/images/push-image.sh
|
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# push-image.sh - pushes the Docker image to the Docker Hub.
#
# The script utilizes $DOCKERHUB_USER and $DOCKERHUB_PASSWORD variables
# to log in to Docker Hub. The variables can be set in the Travis project's
# configuration for automated builds.
#
set -e
source $(dirname $0)/../set-ci-vars.sh
if [[ -z "$OS" ]]; then
echo "OS environment variable is not set"
exit 1
fi
if [[ -z "$OS_VER" ]]; then
echo "OS_VER environment variable is not set"
exit 1
fi
if [[ -z "$CI_CPU_ARCH" ]]; then
echo "CI_CPU_ARCH environment variable is not set"
exit 1
fi
if [[ -z "${DOCKERHUB_REPO}" ]]; then
echo "DOCKERHUB_REPO environment variable is not set"
exit 1
fi
TAG="1.9-${OS}-${OS_VER}-${CI_CPU_ARCH}"
# Check if the image tagged with pmdk/OS-VER exists locally
if [[ ! $(docker images -a | awk -v pattern="^${DOCKERHUB_REPO}:${TAG}\$" \
'$1":"$2 ~ pattern') ]]
then
echo "ERROR: Docker image tagged ${DOCKERHUB_REPO}:${TAG} does not exists locally."
exit 1
fi
# Log in to the Docker Hub
docker login -u="$DOCKERHUB_USER" -p="$DOCKERHUB_PASSWORD"
# Push the image to the repository
docker push ${DOCKERHUB_REPO}:${TAG}
| 1,236 | 22.788462 | 84 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/include/txopt.cc
|
#include "txopt.h"
#include <string.h>
// source: http://stackoverflow.com/questions/1919183/how-to-allocate-and-free-aligned-memory-in-c
void *
aligned_malloc(int size) {
void *mem = malloc(size+64+sizeof(void*));
void **ptr = (void**)((uintptr_t)((uint64_t)mem+64+uint64_t(sizeof(void*))) & ~(64-1));
ptr[-1] = mem;
return ptr;
}
// source: http://stackoverflow.com/questions/1640258/need-a-fast-random-generator-for-c
static unsigned long x=123456789, y=362436069, z=521288629;
unsigned long xorshf96() { //period 2^96-1
unsigned long t;
x ^= x << 16;
x ^= x >> 5;
x ^= x << 1;
t = x;
x = y;
y = z;
z = t ^ x ^ y;
return z;
}
//volatile void s_fence();
// Flush the selected addresses
//volatile void metadata_cache_flush(uint64_t addr, unsigned size);
//volatile void cache_flush(uint64_t addr, unsigned size);
//volatile void flush_caches(uint64_t addr, unsigned size);
// Flush the one cacheline
//volatile inline void metadata_flush(uint64_t addr);
//volatile inline void cache_flush(uint64_t addr);
// Flush the whole caches
//volatile inline void metadata_flush();
//volatile inline void cache_flush();
//volatile void TX_OPT(uint64_t addr, unsigned size);
// Deduplication and Compression are transaparent
/*
class Dedup {
public:
};
class Compress {
public:
}
*/
uint64_t CounterAtomic::currAtomicAddr = COUNTER_ATOMIC_VADDR;
//uint64_t CounterAtomic::currCacheFlushAddr = CACHE_FLUSH_VADDR;
//uint64_t CounterAtomic::currCounterCacheFlushAddr = COUNTER_CACHE_FLUSH_VADDR;
void*
CounterAtomic::counter_atomic_malloc(unsigned _size) {
return (void*)getNextAtomicAddr(_size);
}
volatile void
metadata_cache_flush(void* addr, unsigned size) {
int num_cache_line = size / CACHE_LINE_SIZE;
if ((uint64_t)addr % CACHE_LINE_SIZE)
num_cache_line++;
for (int i = 0; i < num_cache_line; ++i)
*((volatile uint64_t*)METADATA_CACHE_FLUSH_VADDR) = (uint64_t)addr + i * CACHE_LINE_SIZE;
}
volatile void
cache_flush(void* addr, unsigned size) {
int num_cache_line = size / CACHE_LINE_SIZE;
if ((uint64_t)addr % CACHE_LINE_SIZE)
num_cache_line++;
for (int i = 0; i < num_cache_line; ++i)
*((volatile uint64_t*)CACHE_FLUSH_VADDR) = (uint64_t)addr + i * CACHE_LINE_SIZE;
}
volatile void
flush_caches(void* addr, unsigned size) {
cache_flush(addr, size);
metadata_cache_flush(addr, size);
}
// OPT with both data and addr ready
volatile void
OPT(void* opt_obj, bool reg, void* pmemaddr, void* data, unsigned size) {
// fprintf(stderr, "size: %u\n", size);
opt_packet_t opt_packet;
opt_packet.opt_obj = opt_obj;
//opt_packet.seg_id = i;
//opt_packet.pmemaddr = (void*)((uint64_t)(pmemaddr) + i * CACHE_LINE_SIZE);
opt_packet.pmemaddr = pmemaddr;
//opt_packet.data_ptr = (void*)((uint64_t)(data) + i * CACHE_LINE_SIZE);
//opt_packet.data_val = 0;
opt_packet.size = size;
opt_packet.type = (!reg ? FLAG_OPT : FLAG_OPT_REG);
//opt_packet.type = FLAG_OPT;
*((opt_packet_t*)TXOPT_VADDR) = opt_packet;
//*((opt_packet_t*)TXOPT_VADDR) = (opt_packet_t){opt_obj, pmemaddr, size, FLAG_OPT_DATA};
}
// OPT with both data (int) and addr ready
volatile void
OPT_VAL(void* opt_obj, bool reg, void* pmemaddr, int data_val) {
opt_packet_t opt_packet;
opt_packet.opt_obj = opt_obj;
opt_packet.pmemaddr = pmemaddr;
//opt_packet.data_ptr = 0;
//opt_packet.data_val = data_val;
opt_packet.size = sizeof(int);
opt_packet.type = (!reg ? FLAG_OPT_VAL : FLAG_OPT_VAL_REG);
//opt_packet.type = FLAG_OPT;
*((opt_packet_t*)TXOPT_VADDR) = opt_packet;
}
// OPT with only data ready
volatile void
OPT_DATA(void* opt_obj, bool reg, void* data, unsigned size) {
opt_packet_t opt_packet;
opt_packet.opt_obj = opt_obj;
opt_packet.pmemaddr = 0;
//opt_packet.data_ptr = (void*)((uint64_t)(data) + i * CACHE_LINE_SIZE);
//opt_packet.data_val = 0;
opt_packet.size = size;
opt_packet.type = (!reg ? FLAG_OPT_DATA : FLAG_OPT_DATA_REG);
//opt_packet.type = FLAG_OPT;
*((opt_packet_t*)TXOPT_VADDR) = opt_packet;
}
// OPT with only addr ready
volatile void
OPT_ADDR(void* opt_obj, bool reg, void* pmemaddr, unsigned size) {
opt_packet_t opt_packet;
opt_packet.opt_obj = opt_obj;
opt_packet.pmemaddr = pmemaddr;
//opt_packet.data_ptr = 0;
//opt_packet.data_val = 0;
opt_packet.size = size;
opt_packet.type = (!reg ? FLAG_OPT_ADDR : FLAG_OPT_ADDR_REG);
//opt_packet.type = FLAG_OPT;
*((opt_packet_t*)TXOPT_VADDR) = opt_packet;
}
// OPT with only data (int) ready
volatile void
OPT_DATA_VAL(void* opt_obj, bool reg, int data_val) {
opt_packet_t opt_packet;
opt_packet.opt_obj = opt_obj;
opt_packet.pmemaddr = 0;
//opt_packet.data_ptr = 0;
//opt_packet.data_val = data_val;
opt_packet.size = sizeof(int);
opt_packet.type = (!reg ? FLAG_OPT_DATA_VAL : FLAG_OPT_DATA_VAL_REG);
//opt_packet.type = FLAG_OPT;
*((opt_packet_t*)TXOPT_VADDR) = opt_packet;
}
volatile void
OPT_START(void* opt_obj) {
opt_packet_t opt_packet;
opt_packet.opt_obj = opt_obj;
opt_packet.type = FLAG_OPT_START;
}
volatile void
s_fence() {
std::atomic_thread_fence(std::memory_order_acq_rel);
}
CounterAtomic::CounterAtomic() {
val_addr = getNextAtomicAddr(CACHE_LINE_SIZE);
}
CounterAtomic::CounterAtomic(uint64_t _val) {
val_addr = getNextAtomicAddr(CACHE_LINE_SIZE);
*((volatile uint64_t*)val_addr) = _val;
}
CounterAtomic::CounterAtomic(bool _val) {
*((volatile uint64_t*)val_addr) = uint64_t(_val);
val_addr = getNextAtomicAddr(CACHE_LINE_SIZE);
}
uint64_t
CounterAtomic::getValue() {
return *((volatile uint64_t*)val_addr);
}
uint64_t
CounterAtomic::getPtr() {
return val_addr;
}
CounterAtomic&
CounterAtomic::operator=(uint64_t _val) {
*((volatile uint64_t*)val_addr) = _val;
return *this;
}
CounterAtomic&
CounterAtomic::operator+(uint64_t _val) {
*((volatile uint64_t*)val_addr) += _val;
return *this;
}
CounterAtomic&
CounterAtomic::operator++() {
uint64_t val = *((volatile uint64_t*)val_addr);
val++;
*((volatile uint64_t*)val_addr) = val;
return *this;
}
CounterAtomic&
CounterAtomic::operator--() {
uint64_t val = *((volatile uint64_t*)val_addr);
val--;
*((volatile uint64_t*)val_addr) = val;
return *this;
}
CounterAtomic&
CounterAtomic::operator-(uint64_t _val) {
*((volatile uint64_t*)val_addr) -= _val;
return *this;
}
bool
CounterAtomic::operator==(uint64_t _val) {
return *((volatile uint64_t*)val_addr) == _val;
}
bool
CounterAtomic::operator!=(uint64_t _val) {
return *((volatile uint64_t*)val_addr) != _val;
}
uint64_t
CounterAtomic::getNextAtomicAddr(unsigned _size) {
if (currAtomicAddr + _size >= COUNTER_ATOMIC_VADDR + NUM_COUNTER_ATOMIC_PAGE*4*1024) {
printf("@@not enough counter atomic space, current addr=%lu, size=%u\n", currAtomicAddr, _size);
exit(0);
}
currAtomicAddr += _size;
return (currAtomicAddr - _size);
}
volatile void
CounterAtomic::statOutput() {
*((volatile uint64_t*) (STATUS_OUTPUT_VADDR))= 0;
}
volatile void
CounterAtomic::initCounterCache() {
*((volatile uint64_t*) (INIT_METADATA_CACHE_VADDR))= 0;
}
| 6,969 | 24.345455 | 98 |
cc
|
null |
NearPMSW-main/nearpmMDsync/shadow/include/txopt.h
|
// The starting address of the selected counter_atomic writes
#ifndef TXOPT_H
#define TXOPT_H
#define COUNTER_ATOMIC_VADDR (4096UL*1024*1024)
#define NUM_COUNTER_ATOMIC_PAGE 262144
// The starting address of the flush cache instruction
#define CACHE_FLUSH_VADDR (4096UL*1024*1024+4*NUM_COUNTER_ATOMIC_PAGE*1024)
// The starting address of the flush metadata cache instruction
#define METADATA_CACHE_FLUSH_VADDR (4096UL*1024*1024+(4*NUM_COUNTER_ATOMIC_PAGE+4)*1024)
#define STATUS_OUTPUT_VADDR (METADATA_CACHE_FLUSH_VADDR + 1024UL)
#define INIT_METADATA_CACHE_VADDR (STATUS_OUTPUT_VADDR + 1024UL)
#define TXOPT_VADDR (INIT_METADATA_CACHE_VADDR+1024UL)
#define CACHE_LINE_SIZE 64UL
#include <vector>
#include <deque>
#include <cstdlib>
#include <cstdint>
#include <atomic>
#include <stdio.h>
#include <cassert>
enum opt_flag {
FLAG_OPT,
FLAG_OPT_VAL,
FLAG_OPT_ADDR,
FLAG_OPT_DATA,
FLAG_OPT_DATA_VAL,
/* register no execute */
FLAG_OPT_REG,
FLAG_OPT_VAL_REG,
FLAG_OPT_ADDR_REG,
FLAG_OPT_DATA_REG,
FLAG_OPT_DATA_VAL_REG,
/* execute registered OPT */
FLAG_OPT_START
};
struct opt_t {
//int pid;
int obj_id;
};
// Fields in the OPT packet
// Used by both SW and HW
struct opt_packet_t {
void* opt_obj;
void* pmemaddr;
//void* data_ptr;
//int seg_id;
//int data_val;
unsigned size;
opt_flag type;
};
// OPT with both data and addr ready
volatile void OPT(void* opt_obj, bool reg, void* pmemaddr, void* data, unsigned size);
//#define OPT(opt_obj, pmemaddr, data, size) \
// *((opt_packet_t*)TXOPT_VADDR) = (opt_packet_t){opt_obj, pmemaddr, size, FLAG_OPT_DATA};
// OPT with both data (int) and addr ready
volatile void OPT_VAL(void* opt_obj, bool reg, void* pmemaddr, int data_val);
// OPT with only data ready
volatile void OPT_DATA(void* opt_obj, bool reg, void* data, unsigned size);
// OPT with only addr ready
volatile void OPT_ADDR(void* opt_obj, bool reg, void* pmemaddr, unsigned size);
// OPT with only data (int) ready
volatile void OPT_DATA_VAL(void* opt_obj, bool reg, int data_val);
// Begin OPT operation
volatile void OPT_START(void* opt_obj);
// store barrier
volatile void s_fence();
// flush both metadata cache and data cache
volatile void flush_caches(void* addr, unsigned size);
// flush data cache only
volatile void cache_flush(void* addr, unsigned size);
// flush metadata cache only
volatile void metadata_cache_flush(void* addr, unsigned size);
// malloc that is cache-line aligned
void *aligned_malloc(int size);
class CounterAtomic {
public:
static void* counter_atomic_malloc(unsigned _size);
// size is num of bytes
static volatile void statOutput();
static volatile void initCounterCache();
uint64_t getValue();
uint64_t getPtr();
CounterAtomic();
CounterAtomic(uint64_t _val);
CounterAtomic(bool _val);
CounterAtomic& operator=(uint64_t _val);
CounterAtomic& operator+(uint64_t _val);
CounterAtomic& operator++();
CounterAtomic& operator--();
CounterAtomic& operator-(uint64_t _val);
bool operator==(uint64_t _val);
bool operator!=(uint64_t _val);
private:
void init();
static uint64_t getNextAtomicAddr(unsigned _size);
static uint64_t getNextCacheFlushAddr(unsigned _size);
//static uint64_t getNextPersistBarrierAddr(unsigned _size);
static uint64_t getNextCounterCacheFlushAddr(unsigned _size);
static uint64_t currAtomicAddr;
static uint64_t currCacheFlushAddr;
//static uint64_t currPersistentBarrierAddr;
static uint64_t currCounterCacheFlushAddr;
/*
static bool hasAllocateCacheFlush;
static bool hasAllocateCounterCacheFlush;
static bool hasAllocatePersistBarrier;
*/
//uint64_t val;
uint64_t val_addr = 0;
};
#endif
| 3,665 | 26.155556 | 90 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/crc32c.h
|
#ifndef CRC32C_H
#define CRC32C_H
typedef uint32_t (*crc_func)(uint32_t crc, const void *buf, size_t len);
crc_func crc32c;
void crc32c_init(void);
#endif /* CRC32C_H */
| 179 | 17 | 72 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/slabs.h
|
/*
* Copyright 2018 Lenovo
*
* Licensed under the BSD-3 license. see LICENSE.Lenovo.txt for full text
*/
/*
* Note:
* Codes enclosed in `#ifdef PSLAB' and `#endif' are added by Lenovo for
* persistent memory support
*/
/* slabs memory allocation */
#ifndef SLABS_H
#define SLABS_H
/** Init the subsystem. 1st argument is the limit on no. of bytes to allocate,
0 if no limit. 2nd argument is the growth factor; each slab will use a chunk
size equal to the previous slab's chunk size times this factor.
3rd argument specifies if the slab allocator should allocate all memory
up front (if true), or allocate memory in chunks as it is needed (if false)
*/
void slabs_init(const size_t limit, const double factor, const bool prealloc, const uint32_t *slab_sizes);
/** Call only during init. Pre-allocates all available memory */
void slabs_prefill_global(void);
#ifdef PSLAB
int slabs_dump_sizes(uint32_t *slab_sizes, int max);
void slabs_prefill_global_from_pmem(void);
void slabs_update_policy(void);
int do_slabs_renewslab(const unsigned int id, char *ptr);
void do_slab_realloc(item *it, unsigned int id);
void do_slabs_free(void *ptr, const size_t size, unsigned int id);
#endif
/**
* Given object size, return id to use when allocating/freeing memory for object
* 0 means error: can't store such a large object
*/
unsigned int slabs_clsid(const size_t size);
/** Allocate object of given length. 0 on error */ /*@null@*/
#define SLABS_ALLOC_NO_NEWPAGE 1
void *slabs_alloc(const size_t size, unsigned int id, uint64_t *total_bytes, unsigned int flags);
/** Free previously allocated object */
void slabs_free(void *ptr, size_t size, unsigned int id);
/** Adjust the stats for memory requested */
void slabs_adjust_mem_requested(unsigned int id, size_t old, size_t ntotal);
/** Adjust global memory limit up or down */
bool slabs_adjust_mem_limit(size_t new_mem_limit);
/** Return a datum for stats in binary protocol */
bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c);
typedef struct {
unsigned int chunks_per_page;
unsigned int chunk_size;
long int free_chunks;
long int total_pages;
} slab_stats_automove;
void fill_slab_stats_automove(slab_stats_automove *am);
unsigned int global_page_pool_size(bool *mem_flag);
/** Fill buffer with stats */ /*@null@*/
void slabs_stats(ADD_STAT add_stats, void *c);
/* Hints as to freespace in slab class */
unsigned int slabs_available_chunks(unsigned int id, bool *mem_flag, uint64_t *total_bytes, unsigned int *chunks_perslab);
void slabs_mlock(void);
void slabs_munlock(void);
int start_slab_maintenance_thread(void);
void stop_slab_maintenance_thread(void);
enum reassign_result_type {
REASSIGN_OK=0, REASSIGN_RUNNING, REASSIGN_BADCLASS, REASSIGN_NOSPARE,
REASSIGN_SRC_DST_SAME
};
enum reassign_result_type slabs_reassign(int src, int dst);
void slabs_rebalancer_pause(void);
void slabs_rebalancer_resume(void);
#ifdef EXTSTORE
void slabs_set_storage(void *arg);
#endif
#endif
| 3,024 | 31.180851 | 122 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/pslab.h
|
/*
* Copyright 2018 Lenovo
*
* Licensed under the BSD-3 license. see LICENSE.Lenovo.txt for full text
*/
#ifndef PSLAB_H
#define PSLAB_H
#include <libpmem.h>
#define PSLAB_POLICY_DRAM 0
#define PSLAB_POLICY_PMEM 1
#define PSLAB_POLICY_BALANCED 2
#define pmem_member_persist(p, m) \
pmem_persist(&(p)->m, sizeof ((p)->m))
#define pmem_member_flush(p, m) \
pmem_flush(&(p)->m, sizeof ((p)->m))
#define pmem_flush_from(p, t, m) \
pmem_flush(&(p)->m, sizeof (t) - offsetof(t, m));
#define pslab_item_data_persist(it) pmem_persist((it)->data, ITEM_dtotal(it)
#define pslab_item_data_flush(it) pmem_flush((it)->data, ITEM_dtotal(it))
int pslab_create(char *pool_name, uint32_t pool_size, uint32_t slab_size,
uint32_t *slabclass_sizes, int slabclass_num);
int pslab_pre_recover(char *name, uint32_t *slab_sizes, int slab_max, int slab_page_size);
int pslab_do_recover(void);
time_t pslab_process_started(time_t process_started);
void pslab_update_flushtime(uint32_t time);
void pslab_use_slab(void *p, int id, unsigned int size);
void *pslab_get_free_slab(void *slab);
int pslab_contains(char *p);
uint64_t pslab_addr2off(void *addr);
extern bool pslab_force;
#endif
| 1,186 | 30.236842 | 90 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/config.h
|
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Set to nonzero if you want to include DTRACE */
/* #undef ENABLE_DTRACE */
/* Set to nonzero if you want to include SASL */
/* #undef ENABLE_SASL */
/* Set to nonzero if you want to enable a SASL pwdb */
/* #undef ENABLE_SASL_PWDB */
/* machine is bigendian */
/* #undef ENDIAN_BIG */
/* machine is littleendian */
#define ENDIAN_LITTLE 1
/* Set to nonzero if you want to enable extstorextstore */
/* #undef EXTSTORE */
/* Define to 1 if support accept4 */
#define HAVE_ACCEPT4 1
/* Define to 1 if you have the `clock_gettime' function. */
#define HAVE_CLOCK_GETTIME 1
/* Define this if you have an implementation of drop_privileges() */
/* #undef HAVE_DROP_PRIVILEGES */
/* Define this if you have an implementation of drop_worker_privileges() */
/* #undef HAVE_DROP_WORKER_PRIVILEGES */
/* GCC 64bit Atomics available */
/* #undef HAVE_GCC_64ATOMICS */
/* GCC Atomics available */
#define HAVE_GCC_ATOMICS 1
/* Define to 1 if support getopt_long */
#define HAVE_GETOPT_LONG 1
/* Define to 1 if you have the `getpagesizes' function. */
/* #undef HAVE_GETPAGESIZES */
/* Have ntohll */
/* #undef HAVE_HTONLL */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `memcntl' function. */
/* #undef HAVE_MEMCNTL */
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `mlockall' function. */
#define HAVE_MLOCKALL 1
/* Define to 1 if you have the `pledge' function. */
/* #undef HAVE_PLEDGE */
/* we have sasl_callback_ft */
/* #undef HAVE_SASL_CALLBACK_FT */
/* Set to nonzero if your SASL implementation supports SASL_CB_GETCONF */
/* #undef HAVE_SASL_CB_GETCONF */
/* Define to 1 if you have the <sasl/sasl.h> header file. */
/* #undef HAVE_SASL_SASL_H */
/* Define to 1 if you have the `setppriv' function. */
/* #undef HAVE_SETPPRIV */
/* Define to 1 if you have the `sigignore' function. */
#define HAVE_SIGIGNORE 1
/* Define to 1 if stdbool.h conforms to C99. */
#define HAVE_STDBOOL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define this if you have umem.h */
/* #undef HAVE_UMEM_H */
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if the system has the type `_Bool'. */
#define HAVE__BOOL 1
/* Machine need alignment */
/* #undef NEED_ALIGN */
/* Name of package */
#define PACKAGE "memcached"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "[email protected]"
/* Define to the full name of this package. */
#define PACKAGE_NAME "memcached"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "memcached 1.5.4"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "memcached"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.5.4"
/* Set to nonzero if you want to enable pslab */
#define PSLAB 1
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "1.5.4"
/* find sigignore on Linux */
#define _GNU_SOURCE 1
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* define to int if socklen_t not available */
/* #undef socklen_t */
#if HAVE_STDBOOL_H
#include <stdbool.h>
#else
#define bool char
#define false 0
#define true 1
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
| 4,134 | 24.368098 | 78 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/sasl_defs.h
|
#ifndef SASL_DEFS_H
#define SASL_DEFS_H 1
// Longest one I could find was ``9798-U-RSA-SHA1-ENC''
#define MAX_SASL_MECH_LEN 32
#if defined(HAVE_SASL_SASL_H) && defined(ENABLE_SASL)
#include <sasl/sasl.h>
void init_sasl(void);
extern char my_sasl_hostname[1025];
#else /* End of SASL support */
typedef void* sasl_conn_t;
#define init_sasl() {}
#define sasl_dispose(x) {}
#define sasl_server_new(a, b, c, d, e, f, g, h) 1
#define sasl_listmech(a, b, c, d, e, f, g, h) 1
#define sasl_server_start(a, b, c, d, e, f) 1
#define sasl_server_step(a, b, c, d, e) 1
#define sasl_getprop(a, b, c) {}
#define SASL_OK 0
#define SASL_CONTINUE -1
#endif /* sasl compat */
#endif /* SASL_DEFS_H */
| 693 | 20.6875 | 55 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/logger.h
|
/* logging functions */
#ifndef LOGGER_H
#define LOGGER_H
#include "bipbuffer.h"
/* TODO: starttime tunable */
#define LOGGER_BUF_SIZE 1024 * 64
#define LOGGER_WATCHER_BUF_SIZE 1024 * 256
#define LOGGER_ENTRY_MAX_SIZE 2048
#define GET_LOGGER() ((logger *) pthread_getspecific(logger_key));
/* Inlined from memcached.h - should go into sub header */
typedef unsigned int rel_time_t;
enum log_entry_type {
LOGGER_ASCII_CMD = 0,
LOGGER_EVICTION,
LOGGER_ITEM_GET,
LOGGER_ITEM_STORE,
LOGGER_CRAWLER_STATUS,
LOGGER_SLAB_MOVE,
#ifdef EXTSTORE
LOGGER_EXTSTORE_WRITE,
LOGGER_COMPACT_START,
LOGGER_COMPACT_ABORT,
LOGGER_COMPACT_READ_START,
LOGGER_COMPACT_READ_END,
LOGGER_COMPACT_END,
LOGGER_COMPACT_FRAGINFO,
#endif
};
enum log_entry_subtype {
LOGGER_TEXT_ENTRY = 0,
LOGGER_EVICTION_ENTRY,
LOGGER_ITEM_GET_ENTRY,
LOGGER_ITEM_STORE_ENTRY,
#ifdef EXTSTORE
LOGGER_EXT_WRITE_ENTRY,
#endif
};
enum logger_ret_type {
LOGGER_RET_OK = 0,
LOGGER_RET_NOSPACE,
LOGGER_RET_ERR
};
enum logger_parse_entry_ret {
LOGGER_PARSE_ENTRY_OK = 0,
LOGGER_PARSE_ENTRY_FULLBUF,
LOGGER_PARSE_ENTRY_FAILED
};
typedef const struct {
enum log_entry_subtype subtype;
int reqlen;
uint16_t eflags;
char *format;
} entry_details;
/* log entry intermediary structures */
struct logentry_eviction {
long long int exptime;
uint32_t latime;
uint16_t it_flags;
uint8_t nkey;
uint8_t clsid;
char key[];
};
#ifdef EXTSTORE
struct logentry_ext_write {
long long int exptime;
uint32_t latime;
uint16_t it_flags;
uint8_t nkey;
uint8_t clsid;
uint8_t bucket;
char key[];
};
#endif
struct logentry_item_get {
uint8_t was_found;
uint8_t nkey;
uint8_t clsid;
char key[];
};
struct logentry_item_store {
int status;
int cmd;
rel_time_t ttl;
uint8_t nkey;
uint8_t clsid;
char key[];
};
/* end intermediary structures */
typedef struct _logentry {
enum log_entry_subtype event;
uint16_t eflags;
uint64_t gid;
struct timeval tv; /* not monotonic! */
int size;
union {
void *entry; /* probably an item */
char end;
} data[];
} logentry;
#define LOG_SYSEVENTS (1<<1) /* threads start/stop/working */
#define LOG_FETCHERS (1<<2) /* get/gets/etc */
#define LOG_MUTATIONS (1<<3) /* set/append/incr/etc */
#define LOG_SYSERRORS (1<<4) /* malloc/etc errors */
#define LOG_CONNEVENTS (1<<5) /* new client, closed, etc */
#define LOG_EVICTIONS (1<<6) /* details of evicted items */
#define LOG_STRICT (1<<7) /* block worker instead of drop */
#define LOG_RAWCMDS (1<<9) /* raw ascii commands */
typedef struct _logger {
struct _logger *prev;
struct _logger *next;
pthread_mutex_t mutex; /* guard for this + *buf */
uint64_t written; /* entries written to the buffer */
uint64_t dropped; /* entries dropped */
uint64_t blocked; /* times blocked instead of dropped */
uint16_t fetcher_ratio; /* log one out of every N fetches */
uint16_t mutation_ratio; /* log one out of every N mutations */
uint16_t eflags; /* flags this logger should log */
bipbuf_t *buf;
const entry_details *entry_map;
} logger;
enum logger_watcher_type {
LOGGER_WATCHER_STDERR = 0,
LOGGER_WATCHER_CLIENT = 1
};
typedef struct {
void *c; /* original connection structure. still with source thread attached */
int sfd; /* client fd */
int id; /* id number for watcher list */
uint64_t skipped; /* lines skipped since last successful print */
bool failed_flush; /* recently failed to write out (EAGAIN), wait before retry */
enum logger_watcher_type t; /* stderr, client, syslog, etc */
uint16_t eflags; /* flags we are interested in */
bipbuf_t *buf; /* per-watcher output buffer */
} logger_watcher;
struct logger_stats {
uint64_t worker_dropped;
uint64_t worker_written;
uint64_t watcher_skipped;
uint64_t watcher_sent;
};
extern pthread_key_t logger_key;
/* public functions */
void logger_init(void);
logger *logger_create(void);
#define LOGGER_LOG(l, flag, type, ...) \
do { \
logger *myl = l; \
if (l == NULL) \
myl = GET_LOGGER(); \
if (myl->eflags & flag) \
logger_log(myl, type, __VA_ARGS__); \
} while (0)
enum logger_ret_type logger_log(logger *l, const enum log_entry_type event, const void *entry, ...);
enum logger_add_watcher_ret {
LOGGER_ADD_WATCHER_TOO_MANY = 0,
LOGGER_ADD_WATCHER_OK,
LOGGER_ADD_WATCHER_FAILED
};
enum logger_add_watcher_ret logger_add_watcher(void *c, const int sfd, uint16_t f);
#endif
| 4,680 | 24.032086 | 100 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/getresult.sh
|
awk -F ' ' '$1 ~ /time/ {sum += $3} END {print sum}' out
awk -F ' ' '$1 ~ /pagecnt/ {sum += $2} END {print sum}' out
awk -F ' ' '$1 ~ /timecp/ {sum += $3} END {print sum}' out
| 176 | 43.25 | 59 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/extstore.h
|
#ifndef EXTSTORE_H
#define EXTSTORE_H
/* A safe-to-read dataset for determining compaction.
* id is the array index.
*/
struct extstore_page_data {
uint64_t version;
uint64_t bytes_used;
unsigned int bucket;
};
/* Pages can have objects deleted from them at any time. This creates holes
* that can't be reused until the page is either evicted or all objects are
* deleted.
* bytes_fragmented is the total bytes for all of these holes.
* It is the size of all used pages minus each page's bytes_used value.
*/
struct extstore_stats {
uint64_t page_allocs;
uint64_t page_count; /* total page count */
uint64_t page_evictions;
uint64_t page_reclaims;
uint64_t page_size; /* size in bytes per page (supplied by caller) */
uint64_t pages_free; /* currently unallocated/unused pages */
uint64_t pages_used;
uint64_t objects_evicted;
uint64_t objects_read;
uint64_t objects_written;
uint64_t objects_used; /* total number of objects stored */
uint64_t bytes_evicted;
uint64_t bytes_written;
uint64_t bytes_read; /* wbuf - read -> bytes read from storage */
uint64_t bytes_used; /* total number of bytes stored */
uint64_t bytes_fragmented; /* see above comment */
struct extstore_page_data *page_data;
};
// TODO: Temporary configuration structure. A "real" library should have an
// extstore_set(enum, void *ptr) which hides the implementation.
// this is plenty for quick development.
struct extstore_conf {
unsigned int page_size; // ideally 64-256M in size
unsigned int page_count;
unsigned int page_buckets; // number of different writeable pages
unsigned int wbuf_size; // must divide cleanly into page_size
unsigned int wbuf_count; // this might get locked to "2 per active page"
unsigned int io_threadcount;
unsigned int io_depth; // with normal I/O, hits locks less. req'd for AIO
};
enum obj_io_mode {
OBJ_IO_READ = 0,
OBJ_IO_WRITE,
};
typedef struct _obj_io obj_io;
typedef void (*obj_io_cb)(void *e, obj_io *io, int ret);
/* An object for both reads and writes to the storage engine.
* Once an IO is submitted, ->next may be changed by the IO thread. It is not
* safe to further modify the IO stack until the entire request is completed.
*/
struct _obj_io {
void *data; /* user supplied data pointer */
struct _obj_io *next;
char *buf; /* buffer of data to read or write to */
struct iovec *iov; /* alternatively, use this iovec */
unsigned int iovcnt; /* number of IOV's */
unsigned int page_version; /* page version for read mode */
unsigned int len; /* for both modes */
unsigned int offset; /* for read mode */
unsigned short page_id; /* for read mode */
enum obj_io_mode mode;
/* callback pointers? */
obj_io_cb cb;
};
enum extstore_res {
EXTSTORE_INIT_BAD_WBUF_SIZE = 1,
EXTSTORE_INIT_NEED_MORE_WBUF,
EXTSTORE_INIT_NEED_MORE_BUCKETS,
EXTSTORE_INIT_PAGE_WBUF_ALIGNMENT,
EXTSTORE_INIT_OOM,
EXTSTORE_INIT_OPEN_FAIL,
EXTSTORE_INIT_THREAD_FAIL
};
const char *extstore_err(enum extstore_res res);
void *extstore_init(char *fn, struct extstore_conf *cf, enum extstore_res *res);
int extstore_write_request(void *ptr, unsigned int bucket, obj_io *io);
void extstore_write(void *ptr, obj_io *io);
int extstore_submit(void *ptr, obj_io *io);
/* count are the number of objects being removed, bytes are the original
* length of those objects. Bytes is optional but you can't track
* fragmentation without it.
*/
int extstore_check(void *ptr, unsigned int page_id, uint64_t page_version);
int extstore_delete(void *ptr, unsigned int page_id, uint64_t page_version, unsigned int count, unsigned int bytes);
void extstore_get_stats(void *ptr, struct extstore_stats *st);
/* add page data array to a stats structure.
* caller must allocate its stats.page_data memory first.
*/
void extstore_get_page_data(void *ptr, struct extstore_stats *st);
void extstore_run_maint(void *ptr);
void extstore_close_page(void *ptr, unsigned int page_id, uint64_t page_version);
#endif
| 4,091 | 36.541284 | 116 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/assoc.h
|
/* associative array */
void assoc_init(const int hashpower_init);
item *assoc_find(const char *key, const size_t nkey, const uint32_t hv);
int assoc_insert(item *item, const uint32_t hv);
void assoc_delete(const char *key, const size_t nkey, const uint32_t hv);
void do_assoc_move_next_bucket(void);
int start_assoc_maintenance_thread(void);
void stop_assoc_maintenance_thread(void);
extern unsigned int hashpower;
extern unsigned int item_lock_hashpower;
| 457 | 40.636364 | 73 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/run.sh
|
#!/usr/bin/env bash
sudo rm -rf /mnt/mem/*
sed -i "s/Werror/Wno-error/g" Makefile
make -j USE_PMDK=yes STD=-std=gnu99
sudo ./memcached -u root -m 0 -t 1 -o pslab_policy=pmem,pslab_file=/mnt/mem/pool,pslab_force > out
grep "cp" out > time
log=$(awk '{sum+= $2;} END{print sum;}' time)
echo $1'cp' $log
| 301 | 32.555556 | 98 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/slab_automove_extstore.h
|
#ifndef SLAB_AUTOMOVE_EXTSTORE_H
#define SLAB_AUTOMOVE_EXTSTORE_H
void *slab_automove_extstore_init(struct settings *settings);
void slab_automove_extstore_free(void *arg);
void slab_automove_extstore_run(void *arg, int *src, int *dst);
#endif
| 246 | 26.444444 | 63 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/memcached.h
|
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2018 Lenovo
*
* Licensed under the BSD-3 license. see LICENSE.Lenovo.txt for full text
*/
/*
* Note:
* Codes enclosed in `#ifdef PSLAB' and `#endif' are added by Lenovo for
* persistent memory support
*/
/** \file
* The main memcached header holding commonly used data
* structures and function prototypes.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <event.h>
#include <netdb.h>
#include <pthread.h>
#include <unistd.h>
#include <assert.h>
#include "itoa_ljust.h"
#include "protocol_binary.h"
#include "cache.h"
#include "logger.h"
#ifdef EXTSTORE
#include "extstore.h"
#include "crc32c.h"
#endif
#ifdef PSLAB
#include "pslab.h"
#endif
#include "sasl_defs.h"
/** Maximum length of a key. */
#define KEY_MAX_LENGTH 250
/** Size of an incr buf. */
#define INCR_MAX_STORAGE_LEN 24
#define DATA_BUFFER_SIZE 2048
#define UDP_READ_BUFFER_SIZE 65536
#define UDP_MAX_PAYLOAD_SIZE 1400
#define UDP_HEADER_SIZE 8
#define MAX_SENDBUF_SIZE (256 * 1024 * 1024)
/* Up to 3 numbers (2 32bit, 1 64bit), spaces, newlines, null 0 */
#define SUFFIX_SIZE 50
/** Initial size of list of items being returned by "get". */
#define ITEM_LIST_INITIAL 200
/** Initial size of list of CAS suffixes appended to "gets" lines. */
#define SUFFIX_LIST_INITIAL 100
/** Initial size of the sendmsg() scatter/gather array. */
#define IOV_LIST_INITIAL 400
/** Initial number of sendmsg() argument structures to allocate. */
#define MSG_LIST_INITIAL 10
/** High water marks for buffer shrinking */
#define READ_BUFFER_HIGHWAT 8192
#define ITEM_LIST_HIGHWAT 400
#define IOV_LIST_HIGHWAT 600
#define MSG_LIST_HIGHWAT 100
/* Binary protocol stuff */
#define MIN_BIN_PKT_LENGTH 16
#define BIN_PKT_HDR_WORDS (MIN_BIN_PKT_LENGTH/sizeof(uint32_t))
/* Initial power multiplier for the hash table */
#define HASHPOWER_DEFAULT 16
#define HASHPOWER_MAX 32
/*
* We only reposition items in the LRU queue if they haven't been repositioned
* in this many seconds. That saves us from churning on frequently-accessed
* items.
*/
#define ITEM_UPDATE_INTERVAL 60
/* unistd.h is here */
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
/* Slab sizing definitions. */
#ifdef PSLAB
#define POWER_SMALLEST 2
#else
#define POWER_SMALLEST 1
#endif
#define POWER_LARGEST 256 /* actual cap is 255 */
#define SLAB_GLOBAL_PAGE_POOL 0 /* magic slab class for storing pages for reassignment */
#ifdef PSLAB
#define SLAB_GLOBAL_PAGE_POOL_PMEM 1 /* magic slab class for storing pmem pages for reassignment */
#endif
#define CHUNK_ALIGN_BYTES 8
/* slab class max is a 6-bit number, -1. */
#define MAX_NUMBER_OF_SLAB_CLASSES (63 + 1)
/** How long an object can reasonably be assumed to be locked before
harvesting it on a low memory condition. Default: disabled. */
#define TAIL_REPAIR_TIME_DEFAULT 0
/* warning: don't use these macros with a function, as it evals its arg twice */
#define ITEM_get_cas(i) (((i)->it_flags & ITEM_CAS) ? \
(i)->data->cas : (uint64_t)0)
#define ITEM_set_cas(i,v) { \
if ((i)->it_flags & ITEM_CAS) { \
(i)->data->cas = v; \
} \
}
#define ITEM_key(item) (((char*)&((item)->data)) \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#define ITEM_suffix(item) ((char*) &((item)->data) + (item)->nkey + 1 \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#define ITEM_data(item) ((char*) &((item)->data) + (item)->nkey + 1 \
+ (item)->nsuffix \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#define ITEM_ntotal(item) (sizeof(struct _stritem) + (item)->nkey + 1 \
+ (item)->nsuffix + (item)->nbytes \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#ifdef PSLAB
#define ITEM_dtotal(item) (item)->nkey + 1 + (item)->nsuffix + (item)->nbytes \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0)
#endif
#define ITEM_clsid(item) ((item)->slabs_clsid & ~(3<<6))
#define ITEM_lruid(item) ((item)->slabs_clsid & (3<<6))
#define STAT_KEY_LEN 128
#define STAT_VAL_LEN 128
/** Append a simple stat with a stat name, value format and value */
#define APPEND_STAT(name, fmt, val) \
append_stat(name, add_stats, c, fmt, val);
/** Append an indexed stat with a stat name (with format), value format
and value */
#define APPEND_NUM_FMT_STAT(name_fmt, num, name, fmt, val) \
klen = snprintf(key_str, STAT_KEY_LEN, name_fmt, num, name); \
vlen = snprintf(val_str, STAT_VAL_LEN, fmt, val); \
add_stats(key_str, klen, val_str, vlen, c);
/** Common APPEND_NUM_FMT_STAT format. */
#define APPEND_NUM_STAT(num, name, fmt, val) \
APPEND_NUM_FMT_STAT("%d:%s", num, name, fmt, val)
/**
* Callback for any function producing stats.
*
* @param key the stat's key
* @param klen length of the key
* @param val the stat's value in an ascii form (e.g. text form of a number)
* @param vlen length of the value
* @parm cookie magic callback cookie
*/
typedef void (*ADD_STAT)(const char *key, const uint16_t klen,
const char *val, const uint32_t vlen,
const void *cookie);
/*
* NOTE: If you modify this table you _MUST_ update the function state_text
*/
/**
* Possible states of a connection.
*/
enum conn_states {
conn_listening, /**< the socket which listens for connections */
conn_new_cmd, /**< Prepare connection for next command */
conn_waiting, /**< waiting for a readable socket */
conn_read, /**< reading in a command line */
conn_parse_cmd, /**< try to parse a command from the input buffer */
conn_write, /**< writing out a simple response */
conn_nread, /**< reading in a fixed number of bytes */
conn_swallow, /**< swallowing unnecessary bytes w/o storing */
conn_closing, /**< closing this connection */
conn_mwrite, /**< writing out many items sequentially */
conn_closed, /**< connection is closed */
conn_watch, /**< held by the logger thread as a watcher */
conn_max_state /**< Max state value (used for assertion) */
};
enum bin_substates {
bin_no_state,
bin_reading_set_header,
bin_reading_cas_header,
bin_read_set_value,
bin_reading_get_key,
bin_reading_stat,
bin_reading_del_header,
bin_reading_incr_header,
bin_read_flush_exptime,
bin_reading_sasl_auth,
bin_reading_sasl_auth_data,
bin_reading_touch_key,
};
enum protocol {
ascii_prot = 3, /* arbitrary value. */
binary_prot,
negotiating_prot /* Discovering the protocol */
};
enum network_transport {
local_transport, /* Unix sockets*/
tcp_transport,
udp_transport
};
enum pause_thread_types {
PAUSE_WORKER_THREADS = 0,
PAUSE_ALL_THREADS,
RESUME_ALL_THREADS,
RESUME_WORKER_THREADS
};
#define IS_TCP(x) (x == tcp_transport)
#define IS_UDP(x) (x == udp_transport)
#define NREAD_ADD 1
#define NREAD_SET 2
#define NREAD_REPLACE 3
#define NREAD_APPEND 4
#define NREAD_PREPEND 5
#define NREAD_CAS 6
enum store_item_type {
NOT_STORED=0, STORED, EXISTS, NOT_FOUND, TOO_LARGE, NO_MEMORY
};
enum delta_result_type {
OK, NON_NUMERIC, EOM, DELTA_ITEM_NOT_FOUND, DELTA_ITEM_CAS_MISMATCH
};
/** Time relative to server start. Smaller than time_t on 64-bit systems. */
// TODO: Move to sub-header. needed in logger.h
//typedef unsigned int rel_time_t;
/** Use X macros to avoid iterating over the stats fields during reset and
* aggregation. No longer have to add new stats in 3+ places.
*/
#define SLAB_STATS_FIELDS \
X(set_cmds) \
X(get_hits) \
X(touch_hits) \
X(delete_hits) \
X(cas_hits) \
X(cas_badval) \
X(incr_hits) \
X(decr_hits)
/** Stats stored per slab (and per thread). */
struct slab_stats {
#define X(name) uint64_t name;
SLAB_STATS_FIELDS
#undef X
};
#define THREAD_STATS_FIELDS \
X(get_cmds) \
X(get_misses) \
X(get_expired) \
X(get_flushed) \
X(touch_cmds) \
X(touch_misses) \
X(delete_misses) \
X(incr_misses) \
X(decr_misses) \
X(cas_misses) \
X(bytes_read) \
X(bytes_written) \
X(flush_cmds) \
X(conn_yields) /* # of yields for connections (-R option)*/ \
X(auth_cmds) \
X(auth_errors) \
X(idle_kicks) /* idle connections killed */
#ifdef EXTSTORE
#define EXTSTORE_THREAD_STATS_FIELDS \
X(get_extstore) \
X(recache_from_extstore) \
X(miss_from_extstore) \
X(badcrc_from_extstore)
#endif
/**
* Stats stored per-thread.
*/
struct thread_stats {
pthread_mutex_t mutex;
#define X(name) uint64_t name;
THREAD_STATS_FIELDS
#ifdef EXTSTORE
EXTSTORE_THREAD_STATS_FIELDS
#endif
#undef X
struct slab_stats slab_stats[MAX_NUMBER_OF_SLAB_CLASSES];
uint64_t lru_hits[POWER_LARGEST];
};
/**
* Global stats. Only resettable stats should go into this structure.
*/
struct stats {
uint64_t total_items;
uint64_t total_conns;
uint64_t rejected_conns;
uint64_t malloc_fails;
uint64_t listen_disabled_num;
uint64_t slabs_moved; /* times slabs were moved around */
uint64_t slab_reassign_rescues; /* items rescued during slab move */
uint64_t slab_reassign_evictions_nomem; /* valid items lost during slab move */
uint64_t slab_reassign_inline_reclaim; /* valid items lost during slab move */
uint64_t slab_reassign_chunk_rescues; /* chunked-item chunks recovered */
uint64_t slab_reassign_busy_items; /* valid temporarily unmovable */
uint64_t slab_reassign_busy_deletes; /* refcounted items killed */
uint64_t lru_crawler_starts; /* Number of item crawlers kicked off */
uint64_t lru_maintainer_juggles; /* number of LRU bg pokes */
uint64_t time_in_listen_disabled_us; /* elapsed time in microseconds while server unable to process new connections */
uint64_t log_worker_dropped; /* logs dropped by worker threads */
uint64_t log_worker_written; /* logs written by worker threads */
uint64_t log_watcher_skipped; /* logs watchers missed */
uint64_t log_watcher_sent; /* logs sent to watcher buffers */
#ifdef EXTSTORE
uint64_t extstore_compact_lost; /* items lost because they were locked */
uint64_t extstore_compact_rescues; /* items re-written during compaction */
uint64_t extstore_compact_skipped; /* unhit items skipped during compaction */
#endif
struct timeval maxconns_entered; /* last time maxconns entered */
};
/**
* Global "state" stats. Reflects state that shouldn't be wiped ever.
* Ordered for some cache line locality for commonly updated counters.
*/
struct stats_state {
uint64_t curr_items;
uint64_t curr_bytes;
uint64_t curr_conns;
uint64_t hash_bytes; /* size used for hash tables */
unsigned int conn_structs;
unsigned int reserved_fds;
unsigned int hash_power_level; /* Better hope it's not over 9000 */
bool hash_is_expanding; /* If the hash table is being expanded */
bool accepting_conns; /* whether we are currently accepting */
bool slab_reassign_running; /* slab reassign in progress */
bool lru_crawler_running; /* crawl in progress */
};
#define MAX_VERBOSITY_LEVEL 2
/* When adding a setting, be sure to update process_stat_settings */
/**
* Globally accessible settings as derived from the commandline.
*/
struct settings {
size_t maxbytes;
int maxconns;
int port;
int udpport;
char *inter;
int verbose;
rel_time_t oldest_live; /* ignore existing items older than this */
uint64_t oldest_cas; /* ignore existing items with CAS values lower than this */
int evict_to_free;
char *socketpath; /* path to unix socket if using local socket */
int access; /* access mask (a la chmod) for unix domain socket */
double factor; /* chunk size growth factor */
int chunk_size;
int num_threads; /* number of worker (without dispatcher) libevent threads to run */
int num_threads_per_udp; /* number of worker threads serving each udp socket */
char prefix_delimiter; /* character that marks a key prefix (for stats) */
int detail_enabled; /* nonzero if we're collecting detailed stats */
int reqs_per_event; /* Maximum number of io to process on each
io-event. */
bool use_cas;
enum protocol binding_protocol;
int backlog;
int item_size_max; /* Maximum item size */
int slab_chunk_size_max; /* Upper end for chunks within slab pages. */
int slab_page_size; /* Slab's page units. */
bool sasl; /* SASL on/off */
bool maxconns_fast; /* Whether or not to early close connections */
bool lru_crawler; /* Whether or not to enable the autocrawler thread */
bool lru_maintainer_thread; /* LRU maintainer background thread */
bool lru_segmented; /* Use split or flat LRU's */
bool slab_reassign; /* Whether or not slab reassignment is allowed */
int slab_automove; /* Whether or not to automatically move slabs */
double slab_automove_ratio; /* youngest must be within pct of oldest */
unsigned int slab_automove_window; /* window mover for algorithm */
int hashpower_init; /* Starting hash power level */
bool shutdown_command; /* allow shutdown command */
int tail_repair_time; /* LRU tail refcount leak repair time */
bool flush_enabled; /* flush_all enabled */
bool dump_enabled; /* whether cachedump/metadump commands work */
char *hash_algorithm; /* Hash algorithm in use */
int lru_crawler_sleep; /* Microsecond sleep between items */
uint32_t lru_crawler_tocrawl; /* Number of items to crawl per run */
int hot_lru_pct; /* percentage of slab space for HOT_LRU */
int warm_lru_pct; /* percentage of slab space for WARM_LRU */
double hot_max_factor; /* HOT tail age relative to COLD tail */
double warm_max_factor; /* WARM tail age relative to COLD tail */
int crawls_persleep; /* Number of LRU crawls to run before sleeping */
bool inline_ascii_response; /* pre-format the VALUE line for ASCII responses */
bool temp_lru; /* TTL < temporary_ttl uses TEMP_LRU */
uint32_t temporary_ttl; /* temporary LRU threshold */
int idle_timeout; /* Number of seconds to let connections idle */
unsigned int logger_watcher_buf_size; /* size of logger's per-watcher buffer */
unsigned int logger_buf_size; /* size of per-thread logger buffer */
bool drop_privileges; /* Whether or not to drop unnecessary process privileges */
bool relaxed_privileges; /* Relax process restrictions when running testapp */
#ifdef EXTSTORE
unsigned int ext_item_size; /* minimum size of items to store externally */
unsigned int ext_item_age; /* max age of tail item before storing ext. */
unsigned int ext_low_ttl; /* remaining TTL below this uses own pages */
unsigned int ext_recache_rate; /* counter++ % recache_rate == 0 > recache */
unsigned int ext_wbuf_size; /* read only note for the engine */
unsigned int ext_compact_under; /* when fewer than this many pages, compact */
unsigned int ext_drop_under; /* when fewer than this many pages, drop COLD items */
double ext_max_frag; /* ideal maximum page fragmentation */
double slab_automove_freeratio; /* % of memory to hold free as buffer */
bool ext_drop_unread; /* skip unread items during compaction */
/* per-slab-class free chunk limit */
unsigned int ext_free_memchunks[MAX_NUMBER_OF_SLAB_CLASSES];
#endif
#ifdef PSLAB
size_t pslab_size; /* pmem slab pool size */
unsigned int pslab_policy; /* pmem slab allocation policy */
bool pslab_recover; /* do recovery from pmem slab pool */
#endif
};
extern struct stats stats;
extern struct stats_state stats_state;
extern time_t process_started;
extern struct settings settings;
#define ITEM_LINKED 1
#define ITEM_CAS 2
/* temp */
#define ITEM_SLABBED 4
/* Item was fetched at least once in its lifetime */
#define ITEM_FETCHED 8
/* Appended on fetch, removed on LRU shuffling */
#define ITEM_ACTIVE 16
/* If an item's storage are chained chunks. */
#define ITEM_CHUNKED 32
#define ITEM_CHUNK 64
#ifdef PSLAB
/* If an item is stored in pmem */
#define ITEM_PSLAB 64
#endif
#ifdef EXTSTORE
/* ITEM_data bulk is external to item */
#define ITEM_HDR 128
#endif
/**
* Structure for storing items within memcached.
*/
typedef struct _stritem {
/* Protected by LRU locks */
struct _stritem *next;
struct _stritem *prev;
/* Rest are protected by an item lock */
struct _stritem *h_next; /* hash chain next */
rel_time_t time; /* least recent access */
rel_time_t exptime; /* expire time */
int nbytes; /* size of data */
unsigned short refcount;
uint8_t nsuffix; /* length of flags-and-length string */
uint8_t it_flags; /* ITEM_* above */
uint8_t slabs_clsid;/* which slab class we're in */
uint8_t nkey; /* key length, w/terminating null and padding */
/* this odd type prevents type-punning issues when we do
* the little shuffle to save space when not using CAS. */
union {
uint64_t cas;
char end;
} data[];
/* if it_flags & ITEM_CAS we have 8 bytes CAS */
/* then null-terminated key */
/* then " flags length\r\n" (no terminating null) */
/* then data with terminating \r\n (no terminating null; it's binary!) */
} item;
// TODO: If we eventually want user loaded modules, we can't use an enum :(
enum crawler_run_type {
CRAWLER_AUTOEXPIRE=0, CRAWLER_EXPIRED, CRAWLER_METADUMP
};
typedef struct {
struct _stritem *next;
struct _stritem *prev;
struct _stritem *h_next; /* hash chain next */
rel_time_t time; /* least recent access */
rel_time_t exptime; /* expire time */
int nbytes; /* size of data */
unsigned short refcount;
uint8_t nsuffix; /* length of flags-and-length string */
uint8_t it_flags; /* ITEM_* above */
uint8_t slabs_clsid;/* which slab class we're in */
uint8_t nkey; /* key length, w/terminating null and padding */
uint32_t remaining; /* Max keys to crawl per slab per invocation */
uint64_t reclaimed; /* items reclaimed during this crawl. */
uint64_t unfetched; /* items reclaimed unfetched during this crawl. */
uint64_t checked; /* items examined during this crawl. */
} crawler;
/* Header when an item is actually a chunk of another item. */
typedef struct _strchunk {
struct _strchunk *next; /* points within its own chain. */
struct _strchunk *prev; /* can potentially point to the head. */
struct _stritem *head; /* always points to the owner chunk */
int size; /* available chunk space in bytes */
int used; /* chunk space used */
int nbytes; /* used. */
unsigned short refcount; /* used? */
uint8_t orig_clsid; /* For obj hdr chunks slabs_clsid is fake. */
uint8_t it_flags; /* ITEM_* above. */
uint8_t slabs_clsid; /* Same as above. */
#ifdef PSLAB
_Bool pslab : 1;
uint64_t next_poff; /* offset of next chunk in pmem */
#endif
char data[];
} item_chunk;
#ifdef EXTSTORE
typedef struct {
unsigned int page_version; /* from IO header */
unsigned int offset; /* from IO header */
unsigned short page_id; /* from IO header */
} item_hdr;
#endif
typedef struct {
pthread_t thread_id; /* unique ID of this thread */
struct event_base *base; /* libevent handle this thread uses */
struct event notify_event; /* listen event for notify pipe */
int notify_receive_fd; /* receiving end of notify pipe */
int notify_send_fd; /* sending end of notify pipe */
struct thread_stats stats; /* Stats generated by this thread */
struct conn_queue *new_conn_queue; /* queue of new connections to handle */
cache_t *suffix_cache; /* suffix cache */
#ifdef EXTSTORE
cache_t *io_cache; /* IO objects */
void *storage; /* data object for storage system */
#endif
logger *l; /* logger buffer */
void *lru_bump_buf; /* async LRU bump buffer */
} LIBEVENT_THREAD;
typedef struct conn conn;
#ifdef EXTSTORE
typedef struct _io_wrap {
obj_io io;
struct _io_wrap *next;
conn *c;
item *hdr_it; /* original header item. */
unsigned int iovec_start; /* start of the iovecs for this IO */
unsigned int iovec_count; /* total number of iovecs */
unsigned int iovec_data; /* specific index of data iovec */
bool miss; /* signal a miss to unlink hdr_it */
bool badcrc; /* signal a crc failure */
bool active; // FIXME: canary for test. remove
} io_wrap;
#endif
/**
* The structure representing a connection into memcached.
*/
struct conn {
int sfd;
sasl_conn_t *sasl_conn;
bool authenticated;
enum conn_states state;
enum bin_substates substate;
rel_time_t last_cmd_time;
struct event event;
short ev_flags;
short which; /** which events were just triggered */
char *rbuf; /** buffer to read commands into */
char *rcurr; /** but if we parsed some already, this is where we stopped */
int rsize; /** total allocated size of rbuf */
int rbytes; /** how much data, starting from rcur, do we have unparsed */
char *wbuf;
char *wcurr;
int wsize;
int wbytes;
/** which state to go into after finishing current write */
enum conn_states write_and_go;
void *write_and_free; /** free this memory after finishing writing */
char *ritem; /** when we read in an item's value, it goes here */
int rlbytes;
/* data for the nread state */
/**
* item is used to hold an item structure created after reading the command
* line of set/add/replace commands, but before we finished reading the actual
* data. The data is read into ITEM_data(item) to avoid extra copying.
*/
void *item; /* for commands set/add/replace */
/* data for the swallow state */
int sbytes; /* how many bytes to swallow */
/* data for the mwrite state */
struct iovec *iov;
int iovsize; /* number of elements allocated in iov[] */
int iovused; /* number of elements used in iov[] */
struct msghdr *msglist;
int msgsize; /* number of elements allocated in msglist[] */
int msgused; /* number of elements used in msglist[] */
int msgcurr; /* element in msglist[] being transmitted now */
int msgbytes; /* number of bytes in current msg */
item **ilist; /* list of items to write out */
int isize;
item **icurr;
int ileft;
char **suffixlist;
int suffixsize;
char **suffixcurr;
int suffixleft;
#ifdef EXTSTORE
int io_wrapleft;
unsigned int recache_counter;
io_wrap *io_wraplist; /* linked list of io_wraps */
bool io_queued; /* FIXME: debugging flag */
#endif
enum protocol protocol; /* which protocol this connection speaks */
enum network_transport transport; /* what transport is used by this connection */
/* data for UDP clients */
int request_id; /* Incoming UDP request ID, if this is a UDP "connection" */
struct sockaddr_in6 request_addr; /* udp: Who sent the most recent request */
socklen_t request_addr_size;
unsigned char *hdrbuf; /* udp packet headers */
int hdrsize; /* number of headers' worth of space is allocated */
bool noreply; /* True if the reply should not be sent. */
/* current stats command */
struct {
char *buffer;
size_t size;
size_t offset;
} stats;
/* Binary protocol stuff */
/* This is where the binary header goes */
protocol_binary_request_header binary_header;
uint64_t cas; /* the cas to return */
short cmd; /* current command being processed */
int opaque;
int keylen;
conn *next; /* Used for generating a list of conn structures */
LIBEVENT_THREAD *thread; /* Pointer to the thread object serving this connection */
uint32_t objid;
};
/* array of conn structures, indexed by file descriptor */
extern conn **conns;
/* current time of day (updated periodically) */
extern volatile rel_time_t current_time;
/* TODO: Move to slabs.h? */
extern volatile int slab_rebalance_signal;
struct slab_rebalance {
void *slab_start;
void *slab_end;
void *slab_pos;
int s_clsid;
int d_clsid;
uint32_t busy_items;
uint32_t rescues;
uint32_t evictions_nomem;
uint32_t inline_reclaim;
uint32_t chunk_rescues;
uint32_t busy_deletes;
uint32_t busy_loops;
uint8_t done;
};
extern struct slab_rebalance slab_rebal;
#ifdef EXTSTORE
extern void *ext_storage;
#endif
/*
* Functions
*/
void do_accept_new_conns(const bool do_accept);
enum delta_result_type do_add_delta(conn *c, const char *key,
const size_t nkey, const bool incr,
const int64_t delta, char *buf,
uint64_t *cas, const uint32_t hv);
enum store_item_type do_store_item(item *item, int comm, conn* c, const uint32_t hv);
conn *conn_new(const int sfd, const enum conn_states init_state, const int event_flags, const int read_buffer_size, enum network_transport transport, struct event_base *base);
void conn_worker_readd(conn *c);
extern int daemonize(int nochdir, int noclose);
#define mutex_lock(x) pthread_mutex_lock(x)
#define mutex_unlock(x) pthread_mutex_unlock(x)
#include "stats.h"
#include "slabs.h"
#include "assoc.h"
#include "items.h"
#include "crawler.h"
#include "trace.h"
#include "hash.h"
#include "util.h"
/*
* Functions such as the libevent-related calls that need to do cross-thread
* communication in multithreaded mode (rather than actually doing the work
* in the current thread) are called via "dispatch_" frontends, which are
* also #define-d to directly call the underlying code in singlethreaded mode.
*/
void memcached_thread_init(int nthreads, void *arg);
void redispatch_conn(conn *c);
void dispatch_conn_new(int sfd, enum conn_states init_state, int event_flags, int read_buffer_size, enum network_transport transport);
void sidethread_conn_close(conn *c);
/* Lock wrappers for cache functions that are called from main loop. */
enum delta_result_type add_delta(conn *c, const char *key,
const size_t nkey, const int incr,
const int64_t delta, char *buf,
uint64_t *cas);
void accept_new_conns(const bool do_accept);
conn *conn_from_freelist(void);
bool conn_add_to_freelist(conn *c);
void conn_close_idle(conn *c);
item *item_alloc(char *key, size_t nkey, int flags, rel_time_t exptime, int nbytes);
#define DO_UPDATE true
#define DONT_UPDATE false
item *item_get(const char *key, const size_t nkey, conn *c, const bool do_update);
item *item_touch(const char *key, const size_t nkey, uint32_t exptime, conn *c);
int item_link(item *it);
void item_remove(item *it);
int item_replace(item *it, item *new_it, const uint32_t hv);
void item_unlink(item *it);
void item_lock(uint32_t hv);
void *item_trylock(uint32_t hv);
void item_trylock_unlock(void *arg);
void item_unlock(uint32_t hv);
void pause_threads(enum pause_thread_types type);
#define refcount_incr(it) ++(it->refcount)
#define refcount_decr(it) --(it->refcount)
void STATS_LOCK(void);
void STATS_UNLOCK(void);
void threadlocal_stats_reset(void);
void threadlocal_stats_aggregate(struct thread_stats *stats);
void slab_stats_aggregate(struct thread_stats *stats, struct slab_stats *out);
/* Stat processing functions */
void append_stat(const char *name, ADD_STAT add_stats, conn *c,
const char *fmt, ...);
enum store_item_type store_item(item *item, int comm, conn *c);
#if HAVE_DROP_PRIVILEGES
extern void drop_privileges(void);
#else
#define drop_privileges()
#endif
#if HAVE_DROP_WORKER_PRIVILEGES
extern void drop_worker_privileges(void);
#else
#define drop_worker_privileges()
#endif
/* If supported, give compiler hints for branch prediction. */
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
#define __builtin_expect(x, expected_value) (x)
#endif
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
| 28,992 | 34.749692 | 175 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/crawler.h
|
#ifndef CRAWLER_H
#define CRAWLER_H
typedef struct {
uint64_t histo[61];
uint64_t ttl_hourplus;
uint64_t noexp;
uint64_t reclaimed;
uint64_t seen;
rel_time_t start_time;
rel_time_t end_time;
bool run_complete;
} crawlerstats_t;
struct crawler_expired_data {
pthread_mutex_t lock;
crawlerstats_t crawlerstats[POWER_LARGEST];
/* redundant with crawlerstats_t so we can get overall start/stop/done */
rel_time_t start_time;
rel_time_t end_time;
bool crawl_complete;
bool is_external; /* whether this was an alloc local or remote to the module. */
};
enum crawler_result_type {
CRAWLER_OK=0, CRAWLER_RUNNING, CRAWLER_BADCLASS, CRAWLER_NOTSTARTED, CRAWLER_ERROR
};
int start_item_crawler_thread(void);
int stop_item_crawler_thread(void);
int init_lru_crawler(void *arg);
enum crawler_result_type lru_crawler_crawl(char *slabs, enum crawler_run_type, void *c, const int sfd);
int lru_crawler_start(uint8_t *ids, uint32_t remaining,
const enum crawler_run_type type, void *data,
void *c, const int sfd);
void lru_crawler_pause(void);
void lru_crawler_resume(void);
#endif
| 1,191 | 29.564103 | 103 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/slab_automove.h
|
#ifndef SLAB_AUTOMOVE_H
#define SLAB_AUTOMOVE_H
/* default automove functions */
void *slab_automove_init(struct settings *settings);
void slab_automove_free(void *arg);
void slab_automove_run(void *arg, int *src, int *dst);
typedef void *(*slab_automove_init_func)(struct settings *settings);
typedef void (*slab_automove_free_func)(void *arg);
typedef void (*slab_automove_run_func)(void *arg, int *src, int *dst);
typedef struct {
slab_automove_init_func init;
slab_automove_free_func free;
slab_automove_run_func run;
} slab_automove_reg_t;
#endif
| 568 | 27.45 | 70 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/storage.h
|
#ifndef STORAGE_H
#define STORAGE_H
int lru_maintainer_store(void *storage, const int clsid);
int start_storage_compact_thread(void *arg);
void storage_compact_pause(void);
void storage_compact_resume(void);
#endif
| 217 | 20.8 | 57 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/stats.h
|
/* stats */
void stats_prefix_init(void);
void stats_prefix_clear(void);
void stats_prefix_record_get(const char *key, const size_t nkey, const bool is_hit);
void stats_prefix_record_delete(const char *key, const size_t nkey);
void stats_prefix_record_set(const char *key, const size_t nkey);
/*@null@*/
char *stats_prefix_dump(int *length);
| 342 | 37.111111 | 84 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/itoa_ljust.h
|
#ifndef ITOA_LJUST_H
#define ITOA_LJUST_H
//=== itoa_ljust.h - Fast integer to ascii conversion
//
// Fast and simple integer to ASCII conversion:
//
// - 32 and 64-bit integers
// - signed and unsigned
// - user supplied buffer must be large enough for all decimal digits
// in value plus minus sign if negative
// - left-justified
// - NUL terminated
// - return value is pointer to NUL terminator
//
// Copyright (c) 2016 Arturo Martin-de-Nicolas
// [email protected]
// https://github.com/amdn/itoa_ljust/
//===----------------------------------------------------------------------===//
#include <stdint.h>
char* itoa_u32(uint32_t u, char* buffer);
char* itoa_32( int32_t i, char* buffer);
char* itoa_u64(uint64_t u, char* buffer);
char* itoa_64( int64_t i, char* buffer);
#endif // ITOA_LJUST_H
| 822 | 27.37931 | 80 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/murmur3_hash.h
|
//-----------------------------------------------------------------------------
// MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
#ifndef MURMURHASH3_H
#define MURMURHASH3_H
//-----------------------------------------------------------------------------
// Platform-specific functions and macros
#include <stdint.h>
#include <stddef.h>
//-----------------------------------------------------------------------------
uint32_t MurmurHash3_x86_32(const void *key, size_t length);
//-----------------------------------------------------------------------------
#endif // MURMURHASH3_H
| 681 | 33.1 | 79 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/util.h
|
/* fast-enough functions for uriencoding strings. */
void uriencode_init(void);
bool uriencode(const char *src, char *dst, const size_t srclen, const size_t dstlen);
/*
* Wrappers around strtoull/strtoll that are safer and easier to
* use. For tests and assumptions, see internal_tests.c.
*
* str a NULL-terminated base decimal 10 unsigned integer
* out out parameter, if conversion succeeded
*
* returns true if conversion succeeded.
*/
bool safe_strtoull(const char *str, uint64_t *out);
bool safe_strtoll(const char *str, int64_t *out);
bool safe_strtoul(const char *str, uint32_t *out);
bool safe_strtol(const char *str, int32_t *out);
bool safe_strtod(const char *str, double *out);
#ifndef HAVE_HTONLL
extern uint64_t htonll(uint64_t);
extern uint64_t ntohll(uint64_t);
#endif
#ifdef __GCC
# define __gcc_attribute__ __attribute__
#else
# define __gcc_attribute__(x)
#endif
/**
* Vararg variant of perror that makes for more useful error messages
* when reporting with parameters.
*
* @param fmt a printf format
*/
void vperror(const char *fmt, ...)
__gcc_attribute__ ((format (printf, 1, 2)));
| 1,127 | 27.923077 | 85 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/protocol_binary.h
|
/*
* Copyright (c) <2008>, Sun Microsystems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY SUN MICROSYSTEMS, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Summary: Constants used by to implement the binary protocol.
*
* Copy: See Copyright for the status of this software.
*
* Author: Trond Norbye <[email protected]>
*/
#ifndef PROTOCOL_BINARY_H
#define PROTOCOL_BINARY_H
/**
* This file contains definitions of the constants and packet formats
* defined in the binary specification. Please note that you _MUST_ remember
* to convert each multibyte field to / from network byte order to / from
* host order.
*/
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Definition of the legal "magic" values used in a packet.
* See section 3.1 Magic byte
*/
typedef enum {
PROTOCOL_BINARY_REQ = 0x80,
PROTOCOL_BINARY_RES = 0x81
} protocol_binary_magic;
/**
* Definition of the valid response status numbers.
* See section 3.2 Response Status
*/
typedef enum {
PROTOCOL_BINARY_RESPONSE_SUCCESS = 0x00,
PROTOCOL_BINARY_RESPONSE_KEY_ENOENT = 0x01,
PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS = 0x02,
PROTOCOL_BINARY_RESPONSE_E2BIG = 0x03,
PROTOCOL_BINARY_RESPONSE_EINVAL = 0x04,
PROTOCOL_BINARY_RESPONSE_NOT_STORED = 0x05,
PROTOCOL_BINARY_RESPONSE_DELTA_BADVAL = 0x06,
PROTOCOL_BINARY_RESPONSE_AUTH_ERROR = 0x20,
PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE = 0x21,
PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND = 0x81,
PROTOCOL_BINARY_RESPONSE_ENOMEM = 0x82
} protocol_binary_response_status;
/**
* Definition of the different command opcodes.
* See section 3.3 Command Opcodes
*/
typedef enum {
PROTOCOL_BINARY_CMD_GET = 0x00,
PROTOCOL_BINARY_CMD_SET = 0x01,
PROTOCOL_BINARY_CMD_ADD = 0x02,
PROTOCOL_BINARY_CMD_REPLACE = 0x03,
PROTOCOL_BINARY_CMD_DELETE = 0x04,
PROTOCOL_BINARY_CMD_INCREMENT = 0x05,
PROTOCOL_BINARY_CMD_DECREMENT = 0x06,
PROTOCOL_BINARY_CMD_QUIT = 0x07,
PROTOCOL_BINARY_CMD_FLUSH = 0x08,
PROTOCOL_BINARY_CMD_GETQ = 0x09,
PROTOCOL_BINARY_CMD_NOOP = 0x0a,
PROTOCOL_BINARY_CMD_VERSION = 0x0b,
PROTOCOL_BINARY_CMD_GETK = 0x0c,
PROTOCOL_BINARY_CMD_GETKQ = 0x0d,
PROTOCOL_BINARY_CMD_APPEND = 0x0e,
PROTOCOL_BINARY_CMD_PREPEND = 0x0f,
PROTOCOL_BINARY_CMD_STAT = 0x10,
PROTOCOL_BINARY_CMD_SETQ = 0x11,
PROTOCOL_BINARY_CMD_ADDQ = 0x12,
PROTOCOL_BINARY_CMD_REPLACEQ = 0x13,
PROTOCOL_BINARY_CMD_DELETEQ = 0x14,
PROTOCOL_BINARY_CMD_INCREMENTQ = 0x15,
PROTOCOL_BINARY_CMD_DECREMENTQ = 0x16,
PROTOCOL_BINARY_CMD_QUITQ = 0x17,
PROTOCOL_BINARY_CMD_FLUSHQ = 0x18,
PROTOCOL_BINARY_CMD_APPENDQ = 0x19,
PROTOCOL_BINARY_CMD_PREPENDQ = 0x1a,
PROTOCOL_BINARY_CMD_TOUCH = 0x1c,
PROTOCOL_BINARY_CMD_GAT = 0x1d,
PROTOCOL_BINARY_CMD_GATQ = 0x1e,
PROTOCOL_BINARY_CMD_GATK = 0x23,
PROTOCOL_BINARY_CMD_GATKQ = 0x24,
PROTOCOL_BINARY_CMD_SASL_LIST_MECHS = 0x20,
PROTOCOL_BINARY_CMD_SASL_AUTH = 0x21,
PROTOCOL_BINARY_CMD_SASL_STEP = 0x22,
/* These commands are used for range operations and exist within
* this header for use in other projects. Range operations are
* not expected to be implemented in the memcached server itself.
*/
PROTOCOL_BINARY_CMD_RGET = 0x30,
PROTOCOL_BINARY_CMD_RSET = 0x31,
PROTOCOL_BINARY_CMD_RSETQ = 0x32,
PROTOCOL_BINARY_CMD_RAPPEND = 0x33,
PROTOCOL_BINARY_CMD_RAPPENDQ = 0x34,
PROTOCOL_BINARY_CMD_RPREPEND = 0x35,
PROTOCOL_BINARY_CMD_RPREPENDQ = 0x36,
PROTOCOL_BINARY_CMD_RDELETE = 0x37,
PROTOCOL_BINARY_CMD_RDELETEQ = 0x38,
PROTOCOL_BINARY_CMD_RINCR = 0x39,
PROTOCOL_BINARY_CMD_RINCRQ = 0x3a,
PROTOCOL_BINARY_CMD_RDECR = 0x3b,
PROTOCOL_BINARY_CMD_RDECRQ = 0x3c
/* End Range operations */
} protocol_binary_command;
/**
* Definition of the data types in the packet
* See section 3.4 Data Types
*/
typedef enum {
PROTOCOL_BINARY_RAW_BYTES = 0x00
} protocol_binary_datatypes;
/**
* Definition of the header structure for a request packet.
* See section 2
*/
typedef union {
struct {
uint8_t magic;
uint8_t opcode;
uint16_t keylen;
uint8_t extlen;
uint8_t datatype;
uint16_t reserved;
uint32_t bodylen;
uint32_t opaque;
uint64_t cas;
} request;
uint8_t bytes[24];
} protocol_binary_request_header;
/**
* Definition of the header structure for a response packet.
* See section 2
*/
typedef union {
struct {
uint8_t magic;
uint8_t opcode;
uint16_t keylen;
uint8_t extlen;
uint8_t datatype;
uint16_t status;
uint32_t bodylen;
uint32_t opaque;
uint64_t cas;
} response;
uint8_t bytes[24];
} protocol_binary_response_header;
/**
* Definition of a request-packet containing no extras
*/
typedef union {
struct {
protocol_binary_request_header header;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header)];
} protocol_binary_request_no_extras;
/**
* Definition of a response-packet containing no extras
*/
typedef union {
struct {
protocol_binary_response_header header;
} message;
uint8_t bytes[sizeof(protocol_binary_response_header)];
} protocol_binary_response_no_extras;
/**
* Definition of the packet used by the get, getq, getk and getkq command.
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_get;
typedef protocol_binary_request_no_extras protocol_binary_request_getq;
typedef protocol_binary_request_no_extras protocol_binary_request_getk;
typedef protocol_binary_request_no_extras protocol_binary_request_getkq;
/**
* Definition of the packet returned from a successful get, getq, getk and
* getkq.
* See section 4
*/
typedef union {
struct {
protocol_binary_response_header header;
struct {
uint32_t flags;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_response_header) + 4];
} protocol_binary_response_get;
typedef protocol_binary_response_get protocol_binary_response_getq;
typedef protocol_binary_response_get protocol_binary_response_getk;
typedef protocol_binary_response_get protocol_binary_response_getkq;
/**
* Definition of the packet used by the delete command
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_delete;
/**
* Definition of the packet returned by the delete command
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_delete;
/**
* Definition of the packet used by the flush command
* See section 4
* Please note that the expiration field is optional, so remember to see
* check the header.bodysize to see if it is present.
*/
typedef union {
struct {
protocol_binary_request_header header;
struct {
uint32_t expiration;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header) + 4];
} protocol_binary_request_flush;
/**
* Definition of the packet returned by the flush command
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_flush;
/**
* Definition of the packet used by set, add and replace
* See section 4
*/
typedef union {
struct {
protocol_binary_request_header header;
struct {
uint32_t flags;
uint32_t expiration;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header) + 8];
} protocol_binary_request_set;
typedef protocol_binary_request_set protocol_binary_request_add;
typedef protocol_binary_request_set protocol_binary_request_replace;
/**
* Definition of the packet returned by set, add and replace
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_set;
typedef protocol_binary_response_no_extras protocol_binary_response_add;
typedef protocol_binary_response_no_extras protocol_binary_response_replace;
/**
* Definition of the noop packet
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_noop;
/**
* Definition of the packet returned by the noop command
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_noop;
/**
* Definition of the structure used by the increment and decrement
* command.
* See section 4
*/
typedef union {
struct {
protocol_binary_request_header header;
struct {
uint64_t delta;
uint64_t initial;
uint32_t expiration;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header) + 20];
} protocol_binary_request_incr;
typedef protocol_binary_request_incr protocol_binary_request_decr;
/**
* Definition of the response from an incr or decr command
* command.
* See section 4
*/
typedef union {
struct {
protocol_binary_response_header header;
struct {
uint64_t value;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_response_header) + 8];
} protocol_binary_response_incr;
typedef protocol_binary_response_incr protocol_binary_response_decr;
/**
* Definition of the quit
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_quit;
/**
* Definition of the packet returned by the quit command
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_quit;
/**
* Definition of the packet used by append and prepend command
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_append;
typedef protocol_binary_request_no_extras protocol_binary_request_prepend;
/**
* Definition of the packet returned from a successful append or prepend
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_append;
typedef protocol_binary_response_no_extras protocol_binary_response_prepend;
/**
* Definition of the packet used by the version command
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_version;
/**
* Definition of the packet returned from a successful version command
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_version;
/**
* Definition of the packet used by the stats command.
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_stats;
/**
* Definition of the packet returned from a successful stats command
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_stats;
/**
* Definition of the packet used by the touch command.
*/
typedef union {
struct {
protocol_binary_request_header header;
struct {
uint32_t expiration;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header) + 4];
} protocol_binary_request_touch;
/**
* Definition of the packet returned from the touch command
*/
typedef protocol_binary_response_no_extras protocol_binary_response_touch;
/**
* Definition of the packet used by the GAT(Q) command.
*/
typedef union {
struct {
protocol_binary_request_header header;
struct {
uint32_t expiration;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header) + 4];
} protocol_binary_request_gat;
typedef protocol_binary_request_gat protocol_binary_request_gatq;
typedef protocol_binary_request_gat protocol_binary_request_gatk;
typedef protocol_binary_request_gat protocol_binary_request_gatkq;
/**
* Definition of the packet returned from the GAT(Q)
*/
typedef protocol_binary_response_get protocol_binary_response_gat;
typedef protocol_binary_response_get protocol_binary_response_gatq;
typedef protocol_binary_response_get protocol_binary_response_gatk;
typedef protocol_binary_response_get protocol_binary_response_gatkq;
/**
* Definition of a request for a range operation.
* See http://code.google.com/p/memcached/wiki/RangeOps
*
* These types are used for range operations and exist within
* this header for use in other projects. Range operations are
* not expected to be implemented in the memcached server itself.
*/
typedef union {
struct {
protocol_binary_response_header header;
struct {
uint16_t size;
uint8_t reserved;
uint8_t flags;
uint32_t max_results;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header) + 4];
} protocol_binary_request_rangeop;
typedef protocol_binary_request_rangeop protocol_binary_request_rget;
typedef protocol_binary_request_rangeop protocol_binary_request_rset;
typedef protocol_binary_request_rangeop protocol_binary_request_rsetq;
typedef protocol_binary_request_rangeop protocol_binary_request_rappend;
typedef protocol_binary_request_rangeop protocol_binary_request_rappendq;
typedef protocol_binary_request_rangeop protocol_binary_request_rprepend;
typedef protocol_binary_request_rangeop protocol_binary_request_rprependq;
typedef protocol_binary_request_rangeop protocol_binary_request_rdelete;
typedef protocol_binary_request_rangeop protocol_binary_request_rdeleteq;
typedef protocol_binary_request_rangeop protocol_binary_request_rincr;
typedef protocol_binary_request_rangeop protocol_binary_request_rincrq;
typedef protocol_binary_request_rangeop protocol_binary_request_rdecr;
typedef protocol_binary_request_rangeop protocol_binary_request_rdecrq;
#ifdef __cplusplus
}
#endif
#endif /* PROTOCOL_BINARY_H */
| 16,525 | 34.087049 | 80 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/items.h
|
/*
* Copyright 2018 Lenovo
*
* Licensed under the BSD-3 license. see LICENSE.Lenovo.txt for full text
*/
/*
* Note:
* Codes enclosed in `#ifdef PSLAB' and `#endif' are added by Lenovo for
* persistent memory support
*/
#define HOT_LRU 0
#define WARM_LRU 64
#define COLD_LRU 128
#define TEMP_LRU 192
#define CLEAR_LRU(id) (id & ~(3<<6))
#define GET_LRU(id) (id & (3<<6))
/* See items.c */
uint64_t get_cas_id(void);
/*@null@*/
item *do_item_alloc(char *key, const size_t nkey, const unsigned int flags, const rel_time_t exptime, const int nbytes);
item_chunk *do_item_alloc_chunk(item_chunk *ch, const size_t bytes_remain);
item *do_item_alloc_pull(const size_t ntotal, const unsigned int id);
void item_free(item *it);
bool item_size_ok(const size_t nkey, const int flags, const int nbytes);
int do_item_link(item *it, const uint32_t hv); /** may fail if transgresses limits */
#ifdef PSLAB
void do_item_relink(item *it, const uint32_t hv);
#endif
void do_item_unlink(item *it, const uint32_t hv);
void do_item_unlink_nolock(item *it, const uint32_t hv);
void do_item_remove(item *it);
void do_item_update(item *it); /** update LRU time to current and reposition */
void do_item_update_nolock(item *it);
int do_item_replace(item *it, item *new_it, const uint32_t hv);
int item_is_flushed(item *it);
void do_item_linktail_q(item *it);
void do_item_unlinktail_q(item *it);
item *do_item_crawl_q(item *it);
void *item_lru_bump_buf_create(void);
#define LRU_PULL_EVICT 1
#define LRU_PULL_CRAWL_BLOCKS 2
#define LRU_PULL_RETURN_ITEM 4 /* fill info struct if available */
struct lru_pull_tail_return {
item *it;
uint32_t hv;
};
int lru_pull_tail(const int orig_id, const int cur_lru,
const uint64_t total_bytes, const uint8_t flags, const rel_time_t max_age,
struct lru_pull_tail_return *ret_it);
/*@null@*/
char *item_cachedump(const unsigned int slabs_clsid, const unsigned int limit, unsigned int *bytes);
void item_stats(ADD_STAT add_stats, void *c);
void do_item_stats_add_crawl(const int i, const uint64_t reclaimed,
const uint64_t unfetched, const uint64_t checked);
void item_stats_totals(ADD_STAT add_stats, void *c);
/*@null@*/
void item_stats_sizes(ADD_STAT add_stats, void *c);
void item_stats_sizes_init(void);
void item_stats_sizes_enable(ADD_STAT add_stats, void *c);
void item_stats_sizes_disable(ADD_STAT add_stats, void *c);
void item_stats_sizes_add(item *it);
void item_stats_sizes_remove(item *it);
bool item_stats_sizes_status(void);
/* stats getter for slab automover */
typedef struct {
int64_t evicted;
int64_t outofmemory;
uint32_t age;
} item_stats_automove;
void fill_item_stats_automove(item_stats_automove *am);
item *do_item_get(const char *key, const size_t nkey, const uint32_t hv, conn *c, const bool do_update);
item *do_item_touch(const char *key, const size_t nkey, uint32_t exptime, const uint32_t hv, conn *c);
void item_stats_reset(void);
extern pthread_mutex_t lru_locks[POWER_LARGEST];
int start_lru_maintainer_thread(void *arg);
int stop_lru_maintainer_thread(void);
int init_lru_maintainer(void);
void lru_maintainer_pause(void);
void lru_maintainer_resume(void);
void *lru_bump_buf_create(void);
#ifdef EXTSTORE
#define STORAGE_delete(e, it) \
do { \
if (it->it_flags & ITEM_HDR) { \
item_hdr *hdr = (item_hdr *)ITEM_data(it); \
extstore_delete(e, hdr->page_id, hdr->page_version, \
1, ITEM_ntotal(it)); \
} \
} while (0)
#else
#define STORAGE_delete(...)
#endif
| 3,550 | 31.577982 | 120 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/trace.h
|
#ifndef TRACE_H
#define TRACE_H
#ifdef ENABLE_DTRACE
#include "memcached_dtrace.h"
#else
#define MEMCACHED_ASSOC_DELETE(arg0, arg1, arg2)
#define MEMCACHED_ASSOC_DELETE_ENABLED() (0)
#define MEMCACHED_ASSOC_FIND(arg0, arg1, arg2)
#define MEMCACHED_ASSOC_FIND_ENABLED() (0)
#define MEMCACHED_ASSOC_INSERT(arg0, arg1, arg2)
#define MEMCACHED_ASSOC_INSERT_ENABLED() (0)
#define MEMCACHED_COMMAND_ADD(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_ADD_ENABLED() (0)
#define MEMCACHED_COMMAND_APPEND(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_APPEND_ENABLED() (0)
#define MEMCACHED_COMMAND_CAS(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_CAS_ENABLED() (0)
#define MEMCACHED_COMMAND_DECR(arg0, arg1, arg2, arg3)
#define MEMCACHED_COMMAND_DECR_ENABLED() (0)
#define MEMCACHED_COMMAND_DELETE(arg0, arg1, arg2)
#define MEMCACHED_COMMAND_DELETE_ENABLED() (0)
#define MEMCACHED_COMMAND_GET(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_GET_ENABLED() (0)
#define MEMCACHED_COMMAND_TOUCH(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_TOUCH_ENABLED() (0)
#define MEMCACHED_COMMAND_INCR(arg0, arg1, arg2, arg3)
#define MEMCACHED_COMMAND_INCR_ENABLED() (0)
#define MEMCACHED_COMMAND_PREPEND(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_PREPEND_ENABLED() (0)
#define MEMCACHED_COMMAND_REPLACE(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_REPLACE_ENABLED() (0)
#define MEMCACHED_COMMAND_SET(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_SET_ENABLED() (0)
#define MEMCACHED_CONN_ALLOCATE(arg0)
#define MEMCACHED_CONN_ALLOCATE_ENABLED() (0)
#define MEMCACHED_CONN_CREATE(arg0)
#define MEMCACHED_CONN_CREATE_ENABLED() (0)
#define MEMCACHED_CONN_DESTROY(arg0)
#define MEMCACHED_CONN_DESTROY_ENABLED() (0)
#define MEMCACHED_CONN_DISPATCH(arg0, arg1)
#define MEMCACHED_CONN_DISPATCH_ENABLED() (0)
#define MEMCACHED_CONN_RELEASE(arg0)
#define MEMCACHED_CONN_RELEASE_ENABLED() (0)
#define MEMCACHED_ITEM_LINK(arg0, arg1, arg2)
#define MEMCACHED_ITEM_LINK_ENABLED() (0)
#define MEMCACHED_ITEM_REMOVE(arg0, arg1, arg2)
#define MEMCACHED_ITEM_REMOVE_ENABLED() (0)
#define MEMCACHED_ITEM_REPLACE(arg0, arg1, arg2, arg3, arg4, arg5)
#define MEMCACHED_ITEM_REPLACE_ENABLED() (0)
#define MEMCACHED_ITEM_UNLINK(arg0, arg1, arg2)
#define MEMCACHED_ITEM_UNLINK_ENABLED() (0)
#define MEMCACHED_ITEM_UPDATE(arg0, arg1, arg2)
#define MEMCACHED_ITEM_UPDATE_ENABLED() (0)
#define MEMCACHED_PROCESS_COMMAND_END(arg0, arg1, arg2)
#define MEMCACHED_PROCESS_COMMAND_END_ENABLED() (0)
#define MEMCACHED_PROCESS_COMMAND_START(arg0, arg1, arg2)
#define MEMCACHED_PROCESS_COMMAND_START_ENABLED() (0)
#define MEMCACHED_SLABS_ALLOCATE(arg0, arg1, arg2, arg3)
#define MEMCACHED_SLABS_ALLOCATE_ENABLED() (0)
#define MEMCACHED_SLABS_ALLOCATE_FAILED(arg0, arg1)
#define MEMCACHED_SLABS_ALLOCATE_FAILED_ENABLED() (0)
#define MEMCACHED_SLABS_FREE(arg0, arg1, arg2)
#define MEMCACHED_SLABS_FREE_ENABLED() (0)
#define MEMCACHED_SLABS_SLABCLASS_ALLOCATE(arg0)
#define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_ENABLED() (0)
#define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_FAILED(arg0)
#define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_FAILED_ENABLED() (0)
#endif
#endif
| 3,179 | 43.166667 | 66 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/jenkins_hash.h
|
#ifndef JENKINS_HASH_H
#define JENKINS_HASH_H
#ifdef __cplusplus
extern "C" {
#endif
uint32_t jenkins_hash(const void *key, size_t length);
#ifdef __cplusplus
}
#endif
#endif /* JENKINS_HASH_H */
| 213 | 12.375 | 54 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/cache.h
|
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#ifndef CACHE_H
#define CACHE_H
#include <pthread.h>
#ifdef HAVE_UMEM_H
#include <umem.h>
#define cache_t umem_cache_t
#define cache_alloc(a) umem_cache_alloc(a, UMEM_DEFAULT)
#define do_cache_alloc(a) umem_cache_alloc(a, UMEM_DEFAULT)
#define cache_free(a, b) umem_cache_free(a, b)
#define do_cache_free(a, b) umem_cache_free(a, b)
#define cache_create(a,b,c,d,e) umem_cache_create((char*)a, b, c, d, e, NULL, NULL, NULL, 0)
#define cache_destroy(a) umem_cache_destroy(a);
#else
#ifndef NDEBUG
/* may be used for debug purposes */
extern int cache_error;
#endif
/**
* Constructor used to initialize allocated objects
*
* @param obj pointer to the object to initialized.
* @param notused1 This parameter is currently not used.
* @param notused2 This parameter is currently not used.
* @return you should return 0, but currently this is not checked
*/
typedef int cache_constructor_t(void* obj, void* notused1, int notused2);
/**
* Destructor used to clean up allocated objects before they are
* returned to the operating system.
*
* @param obj pointer to the object to clean up.
* @param notused1 This parameter is currently not used.
* @param notused2 This parameter is currently not used.
* @return you should return 0, but currently this is not checked
*/
typedef void cache_destructor_t(void* obj, void* notused);
/**
* Definition of the structure to keep track of the internal details of
* the cache allocator. Touching any of these variables results in
* undefined behavior.
*/
typedef struct {
/** Mutex to protect access to the structure */
pthread_mutex_t mutex;
/** Name of the cache objects in this cache (provided by the caller) */
char *name;
/** List of pointers to available buffers in this cache */
void **ptr;
/** The size of each element in this cache */
size_t bufsize;
/** The capacity of the list of elements */
int freetotal;
/** The current number of free elements */
int freecurr;
/** The constructor to be called each time we allocate more memory */
cache_constructor_t* constructor;
/** The destructor to be called each time before we release memory */
cache_destructor_t* destructor;
} cache_t;
/**
* Create an object cache.
*
* The object cache will let you allocate objects of the same size. It is fully
* MT safe, so you may allocate objects from multiple threads without having to
* do any synchronization in the application code.
*
* @param name the name of the object cache. This name may be used for debug purposes
* and may help you track down what kind of object you have problems with
* (buffer overruns, leakage etc)
* @param bufsize the size of each object in the cache
* @param align the alignment requirements of the objects in the cache.
* @param constructor the function to be called to initialize memory when we need
* to allocate more memory from the os.
* @param destructor the function to be called before we release the memory back
* to the os.
* @return a handle to an object cache if successful, NULL otherwise.
*/
cache_t* cache_create(const char* name, size_t bufsize, size_t align,
cache_constructor_t* constructor,
cache_destructor_t* destructor);
/**
* Destroy an object cache.
*
* Destroy and invalidate an object cache. You should return all buffers allocated
* with cache_alloc by using cache_free before calling this function. Not doing
* so results in undefined behavior (the buffers may or may not be invalidated)
*
* @param handle the handle to the object cache to destroy.
*/
void cache_destroy(cache_t* handle);
/**
* Allocate an object from the cache.
*
* @param handle the handle to the object cache to allocate from
* @return a pointer to an initialized object from the cache, or NULL if
* the allocation cannot be satisfied.
*/
void* cache_alloc(cache_t* handle);
void* do_cache_alloc(cache_t* handle);
/**
* Return an object back to the cache.
*
* The caller should return the object in an initialized state so that
* the object may be returned in an expected state from cache_alloc.
*
* @param handle handle to the object cache to return the object to
* @param ptr pointer to the object to return.
*/
void cache_free(cache_t* handle, void* ptr);
void do_cache_free(cache_t* handle, void* ptr);
#endif
#endif
| 4,498 | 36.181818 | 92 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/bipbuffer.h
|
#ifndef BIPBUFFER_H
#define BIPBUFFER_H
typedef struct
{
unsigned long int size;
/* region A */
unsigned int a_start, a_end;
/* region B */
unsigned int b_end;
/* is B inuse? */
int b_inuse;
unsigned char data[];
} bipbuf_t;
/**
* Create a new bip buffer.
*
* malloc()s space
*
* @param[in] size The size of the buffer */
bipbuf_t *bipbuf_new(const unsigned int size);
/**
* Initialise a bip buffer. Use memory provided by user.
*
* No malloc()s are performed.
*
* @param[in] size The size of the array */
void bipbuf_init(bipbuf_t* me, const unsigned int size);
/**
* Free the bip buffer */
void bipbuf_free(bipbuf_t *me);
/* TODO: DOCUMENTATION */
unsigned char *bipbuf_request(bipbuf_t* me, const int size);
int bipbuf_push(bipbuf_t* me, const int size);
/**
* @param[in] data The data to be offered to the buffer
* @param[in] size The size of the data to be offered
* @return number of bytes offered */
int bipbuf_offer(bipbuf_t *me, const unsigned char *data, const int size);
/**
* Look at data. Don't move cursor
*
* @param[in] len The length of the data to be peeked
* @return data on success, NULL if we can't peek at this much data */
unsigned char *bipbuf_peek(const bipbuf_t* me, const unsigned int len);
/**
* Look at data. Don't move cursor
*
* @param[in] len The length of the data returned
* @return data on success, NULL if nothing available */
unsigned char *bipbuf_peek_all(const bipbuf_t* me, unsigned int *len);
/**
* Get pointer to data to read. Move the cursor on.
*
* @param[in] len The length of the data to be polled
* @return pointer to data, NULL if we can't poll this much data */
unsigned char *bipbuf_poll(bipbuf_t* me, const unsigned int size);
/**
* @return the size of the bipbuffer */
int bipbuf_size(const bipbuf_t* me);
/**
* @return 1 if buffer is empty; 0 otherwise */
int bipbuf_is_empty(const bipbuf_t* me);
/**
* @return how much space we have assigned */
int bipbuf_used(const bipbuf_t* cb);
/**
* @return bytes of unused space */
int bipbuf_unused(const bipbuf_t* me);
#endif /* BIPBUFFER_H */
| 2,118 | 23.079545 | 74 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/memcached-pmem-sd/hash.h
|
#ifndef HASH_H
#define HASH_H
typedef uint32_t (*hash_func)(const void *key, size_t length);
hash_func hash;
enum hashfunc_type {
JENKINS_HASH=0, MURMUR3_HASH
};
int hash_init(enum hashfunc_type type);
#endif /* HASH_H */
| 237 | 14.866667 | 62 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/TATP_SD/tatp_db.h
|
/*
Author: Vaibhav Gogte <[email protected]>
Aasheesh Kolli <[email protected]>
This file declares the TATP data base and the different transactions supported by
the database.
*/
#include <cstdint>
//#include <atomic>
#include <pthread.h>
#include "tableEntries.h"
#include "../include/txopt.h"
class TATP_DB{
private:
long total_subscribers; // Holds the number of subscribers
int num_threads;
subscriber_entry* subscriber_table; // Pointer to the subscriber table
access_info_entry* access_info_table; // Pointer to the access info table
special_facility_entry* special_facility_table; // Pointer to the special facility table
call_forwarding_entry* call_forwarding_table; // Pointer to the call forwarding table
pthread_mutex_t* lock_; // Lock per subscriber to protect the update
//std::atomic<long>** txCounts; // Array of tx counts, success and fails
unsigned long* subscriber_rndm_seeds;
unsigned long* vlr_rndm_seeds;
unsigned long* rndm_seeds;
public:
TATP_DB(unsigned num_subscribers); // Constructs and sizes tables as per num_subscribers
~TATP_DB();
void initialize(unsigned num_subscribers, int n);
void populate_tables(unsigned num_subscribers); // Populates the various tables
void fill_subscriber_entry(unsigned _s_id); // Fills subscriber table entry given subscriber id
void fill_access_info_entry(unsigned _s_id, short _ai_type); // Fills access info table entry given subscriber id and ai_type
void fill_special_facility_entry(unsigned _s_id, short _sf_type); // Fills special facility table entry given subscriber id and sf_type
void fill_call_forwarding_entry(unsigned _s_id, short _sf_type, short _start_time); // Fills call forwarding table entry given subscriber id, sf_type and start type
void convert_to_string(unsigned number, int num_digits, char* string_ptr);
void make_upper_case_string(char* string_ptr, int num_chars);
void update_subscriber_data(int threadId); // Tx: updates a random subscriber data
void update_location(int threadId, int num_ops); // Tx: updates location for a random subscriber
void insert_call_forwarding(int threadId); // Tx: Inserts into call forwarding table for a random user
void delete_call_forwarding(int threadId); // Tx: Deletes call forwarding for a random user
unsigned long get_random(int thread_id, int min, int max);
unsigned long get_random(int thread_id);
unsigned long get_random_s_id(int thread_id);
unsigned long get_random_vlr(int thread_id);
void print_results();
};
//DS for logging info to recover from a failed update_subscriber_data Tx
struct recovery_update_subscriber_data {
char txType; // will be '0'
unsigned s_id; // the subscriber id being updated
short sf_type; // the sf_type being modified
short bit_1; // the old bit_! value
short data_a; // the old data_a value
char padding[5];
};
struct recovery_update_location {
char txType; // will be '1'
unsigned s_id; // the subcriber whose location is being updated
unsigned vlr_location; // the old vlr location
char padding[7];
};
| 3,135 | 39.727273 | 168 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/TATP_SD/tatp_db.cc
|
/*
Author: Vaibhav Gogte <[email protected]>
Aasheesh Kolli <[email protected]>
This file defines the various transactions in TATP.
*/
#include "tatp_db.h"
#include <cstdlib> // For rand
#include <iostream>
#include <libpmem.h>
#include <sys/mman.h>
//#include <queue>
//#include <iostream>
#define NUM_RNDM_SEEDS 1280
subscriber_entry * subscriber_table_entry_backup;
uint64_t * subscriber_table_entry_backup_valid;
extern void * device;
static void setpage(void * addr){
uint64_t pageNo = ((uint64_t)addr)/4096;
unsigned long * pageStart = (unsigned long *)(pageNo*4096);
mprotect(pageStart, 4096, PROT_READ);
return;
}
extern void * checkpoint_start;
int getRand() {
return rand();
}
TATP_DB::TATP_DB(unsigned num_subscribers) {}
//Korakit
//this function is used in setup phase, no need to provide crash consistency
void TATP_DB::initialize(unsigned num_subscribers, int n) {
total_subscribers = num_subscribers;
num_threads = n;
size_t mapped_len;
int is_pmem;
void * pmemstart;
int totsize = num_subscribers*sizeof(subscriber_entry) + 4*num_subscribers*sizeof(access_info_entry) + 4*num_subscribers*sizeof(special_facility_entry) + 3*4*num_subscribers*sizeof(call_forwarding_entry) + NUM_RNDM_SEEDS*sizeof(unsigned long) + NUM_RNDM_SEEDS*sizeof(unsigned long) + NUM_RNDM_SEEDS*sizeof(unsigned long) + sizeof(subscriber_entry) + sizeof(uint64_t);
if ((pmemstart = pmem_map_file("/mnt/mem/tatp", totsize,
PMEM_FILE_CREATE, 0666, &mapped_len, &is_pmem)) == NULL) {
fprintf(stderr, "pmem_map_file failed\n");
exit(0);
}
if ((checkpoint_start = pmem_map_file("/mnt/mem/checkpoint", 4096*50,
PMEM_FILE_CREATE, 0666, &mapped_len, &is_pmem)) == NULL) {
fprintf(stderr, "pmem_map_file failed\n");
exit(0);
}
subscriber_table = (subscriber_entry*) pmemstart;
// A max of 4 access info entries per subscriber
access_info_table = (access_info_entry*) (pmemstart + num_subscribers*sizeof(subscriber_entry));
// A max of 4 access info entries per subscriber
special_facility_table = (special_facility_entry*) (pmemstart + num_subscribers*sizeof(subscriber_entry) + 4*num_subscribers*sizeof(access_info_entry));
// A max of 3 call forwarding entries per "special facility entry"
call_forwarding_table= (call_forwarding_entry*) (pmemstart + num_subscribers*sizeof(subscriber_entry) + 4*num_subscribers*sizeof(access_info_entry) + 4*num_subscribers*sizeof(special_facility_entry));
//Korakit
//removed for single thread version
/*
lock_ = (pthread_mutex_t *)malloc(n*sizeof(pthread_mutex_t));
for(int i=0; i<num_threads; i++) {
pthread_mutex_init(&lock_[i], NULL);
}
*/
for(int i=0; i<4*num_subscribers; i++) {
access_info_table[i].valid = false;
special_facility_table[i].valid = false;
for(int j=0; j<3; j++) {
call_forwarding_table[3*i+j].valid = false;
// printf("%d\n",j);
}
// printf("%d %d %d\n", i, 4*num_subscribers, totsize);
}
//printf("ab\n");
//rndm_seeds = new std::atomic<unsigned long>[NUM_RNDM_SEEDS];
//rndm_seeds = (std::atomic<unsigned long>*) malloc(NUM_RNDM_SEEDS*sizeof(std::atomic<unsigned long>));
subscriber_rndm_seeds = (unsigned long*) (pmemstart + num_subscribers*sizeof(subscriber_entry) + 4*num_subscribers*sizeof(access_info_entry) + 4*num_subscribers*sizeof(special_facility_entry) + 3*4*num_subscribers*sizeof(call_forwarding_entry));
vlr_rndm_seeds = (unsigned long*) (pmemstart + num_subscribers*sizeof(subscriber_entry) + 4*num_subscribers*sizeof(access_info_entry) + 4*num_subscribers*sizeof(special_facility_entry) + 3*4*num_subscribers*sizeof(call_forwarding_entry) + NUM_RNDM_SEEDS*sizeof(unsigned long));
rndm_seeds = (unsigned long*) (pmemstart + num_subscribers*sizeof(subscriber_entry) + 4*num_subscribers*sizeof(access_info_entry) + 4*num_subscribers*sizeof(special_facility_entry) + 3*4*num_subscribers*sizeof(call_forwarding_entry) + NUM_RNDM_SEEDS*sizeof(unsigned long) + NUM_RNDM_SEEDS*sizeof(unsigned long));
subscriber_table_entry_backup = (subscriber_entry*) (pmemstart + num_subscribers*sizeof(subscriber_entry) + 4*num_subscribers*sizeof(access_info_entry) + 4*num_subscribers*sizeof(special_facility_entry) + 3*4*num_subscribers*sizeof(call_forwarding_entry) + NUM_RNDM_SEEDS*sizeof(unsigned long) + NUM_RNDM_SEEDS*sizeof(unsigned long) + NUM_RNDM_SEEDS*sizeof(unsigned long));
subscriber_table_entry_backup_valid = (uint64_t*)(pmemstart + num_subscribers*sizeof(subscriber_entry) + 4*num_subscribers*sizeof(access_info_entry) + 4*num_subscribers*sizeof(special_facility_entry) + 3*4*num_subscribers*sizeof(call_forwarding_entry) + NUM_RNDM_SEEDS*sizeof(unsigned long) + NUM_RNDM_SEEDS*sizeof(unsigned long) + NUM_RNDM_SEEDS*sizeof(unsigned long) + sizeof(subscriber_entry) );
//sgetRand();
for(int i=0; i<NUM_RNDM_SEEDS; i++) {
subscriber_rndm_seeds[i] = getRand()%(NUM_RNDM_SEEDS*10)+1;
vlr_rndm_seeds[i] = getRand()%(NUM_RNDM_SEEDS*10)+1;
rndm_seeds[i] = getRand()%(NUM_RNDM_SEEDS*10)+1;
//std::cout<<i<<" "<<rndm_seeds[i]<<std::endl;
}
}
TATP_DB::~TATP_DB(){
free(subscriber_rndm_seeds);
free(vlr_rndm_seeds);
free(rndm_seeds);
}
//Korakit
//this function is used in setup phase, no need to provide crash consistency
void TATP_DB::populate_tables(unsigned num_subscribers) {
for(int i=0; i<num_subscribers; i++) {
fill_subscriber_entry(i);
int num_ai_types = getRand()%4 + 1; // num_ai_types varies from 1->4
for(int j=1; j<=num_ai_types; j++) {
fill_access_info_entry(i,j);
}
int num_sf_types = getRand()%4 + 1; // num_sf_types varies from 1->4
for(int k=1; k<=num_sf_types; k++) {
fill_special_facility_entry(i,k);
int num_call_forwards = getRand()%4; // num_call_forwards varies from 0->3
for(int p=0; p<num_call_forwards; p++) {
fill_call_forwarding_entry(i,k,8*p);
}
}
}
}
//Korakit
//this function is used in setup phase, no need to provide crash consistency
void TATP_DB::fill_subscriber_entry(unsigned _s_id) {
subscriber_table[_s_id].s_id = _s_id;
convert_to_string(_s_id, 15, subscriber_table[_s_id].sub_nbr);
subscriber_table[_s_id].bit_1 = (short) (getRand()%2);
subscriber_table[_s_id].bit_2 = (short) (getRand()%2);
subscriber_table[_s_id].bit_3 = (short) (getRand()%2);
subscriber_table[_s_id].bit_4 = (short) (getRand()%2);
subscriber_table[_s_id].bit_5 = (short) (getRand()%2);
subscriber_table[_s_id].bit_6 = (short) (getRand()%2);
subscriber_table[_s_id].bit_7 = (short) (getRand()%2);
subscriber_table[_s_id].bit_8 = (short) (getRand()%2);
subscriber_table[_s_id].bit_9 = (short) (getRand()%2);
subscriber_table[_s_id].bit_10 = (short) (getRand()%2);
subscriber_table[_s_id].hex_1 = (short) (getRand()%16);
subscriber_table[_s_id].hex_2 = (short) (getRand()%16);
subscriber_table[_s_id].hex_3 = (short) (getRand()%16);
subscriber_table[_s_id].hex_4 = (short) (getRand()%16);
subscriber_table[_s_id].hex_5 = (short) (getRand()%16);
subscriber_table[_s_id].hex_6 = (short) (getRand()%16);
subscriber_table[_s_id].hex_7 = (short) (getRand()%16);
subscriber_table[_s_id].hex_8 = (short) (getRand()%16);
subscriber_table[_s_id].hex_9 = (short) (getRand()%16);
subscriber_table[_s_id].hex_10 = (short) (getRand()%16);
subscriber_table[_s_id].byte2_1 = (short) (getRand()%256);
subscriber_table[_s_id].byte2_2 = (short) (getRand()%256);
subscriber_table[_s_id].byte2_3 = (short) (getRand()%256);
subscriber_table[_s_id].byte2_4 = (short) (getRand()%256);
subscriber_table[_s_id].byte2_5 = (short) (getRand()%256);
subscriber_table[_s_id].byte2_6 = (short) (getRand()%256);
subscriber_table[_s_id].byte2_7 = (short) (getRand()%256);
subscriber_table[_s_id].byte2_8 = (short) (getRand()%256);
subscriber_table[_s_id].byte2_9 = (short) (getRand()%256);
subscriber_table[_s_id].byte2_10 = (short) (getRand()%256);
subscriber_table[_s_id].msc_location = getRand()%(2^32 - 1) + 1;
subscriber_table[_s_id].vlr_location = getRand()%(2^32 - 1) + 1;
}
//Korakit
//this function is used in setup phase, no need to provide crash consistency
void TATP_DB::fill_access_info_entry(unsigned _s_id, short _ai_type) {
int tab_indx = 4*_s_id + _ai_type - 1;
access_info_table[tab_indx].s_id = _s_id;
access_info_table[tab_indx].ai_type = _ai_type;
access_info_table[tab_indx].data_1 = getRand()%256;
access_info_table[tab_indx].data_2 = getRand()%256;
make_upper_case_string(access_info_table[tab_indx].data_3, 3);
make_upper_case_string(access_info_table[tab_indx].data_4, 5);
access_info_table[tab_indx].valid = true;
}
//Korakit
//this function is used in setup phase, no need to provide crash consistency
void TATP_DB::fill_special_facility_entry(unsigned _s_id, short _sf_type) {
int tab_indx = 4*_s_id + _sf_type - 1;
special_facility_table[tab_indx].s_id = _s_id;
special_facility_table[tab_indx].sf_type = _sf_type;
special_facility_table[tab_indx].is_active = ((getRand()%100 < 85) ? 1 : 0);
special_facility_table[tab_indx].error_cntrl = getRand()%256;
special_facility_table[tab_indx].data_a = getRand()%256;
make_upper_case_string(special_facility_table[tab_indx].data_b, 5);
special_facility_table[tab_indx].valid = true;
}
//Korakit
//this function is used in setup phase, no need to provide crash consistency
void TATP_DB::fill_call_forwarding_entry(unsigned _s_id, short _sf_type, short _start_time) {
if(_start_time == 0)
return;
int tab_indx = 12*_s_id + 3*(_sf_type-1) + (_start_time-8)/8;
call_forwarding_table[tab_indx].s_id = _s_id;
call_forwarding_table[tab_indx].sf_type = _sf_type;
call_forwarding_table[tab_indx].start_time = _start_time - 8;
call_forwarding_table[tab_indx].end_time = (_start_time - 8) + getRand()%8 + 1;
convert_to_string(getRand()%1000, 15, call_forwarding_table[tab_indx].numberx);
}
void TATP_DB::convert_to_string(unsigned number, int num_digits, char* string_ptr) {
char digits[10] = {'0','1','2','3','4','5','6','7','8','9'};
int quotient = number;
int reminder = 0;
int num_digits_converted=0;
int divider = 1;
while((quotient != 0) && (num_digits_converted<num_digits)) {
divider = 10^(num_digits_converted+1);
reminder = quotient%divider; quotient = quotient/divider;
string_ptr[num_digits-1 - num_digits_converted] = digits[reminder];
num_digits_converted++;
}
if(num_digits_converted < num_digits) {
string_ptr[num_digits-1 - num_digits_converted] = digits[0];
num_digits_converted++;
}
return;
}
void TATP_DB::make_upper_case_string(char* string_ptr, int num_chars) {
char alphabets[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N',
'O','P','Q','R','S','T','U','V','W','X','Y','Z'};
for(int i=0; i<num_chars; i++) {
string_ptr[i] = alphabets[getRand()%26];
}
return;
}
void TATP_DB::update_subscriber_data(int threadId) {
unsigned rndm_s_id = getRand() % total_subscribers;
short rndm_sf_type = getRand() % 4 + 1;
unsigned special_facility_tab_indx = 4*rndm_s_id + rndm_sf_type -1;
if(special_facility_table[special_facility_tab_indx].valid) {
//FIXME: There is a potential data race here, do not use this function yet
//Korakit
//removed for single thread version
//pthread_mutex_lock(&lock_[rndm_s_id]);
subscriber_table[rndm_s_id].bit_1 = getRand()%2;
special_facility_table[special_facility_tab_indx].data_a = getRand()%256;
//Korakit
//removed for single thread version
//pthread_mutex_unlock(&lock_[rndm_s_id]);
}
return;
}
//subscriber_entry subscriber_table_entry_backup;
//uint64_t subscriber_table_entry_backup_valid;
void TATP_DB::update_location(int threadId, int num_ops) {
long rndm_s_id;
rndm_s_id = get_random_s_id(threadId)-1;
rndm_s_id /=total_subscribers;
//Korakit
//removed for single thread version
//pthread_mutex_lock(&lock_[rndm_s_id]);
//create backup
//*subscriber_table_entry_backup = subscriber_table[rndm_s_id];
//move_data(&subscriber_table_entry_backup, &subscriber_table[rndm_s_id],sizeof(subscriber_table_entry_backup));
//s_fence();
//*subscriber_table_entry_backup_valid = 1;
//s_fence();
setpage(&subscriber_table[rndm_s_id].vlr_location);
subscriber_table[rndm_s_id].vlr_location = get_random_vlr(threadId);
pmem_persist(&subscriber_table[rndm_s_id], sizeof(subscriber_table[rndm_s_id]));
//*subscriber_table_entry_backup_valid = 0;
//s_fence();
//Korakit
//removed for single thread version
//pthread_mutex_unlock(&lock_[rndm_s_id]);
return;
}
void TATP_DB::insert_call_forwarding(int threadId) {
return;
}
void TATP_DB::delete_call_forwarding(int threadId) {
return;
}
void TATP_DB::print_results() {
//std::cout<<"TxType:0 successful txs = "<<txCounts[0][0]<<std::endl;
//std::cout<<"TxType:0 failed txs = "<<txCounts[0][1]<<std::endl;
//std::cout<<"TxType:1 successful txs = "<<txCounts[1][0]<<std::endl;
//std::cout<<"TxType:1 failed txs = "<<txCounts[1][1]<<std::endl;
//std::cout<<"TxType:2 successful txs = "<<txCounts[2][0]<<std::endl;
//std::cout<<"TxType:2 failed txs = "<<txCounts[2][1]<<std::endl;
//std::cout<<"TxType:3 successful txs = "<<txCounts[3][0]<<std::endl;
//std::cout<<"TxType:3 failed txs = "<<txCounts[3][1]<<std::endl;
}
unsigned long TATP_DB::get_random(int thread_id) {
//return (getRand()%65536 | min + getRand()%(max - min + 1)) % (max - min + 1) + min;
unsigned long tmp;
tmp = rndm_seeds[thread_id*10] = (rndm_seeds[thread_id*10] * 16807) % 2147483647;
return tmp;
}
unsigned long TATP_DB::get_random(int thread_id, int min, int max) {
//return (getRand()%65536 | min + getRand()%(max - min + 1)) % (max - min + 1) + min;
unsigned long tmp;
tmp = rndm_seeds[thread_id*10] = (rndm_seeds[thread_id*10] * 16807) % 2147483647;
return (min+tmp%(max-min+1));
}
unsigned long TATP_DB::get_random_s_id(int thread_id) {
unsigned long tmp;
tmp = subscriber_rndm_seeds[thread_id*10] = (subscriber_rndm_seeds[thread_id*10] * 16807) % 2147483647;
return (1 + tmp%(total_subscribers));
}
unsigned long TATP_DB::get_random_vlr(int thread_id) {
unsigned long tmp;
tmp = vlr_rndm_seeds[thread_id*10] = (vlr_rndm_seeds[thread_id*10] * 16807)%2147483647;
return (1 + tmp%(2^32));
}
| 14,363 | 39.235294 | 402 |
cc
|
null |
NearPMSW-main/nearpmMDsync/shadow/TATP_SD/run.sh
|
#!/usr/bin/env bash
sudo rm -rf /mnt/mem/*
sudo ./tatp_nvm > out
tot=$(grep "tottime" out)
grep "cp" out > time
cp=$(awk '{sum+= $2;} END{print sum;}' time)
echo $1$tot
echo $1'cp' $cp
| 187 | 16.090909 | 44 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/TATP_SD/tatp_nvm.cc
|
/*
Author: Vaibhav Gogte <[email protected]>
Aasheesh Kolli <[email protected]>
This file is the TATP benchmark, performs various transactions as per the specifications.
*/
#include "tatp_db.h"
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <cstdint>
#include <assert.h>
#include <sys/time.h>
#include <string>
#include <fstream>
#include <libpmem.h>
#include <cstring>
//Korakit
//might need to change parameters
#define NUM_SUBSCRIBERS 100000 //100000
#define NUM_OPS_PER_CS 2
#define NUM_OPS 30000 //10000000
#define NUM_THREADS 1
TATP_DB* my_tatp_db;
//#include "../DCT/rdtsc.h"
void init_db() {
unsigned num_subscribers = NUM_SUBSCRIBERS;
my_tatp_db = (TATP_DB *)malloc(sizeof(TATP_DB));
my_tatp_db->initialize(num_subscribers,NUM_THREADS);
fprintf(stderr, "Created tatp db at %p\n", (void *)my_tatp_db);
}
void* update_locations(void* args) {
int thread_id = *((int*)args);
for(int i=0; i<NUM_OPS/NUM_THREADS; i++) {
my_tatp_db->update_location(thread_id,NUM_OPS_PER_CS);
}
return 0;
}
/////////////////Page fault handling/////////////////
#include <bits/types/sig_atomic_t.h>
#include <bits/types/sigset_t.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#define SIGSTKSZ 8192
#define SA_SIGINFO 4
#define SA_ONSTACK 0x08000000 /* Use signal stack by using `sa_restorer'. */
#define SA_RESTART 0x10000000 /* Restart syscall on signal return. */
#define SA_NODEFER 0x40000000 /* Don't automatically block the signal when*/
stack_t _sigstk;
int updated_page_count = 0;
int all_updates = 0;
void * checkpoint_start;
void * page[50];
void * device;
double totTimeCP = 0;
static inline uint64_t getCycle(){
uint32_t cycles_high, cycles_low, pid;
asm volatile ("RDTSCP\n\t" // rdtscp into eax and edx
"mov %%edx, %0\n\t"
"mov %%eax, %1\n\t"
"mov %%ecx, %2\n\t"
:"=r" (cycles_high), "=r" (cycles_low), "=r" (pid) //store in vars
:// no input
:"%eax", "%edx", "%ecx" // clobbered by rdtscp
);
return((uint64_t)cycles_high << 32) | cycles_low;
}
#define GRANULARITY 2048
void cmd_issue( uint32_t opcode,
uint32_t TXID,
uint32_t TID,
uint32_t OID,
uint64_t data_addr,
uint32_t data_size,
void * ptr){
//command with thread id encoded as first 8 bits of each word
uint32_t issue_cmd[7];
issue_cmd[0] = (TID<<24)|(opcode<<16)|(TXID<<8)|TID;
issue_cmd[1] = (TID<<24)|(OID<<16)|(data_addr>>48);
issue_cmd[2] = (TID<<24)|((data_addr & 0x0000FFFFFFFFFFFF)>>24);
issue_cmd[3] = (TID<<24)|(data_addr & 0x0000000000FFFFFF);
issue_cmd[4] = (TID<<24)|(data_size<<8);
issue_cmd[5] = (TID<<24)|(0X00FFFFFF>>16);
issue_cmd[6] = (TID<<24)|((0X00FFFFFF & 0x0000FFFF)<<8);
for(int i=0;i<7;i++){
// printf("%08x\n",issue_cmd[i]);
*((u_int32_t *) ptr) = issue_cmd[i];
}
}
static void segvHandle(int signum, siginfo_t * siginfo, void * context) {
#define CPTIME
#ifdef CPTIME
uint64_t endCycles, startCycles,totalCycles;
startCycles = getCycle();
#endif
void * addr = siginfo->si_addr; // address of access
uint64_t pageNo = ((uint64_t)addr)/4096;
unsigned long * pageStart = (unsigned long *)(pageNo*4096);
// Check if this was a SEGV that we are supposed to trap.
if (siginfo->si_code == SEGV_ACCERR) {
mprotect(pageStart, 4096, PROT_READ|PROT_WRITE);
if(all_updates >=0 || updated_page_count == 50){
for(int i=0;i<updated_page_count;i++){
//memcpy(checkpoint_start + 4096, pageStart, 4096);
//pmem_persist(checkpoint_start + 4096, 4096);
cmd_issue(2,0,0,0, (uint64_t)pageStart,4096,device);
/* *((uint64_t*)device) = (uint64_t)(checkpoint_start + 4096);
*((uint64_t*)(device)+1) = 00;
*((uint64_t*)(device)+2) = (uint64_t)0.320580;
*((uint64_t*)(device)+3) = ((uint64_t)(((0) << 16)| 6) << 32) | 4096;
*(((uint32_t*)(device))+255) = (uint32_t)(((0) << 16)| 6);
*/
page[updated_page_count] = 0;
}
updated_page_count = 0;
all_updates = 0;
}
all_updates ++;
for(int i=0; i<updated_page_count; i++){
if(page[i] == pageStart){
#ifdef CPTIME
endCycles = getCycle();
totalCycles = endCycles - startCycles;
double totTime = ((double)totalCycles)/2000000000;
printf("cp %f\n", totTime);
#endif
return;}
}
page[updated_page_count] = pageStart;
//printf("test1 %lx %d %d\n",page[updated_page_count],updated_page_count,all_updates);
updated_page_count++;
#ifdef CPTIME
endCycles = getCycle();
totalCycles = endCycles - startCycles;
double totTime = ((double)totalCycles)/2000000000;
printf("cp %f\n", totTime);
#endif
//*((int *)checkpoint_start) = 10;
//test++;
//printf("test1 %lx %d\n",updated_page_count);
} else if (siginfo->si_code == SEGV_MAPERR) {
fprintf (stderr, "%d : map error with addr %p!\n", getpid(), addr);
abort();
} else {
fprintf (stderr, "%d : other access error with addr %p.\n", getpid(), addr);
abort();
}
}
static void installSignalHandler(void) {
// Set up an alternate signal stack.
printf("page fault handler initialized!!\n");
_sigstk.ss_sp = mmap(NULL, SIGSTKSZ, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
_sigstk.ss_size = SIGSTKSZ;
_sigstk.ss_flags = 0;
sigaltstack(&_sigstk, (stack_t *) 0);
// Now set up a signal handler for SIGSEGV events.
struct sigaction siga;
sigemptyset(&siga.sa_mask);
// Set the following signals to a set
sigaddset(&siga.sa_mask, SIGSEGV);
sigaddset(&siga.sa_mask, SIGALRM);
sigprocmask(SIG_BLOCK, &siga.sa_mask, NULL);
// Point to the handler function.
siga.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_RESTART | SA_NODEFER;
siga.sa_sigaction = segvHandle;
if (sigaction(SIGSEGV, &siga, NULL) == -1) {
perror("sigaction(SIGSEGV)");
exit(-1);
}
sigprocmask(SIG_UNBLOCK, &siga.sa_mask, NULL);
return;
}
void* open_device(const char* pathname)
{
//int fd = os_open("/sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/devices/0000:0a:00.0/resource0",O_RDWR|O_SYNC);
int fd = open(pathname,O_RDWR|O_SYNC);
if(fd == -1)
{
printf("Couldnt opene file!!\n");
exit(0);
}
void * ptr = mmap(0,4096,PROT_READ|PROT_WRITE, MAP_SHARED,fd,0);
if(ptr == (void *)-1)
{
printf("Could not map memory!!\n");
exit(0);
}
printf("opened device without error!!\n");
return ptr;
}
///////////////////////////////////////////////////////////////////
void installSignalHandler (void) __attribute__ ((constructor));
int main(int argc, char* argv[]) {
//printf("in main\n");
//struct timeval tv_start;
//struct timeval tv_end;
//std::ofstream fexec;
//fexec.open("exec.csv",std::ios_base::app);
// Korakit: move to the init
// LIU
device = open_device("/sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/devices/0000:0a:00.0/resource0");
uint64_t* tmp = (uint64_t*)device;
*tmp = 0xdeadbeefdeadbeef;
pmem_persist(tmp,64);
*tmp = (uint64_t)tmp;
pmem_persist(tmp,64);
uint32_t tid;
tid = 0;//gettid();
tid = tid & 0x3f;
tid = (tid<< 4)| 0;//pop->run_id;
//printf("%d %d\n",tid, pop->run_id);
*tmp = tid;
pmem_persist(tmp,64);
init_db();
// LIU: remove output
//std::cout<<"done with initialization"<<std::endl;
my_tatp_db->populate_tables(NUM_SUBSCRIBERS);
// LIU: remove output
//std::cout<<"done with populating tables"<<std::endl;
pthread_t threads[NUM_THREADS];
int id[NUM_THREADS];
//Korakit
//exit to count instructions after initialization
//we use memory trace from the beginning to this to test the compression ratio
//as update locations(the actual test) only do one update
// LIU
// gettimeofday(&tv_start, NULL);
//CounterAtomic::initCounterCache();
uint64_t endCycles, startCycles,totalCycles;
startCycles = getCycle();
for(int i=0; i<NUM_THREADS; i++) {
id[i] = i;
update_locations((void*)&id[i]);
}
endCycles = getCycle();
totalCycles = endCycles - startCycles;
double totTime = ((double)totalCycles)/2000000000;
printf("tottime %f\ndata movement time %f\n", totTime, totTimeCP);
//Korakit
//Not necessary for single threaded version
/*
for(int i=0; i<NUM_THREADS; i++) {
pthread_join(threads[i], NULL);
}
*/
// LIU: remove the output
/*
gettimeofday(&tv_end, NULL);
fprintf(stderr, "time elapsed %ld us\n",
tv_end.tv_usec - tv_start.tv_usec +
(tv_end.tv_sec - tv_start.tv_sec) * 1000000);
fexec << "TATP" << ", " << std::to_string((tv_end.tv_usec - tv_start.tv_usec) + (tv_end.tv_sec - tv_start.tv_sec) * 1000000) << std::endl;
fexec.close();
free(my_tatp_db);
std::cout<<"done with threads"<<std::endl;
*/
return 0;
}
| 8,797 | 25.5 | 140 |
cc
|
null |
NearPMSW-main/nearpmMDsync/shadow/TATP_SD/tableEntries.h
|
/*
Author: Vaibhav Gogte <[email protected]>
Aasheesh Kolli <[email protected]>
This file defines the table entries used by TATP.
*/
struct subscriber_entry {
unsigned s_id; // Subscriber id
char sub_nbr[15]; // Subscriber number, s_id in 15 digit string, zeros padded
short bit_1, bit_2, bit_3, bit_4, bit_5, bit_6, bit_7, bit_8, bit_9, bit_10; // randomly generated values 0/1
short hex_1, hex_2, hex_3, hex_4, hex_5, hex_6, hex_7, hex_8, hex_9, hex_10; // randomly generated values 0->15
short byte2_1, byte2_2, byte2_3, byte2_4, byte2_5, byte2_6, byte2_7, byte2_8, byte2_9, byte2_10; // randomly generated values 0->255
unsigned msc_location; // Randomly generated value 1->((2^32)-1)
unsigned vlr_location; // Randomly generated value 1->((2^32)-1)
char padding[40];
};
struct access_info_entry {
unsigned s_id; //Subscriber id
short ai_type; // Random value 1->4. A subscriber can have a max of 4 and all unique
short data_1, data_2; // Randomly generated values 0->255
char data_3[3]; // random 3 char string. All upper case alphabets
char data_4[5]; // random 5 char string. All upper case alphabets
bool valid;
bool padding_1[7];
char padding_2[4+32];
};
struct special_facility_entry {
unsigned s_id; //Subscriber id
short sf_type; // Random value 1->4. A subscriber can have a max of 4 and all unique
short is_active; // 0(15%)/1(85%)
short error_cntrl; // Randomly generated values 0->255
short data_a; // Randomly generated values 0->255
char data_b[5]; // random 5 char string. All upper case alphabets
char padding_1[7];
bool valid;
bool padding_2[4+32];
};
struct call_forwarding_entry {
unsigned s_id; // Subscriber id from special facility
short sf_type; // sf_type from special facility table
int start_time; // 0 or 8 or 16
int end_time; // start_time+N, N randomly generated 1->8
char numberx[15]; // randomly generated 15 digit string
char padding_1[7];
bool valid;
bool padding_2[24];
};
| 1,993 | 35.254545 | 134 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/TPCC_SD/tpcc_db.h
|
/*
Author: Vaibhav Gogte <[email protected]>
Aasheesh Kolli <[email protected]>
This file declares the tpcc database and the accesor transactions.
*/
#include "table_entries.h"
#include <atomic>
#include "simple_queue.h"
#include <pthread.h>
#include <cstdlib>
#include "../include/txopt.h"
typedef simple_queue queue_t;
struct backUpLog{
struct district_entry district_back;
//fill_new_order_entry
struct new_order_entry new_order_entry_back;
//update_order_entry
struct order_entry order_entry_back;
//update_stock_entry
struct stock_entry stock_entry_back[15];
int fill_new_order_entry_indx = 0;
int update_order_entry_indx = 0;
int update_stock_entry_indx[16];
uint64_t district_back_valid;
uint64_t fill_new_order_entry_back_valid;
uint64_t update_order_entry_back_valid;
uint64_t update_stock_entry_num_valid;
//global log valid
uint64_t log_valid;
};
class TPCC_DB {
private:
// Tables with size dependent on num warehouses
short num_warehouses;
short random_3000[3000];
warehouse_entry* warehouse;
district_entry* district;
customer_entry* customer;
stock_entry* stock;
// Tables with slight variation in sizes (due to inserts/deletes etc.)
history_entry* history;
order_entry* order;
new_order_entry* new_order;
order_line_entry* order_line;
// Fixed size table
item_entry* item;
unsigned long* rndm_seeds;
queue_t* perTxLocks; // Array of queues of locks held by active Tx
pthread_mutex_t* locks; // Array of locks held by the TxEngn. RDSs acquire locks through the TxEngn
unsigned g_seed;
public:
struct backUpLog * backUpInst;
TPCC_DB();
~TPCC_DB();
void initialize(int _num_warehouses, int numThreads);
void populate_tables();
void fill_item_entry(int _i_id);
void fill_warehouse_entry(int _w_id);
void fill_stock_entry(int _s_w_id, int s_i_id);
void fill_district_entry(int _d_w_id, int _d_id);
void fill_customer_entry(int _c_w_id, int _c_d_id, int _c_id);
void fill_history_entry(int _h_c_w_id, int _h_c_d_id, int _h_c_id);
void fill_order_entry(int _o_w_id, int _o_d_id, int _o_id);
void fill_order_line_entry(int _ol_w_id, int _ol_d_id, int _ol_o_id, int _o_ol_cnt, long long _o_entry_d);
void fill_new_order_entry(int _no_w_id, int _no_d_id, int _no_o_id, int threadId);
void random_a_string(int min, int max, char* string_ptr);
void random_n_string(int min, int max, char* string_ptr);
void random_a_original_string(int min, int max, int probability, char* string_ptr);
void random_zip(char* string_ptr);
void fill_time(long long &time_slot);
int rand_local(int min, int max);
void new_order_tx(int threadId, int w_id, int d_id, int c_id);
void copy_district_info(district_entry &dest, district_entry &source);
void copy_customer_info(customer_entry &dest, customer_entry &source);
void copy_new_order_info(new_order_entry &dest, new_order_entry &source);
void copy_order_info(order_entry &dest, order_entry &source);
void copy_stock_info(stock_entry &dest, stock_entry &source);
void copy_order_line_info(order_line_entry &dest, order_line_entry &source);
void update_order_entry(int _w_id, short _d_id, int _o_id, int _c_id, int _ol_cnt, int threadId);
void update_stock_entry(int threadId, int _w_id, int _i_id, int _d_id, float &amount, int itr);
unsigned long get_random(int thread_id, int min, int max);
unsigned long get_random(int thread_id);
void printStackPointer(int* sp, int thread_id);
void acquire_locks(int thread_id, queue_t &reqLocks);
void release_locks(int thread_id);
unsigned fastrand();
};
| 3,755 | 30.041322 | 110 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/TPCC_SD/tpcc_nvm.cc
|
/*
Author: Vaibhav Gogte <[email protected]>
Aasheesh Kolli <[email protected]>
This file models the TPCC benchmark.
*/
//Korakit
//remove MT stuffs
//#include <pthread.h>
#include <memkind.h>
#include <dlfcn.h>
#include <iostream>
#include <vector>
#include <sys/time.h>
#include <string>
#include <fstream>
#include <cstring>
//#include "txopt.h"
#include <libpmem.h>
#include "tpcc_db.h"
#include "../include/txopt.h"
#define NUM_ORDERS 1000 //10000000
#define NUM_THREADS 1
#define NUM_WAREHOUSES 1
#define NUM_ITEMS 10000//10000
#define NUM_LOCKS NUM_WAREHOUSES*10 + NUM_WAREHOUSES*NUM_ITEMS
TPCC_DB* tpcc_db[NUM_THREADS];
static inline uint64_t getCycle(){
uint32_t cycles_high, cycles_low, pid;
asm volatile ("RDTSCP\n\t" // rdtscp into eax and edx
"mov %%edx, %0\n\t"
"mov %%eax, %1\n\t"
"mov %%ecx, %2\n\t"
:"=r" (cycles_high), "=r" (cycles_low), "=r" (pid) //store in vars
:// no input
:"%eax", "%edx", "%ecx" // clobbered by rdtscp
);
return((uint64_t)cycles_high << 32) | cycles_low;
}
void initialize(int tid, void * backUpLog) {
tpcc_db[tid] = (TPCC_DB *)malloc(sizeof(TPCC_DB));
tpcc_db[tid]->backUpInst = (struct backUpLog *)backUpLog;
new(tpcc_db[tid]) TPCC_DB();
tpcc_db[tid]->initialize(NUM_WAREHOUSES, NUM_THREADS);
// fprintf(stderr, "Created tpcc at %p\n", (void *)tpcc_db[tid]);
}
//void new_orders(TxEngine* tx_engine, int tx_engn_type, TPCC_DB* tpcc_db, int thread_id, int num_orders, int num_threads, int num_strands_per_thread, std::atomic<bool>*wait) {
void* new_orders(void* arguments) {
int thread_id = *((int*)arguments);
// fprintf(stdout, "New order, thread: %d\n", thread_id);
for(int i=0; i<NUM_ORDERS/NUM_THREADS; i++) {
int w_id = 1;
//There can only be 10 districts, this controls the number of locks in tpcc_db, which is why NUM_LOCKS = warehouse*10
int d_id = tpcc_db[thread_id]->get_random(thread_id, 1, 10);
int c_id = tpcc_db[thread_id]->get_random(thread_id, 1, 3000);
// fprintf(stdout, "thread: %d, line: %d\n", thread_id, __LINE__);
tpcc_db[thread_id]->new_order_tx(thread_id, w_id, d_id, c_id);
// fprintf(stdout, "thread: %d, #%d\n", thread_id, i);
}
// fprintf(stdout, "thread: %d\n", thread_id);
// return 0;
}
/////////////////Page fault handling/////////////////
#include <bits/types/sig_atomic_t.h>
#include <bits/types/sigset_t.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#define SIGSTKSZ 8192
#define SA_SIGINFO 4
#define SA_ONSTACK 0x08000000 /* Use signal stack by using `sa_restorer'. */
#define SA_RESTART 0x10000000 /* Restart syscall on signal return. */
#define SA_NODEFER 0x40000000 /* Don't automatically block the signal when*/
stack_t _sigstk;
int updated_page_count = 0;
int all_updates = 0;
void * checkpoint_start;
void * page[50];
void * device;
double totTimeShadow = 0;
#define GRANULARITY 2048
void cmd_issue( uint32_t opcode,
uint32_t TXID,
uint32_t TID,
uint32_t OID,
uint64_t data_addr,
uint32_t data_size,
void * ptr){
//command with thread id encoded as first 8 bits of each word
uint32_t issue_cmd[7];
issue_cmd[0] = (TID<<24)|(opcode<<16)|(TXID<<8)|TID;
issue_cmd[1] = (TID<<24)|(OID<<16)|(data_addr>>48);
issue_cmd[2] = (TID<<24)|((data_addr & 0x0000FFFFFFFFFFFF)>>24);
issue_cmd[3] = (TID<<24)|(data_addr & 0x0000000000FFFFFF);
issue_cmd[4] = (TID<<24)|(data_size<<8);
issue_cmd[5] = (TID<<24)|(0X00FFFFFF>>16);
issue_cmd[6] = (TID<<24)|((0X00FFFFFF & 0x0000FFFF)<<8);
for(int i=0;i<7;i++){
// printf("%08x\n",issue_cmd[i]);
*((u_int32_t *) ptr) = issue_cmd[i];
}
}
static void segvHandle(int signum, siginfo_t * siginfo, void * context) {
#define CPTIME
#ifdef CPTIME
uint64_t endCycles, startCycles,totalCycles;
startCycles = getCycle();
#endif
void * addr = siginfo->si_addr; // address of access
uint64_t pageNo = ((uint64_t)addr)/4096;
unsigned long * pageStart = (unsigned long *)(pageNo*4096);
// Check if this was a SEGV that we are supposed to trap.
if (siginfo->si_code == SEGV_ACCERR) {
mprotect(pageStart, 4096, PROT_READ|PROT_WRITE);
if(all_updates >=0 || updated_page_count == 50){
for(int i=0;i<updated_page_count;i++){
//memcpy(checkpoint_start + 4096, pageStart, 4096);
//pmem_persist(checkpoint_start + 4096, 4096);
cmd_issue(2,0,0,0, (uint64_t)pageStart,4096,device);
/* *((uint64_t*)device) = (uint64_t)(checkpoint_start + 4096);
*((uint64_t*)(device)+1) = 00;
*((uint64_t*)(device)+2) = (uint64_t)0.320580;
*((uint64_t*)(device)+3) = ((uint64_t)(((0) << 16)| 6) << 32) | 4096;
*(((uint32_t*)(device))+255) = (uint32_t)(((0) << 16)| 6);
*/
page[updated_page_count] = 0;
}
updated_page_count = 0;
all_updates = 0;
}
all_updates ++;
for(int i=0; i<updated_page_count; i++){
if(page[i] == pageStart){
#ifdef CPTIME
endCycles = getCycle();
totalCycles = endCycles - startCycles;
double totTime = ((double)totalCycles)/2000000000;
printf("cp %f\n", totTime);
#endif
return;}
}
page[updated_page_count] = pageStart;
//printf("test1 %lx %d %d\n",page[updated_page_count],updated_page_count,all_updates);
updated_page_count++;
#ifdef CPTIME
endCycles = getCycle();
totalCycles = endCycles - startCycles;
double totTime = ((double)totalCycles)/2000000000;
printf("cp %f\n", totTime);
#endif
//*((int *)checkpoint_start) = 10;
//test++;
//printf("test1 %lx %d\n",updated_page_count);
} else if (siginfo->si_code == SEGV_MAPERR) {
fprintf (stderr, "%d : map error with addr %p!\n", getpid(), addr);
abort();
} else {
fprintf (stderr, "%d : other access error with addr %p.\n", getpid(), addr);
abort();
}
}
static void installSignalHandler(void) {
// Set up an alternate signal stack.
printf("page fault handler initialized!!\n");
_sigstk.ss_sp = mmap(NULL, SIGSTKSZ, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
_sigstk.ss_size = SIGSTKSZ;
_sigstk.ss_flags = 0;
sigaltstack(&_sigstk, (stack_t *) 0);
// Now set up a signal handler for SIGSEGV events.
struct sigaction siga;
sigemptyset(&siga.sa_mask);
// Set the following signals to a set
sigaddset(&siga.sa_mask, SIGSEGV);
sigaddset(&siga.sa_mask, SIGALRM);
sigprocmask(SIG_BLOCK, &siga.sa_mask, NULL);
// Point to the handler function.
siga.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_RESTART | SA_NODEFER;
siga.sa_sigaction = segvHandle;
if (sigaction(SIGSEGV, &siga, NULL) == -1) {
perror("sigaction(SIGSEGV)");
exit(-1);
}
sigprocmask(SIG_UNBLOCK, &siga.sa_mask, NULL);
return;
}
void* open_device(const char* pathname)
{
//int fd = os_open("/sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/devices/0000:0a:00.0/resource0",O_RDWR|O_SYNC);
int fd = open(pathname,O_RDWR|O_SYNC);
if(fd == -1)
{
printf("Couldnt opene file!!\n");
exit(0);
}
void * ptr = mmap(0,4096,PROT_READ|PROT_WRITE, MAP_SHARED,fd,0);
if(ptr == (void *)-1)
{
printf("Could not map memory!!\n");
exit(0);
}
printf("opened device without error!!\n");
return ptr;
}
///////////////////////////////////////////////////////////////////
void installSignalHandler (void) __attribute__ ((constructor));
int main(int argc, char* argv[]) {
device = open_device("/sys/devices/pci0000:00/0000:00:00.2/iommu/ivhd0/devices/0000:0a:00.0/resource0");
uint64_t* tmp = (uint64_t*)device;
*tmp = 0xdeadbeefdeadbeef;
pmem_persist(tmp,64);
*tmp = (uint64_t)tmp;
pmem_persist(tmp,64);
uint32_t tid;
tid = 0;//gettid();
tid = tid & 0x3f;
tid = (tid<< 4)| 0;//pop->run_id;
//printf("%d %d\n",tid, pop->run_id);
*tmp = tid;
pmem_persist(tmp,64);
size_t mapped_len;
int is_pmem;
void * backUpLogPtr;
if ((backUpLogPtr = pmem_map_file("/mnt/mem/tpcc_db", sizeof(struct backUpLog)*NUM_THREADS,
PMEM_FILE_CREATE, 0666, &mapped_len, &is_pmem)) == NULL) {
fprintf(stderr, "pmem_map_file failed\n");
exit(0);
}
for(int i=0;i<NUM_THREADS;i++){
initialize(i, (backUpLogPtr + i*sizeof(struct backUpLog)));
}
// exit(0);
//CounterAtomic::initCounterCache();
/*
std::cout<<"num_threads, num_orders = "<< NUM_THREADS <<", "<<NUM_ORDERS <<std::endl;
std::cout<<"done with initialization"<<std::endl;
tpcc_db->populate_tables();
std::cout<<"done with populating tables"<<std::endl;
*/
pthread_t threads[NUM_THREADS];
int id[NUM_THREADS];
//gettimeofday(&tv_start, NULL);
uint64_t endCycles, startCycles,totalCycles;
startCycles = getCycle();
for(int i=0; i<NUM_THREADS; i++) {
id[i] = i;
// fprintf(stderr, "create %d\n", i);
//Korakit
//convert to ST version
//new_orders((void *)(id+i));
new_orders((void *)&id[i]);
}
endCycles = getCycle();
totalCycles = endCycles - startCycles;
double totTime = ((double)totalCycles)/2000000000;
printf("tottime %f\n", totTime);
//Korakit
//remote MT stuffs
// for(int i=0; i<NUM_THREADS; i++) {
// pthread_join(threads[i], NULL);
// }
//Korakit
//Remove all timing stuffs
/*
gettimeofday(&tv_end, NULL);
fprintf(stderr, "time elapsed %ld us\n",
tv_end.tv_usec - tv_start.tv_usec +
(tv_end.tv_sec - tv_start.tv_sec) * 1000000);
fexec << "TPCC" << ", " << std::to_string((tv_end.tv_usec - tv_start.tv_usec) + (tv_end.tv_sec - tv_start.tv_sec) * 1000000) << std::endl;
fexec.close();
*/
//free(tpcc_db);
//std::cout<<"done with threads"<<std::endl;
return 0;
}
| 9,685 | 26.517045 | 176 |
cc
|
null |
NearPMSW-main/nearpmMDsync/shadow/TPCC_SD/run.sh
|
#!/usr/bin/env bash
sudo rm -rf /mnt/mem/*
sudo ./tpcc_nvm > out
tot=$(grep "tottime" out)
grep "cp" out > time
cp=$(awk '{sum+= $2;} END{print sum;}' time)
echo $1$tot
echo $1'cp' $cp
| 187 | 16.090909 | 44 |
sh
|
null |
NearPMSW-main/nearpmMDsync/shadow/TPCC_SD/simple_queue.h
|
/*
Author: Vaibhav Gogte <[email protected]>
Aasheesh Kolli <[email protected]>
*/
//#include <iostream>
#define QUEUE_SIZE 20
class simple_queue {
private:
long entries[QUEUE_SIZE];
long head;
long tail;
public:
simple_queue() {
head = 0;
tail = 0;
}
~simple_queue() {}
bool empty() {
return (head == tail);
}
bool full() {
if(tail == 0)
return (head == QUEUE_SIZE-1);
return (head == tail-1);
}
int size() {
if(head >= tail) {
return head - tail;
}
else {
return (QUEUE_SIZE - tail + head);
}
}
bool push(long entry) {
if(full())
return false;
entries[head] = entry;
if(head == QUEUE_SIZE-1)
head = 0;
else
head++;
return true;
}
long front() {
return entries[tail];
}
bool pop() {
if(empty())
return false;
if(tail == QUEUE_SIZE-1)
tail = 0;
else
tail++;
return true;
}
//void printQueue() {
// std::cout<<"head tail "<<head<<" "<<tail<<std::endl;
// for(int i=0; i<QUEUE_SIZE; i++) {
// std::cout<<i<<" "<<entries[i]<<std::endl;
// }
//}
};
| 1,257 | 16.232877 | 60 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/TPCC_SD/table_entries.h
|
/*
Author: Vaibhav Gogte <[email protected]>
Aasheesh Kolli <[email protected]>
This file declares the entry types for each of the tables used in TPCC
*/
struct warehouse_entry {
int w_id;
char w_name[10];
char w_street_1[20];
char w_street_2[20];
char w_city[20];
char w_state[2];
char w_zip[9];
float w_tax;
float w_ytd;
char padding[32];
};
struct district_entry {
short d_id;
int d_w_id;
char d_name[10];
char d_street_1[20];
char d_street_2[20];
char d_city[20];
char d_state[2];
char d_zip[9];
float d_tax;
float d_ytd;
int d_next_o_id;
char padding[24]; //change padding from 4 to 24 to make it fits in 64-byte cacheline size
};
struct customer_entry {
int c_id;
short c_d_id;
int c_w_id;
char c_first[16];
char c_middle[2];
char c_last[16];
char c_street_1[20];
char c_street_2[20];
char c_city[20];
char c_state[2];
char c_zip[9];
char c_phone[16];
long long c_since; // Seconds since 1st Jan 1900, 00:00:00
char c_credit[2];
float c_credit_lim;
float c_discount;
float c_balance;
float c_ytd_payment;
float c_payment_cnt;
float c_delivery_cnt;
char c_data[500];
char padding[32];
};
struct history_entry {
int h_c_id;
short h_c_d_id;
int h_c_w_id;
short h_d_id;
int h_w_id;
long long h_date;
float h_amount;
char h_data[24];
};
struct new_order_entry {
int no_o_id;
short no_d_id;
int no_w_id;
int indx;
char padding[48]; //change padding from 4 to 52 to make it fits in 64-byte cacheline size
};
struct order_entry {
int o_id;
short o_d_id;
int o_w_id;
int o_c_id;
long long o_entry_d;
short o_carrier_id;
float o_ol_cnt;
float o_all_local;
int indx;
char padding[20];
};
struct order_line_entry {
int ol_o_id;
short ol_d_id;
int ol_w_id;
short ol_number;
int ol_i_id;
int ol_supply_w_id;
long long ol_delivery_d;
float ol_quantity;
float ol_amount;
char ol_dist_info[24];
};
struct item_entry {
int i_id;
int i_im_id;
char i_name[24];
float i_price;
char i_data[50];
char padding[40];
};
struct stock_entry {
int s_i_id;
int s_w_id;
float s_quantity;
char s_dist_01[24];
char s_dist_02[24];
char s_dist_03[24];
char s_dist_04[24];
char s_dist_05[24];
char s_dist_06[24];
char s_dist_07[24];
char s_dist_08[24];
char s_dist_09[24];
char s_dist_10[24];
float s_ytd;
float s_order_cnt;
float s_remote_cnt;
char s_data[50];
int indx;
};
| 2,468 | 17.154412 | 91 |
h
|
null |
NearPMSW-main/nearpmMDsync/shadow/TPCC_SD/tpcc_db.cc
|
/*
Author: Vaibhav Gogte <[email protected]>
Aasheesh Kolli <[email protected]>
This file defines the various functions of the tpcc database
*/
#include <cstdlib>
#include <iostream>
#include <queue>
#include <cstring> // For memcpy
#include <algorithm> // for sort
#include "tpcc_db.h"
#include <libpmem.h>
#include <sys/mman.h>
//#define NEW_ORDER_LOCK 10;
#define TPCC_DEBUG 0
//#define NUM_ITEMS 1000
#define NUM_ITEMS 10000
#define NUM_RNDM_SEEDS 1280
static void setpage(void * addr){
uint64_t pageNo = ((uint64_t)addr)/4096;
unsigned long * pageStart = (unsigned long *)(pageNo*4096);
mprotect(pageStart, 4096, PROT_READ);
return;
}
extern void * checkpoint_start;
TPCC_DB::TPCC_DB() {
uint64_t district_back_valid = 0UL;
uint64_t fill_new_order_entry_back_valid = 0UL;
uint64_t update_order_entry_back_valid = 0UL;
uint64_t update_stock_entry_num_valid = 0UL;
uint64_t log_valid = 0UL;
g_seed = 1312515;
}
unsigned TPCC_DB::fastrand() {
g_seed = (179423891 * g_seed + 2038073749);
return (g_seed >> 8) & 0x7FFFFFFF;
}
void TPCC_DB::initialize(int _num_warehouses, int numThreads) {
num_warehouses = _num_warehouses;
int num_districts = 10*num_warehouses;
int num_customers = 3000*num_districts;
int num_stocks = NUM_ITEMS*num_warehouses;
for(int i=0; i<3000; i++) {
random_3000[i] = i;
}
for(int i=0; i<3000; i++) {
int rand_loc = fastrand()%3000;
int temp = random_3000[i];
random_3000[i] = random_3000[rand_loc];
random_3000[rand_loc] = temp;
}
/*
perTxLocks = new queue_t[numThreads];
for(int i=0; i<numThreads; i++) {
perTxLocks[i].push(0);
perTxLocks[i].pop();
}
*/
/*
locks = new pthread_mutex_t[numLocks];
for (int i = 0; i < numLocks; i++) {
pthread_mutex_init(&locks[i],NULL);
}
*/
//Korakit
//info removed
// std::cout<<"Allocating tables"<<std::endl;
int num_items = NUM_ITEMS;
int num_histories = num_customers;
int num_orders = 3000*num_districts;
int num_order_lines = 15*num_orders; // Max possible, average is 10*num_orders
int num_new_orders = 900*num_districts;
size_t mapped_len;
int is_pmem;
void * pmemstart;
int totsize = num_warehouses*sizeof(warehouse_entry) + num_districts*sizeof(district_entry) + num_customers*sizeof(customer_entry)
+ num_stocks*sizeof(stock_entry) + num_items*sizeof(item_entry) + num_histories*sizeof(history_entry) + num_orders*sizeof(order_entry)
+ num_new_orders*sizeof(new_order_entry) + num_order_lines*sizeof(order_line_entry);
if ((pmemstart = pmem_map_file("/mnt/mem/tpcc", totsize,
PMEM_FILE_CREATE, 0666, &mapped_len, &is_pmem)) == NULL) {
fprintf(stderr, "pmem_map_file failed\n");
exit(0);
}
if ((checkpoint_start = pmem_map_file("/mnt/mem/checkpoint", 4096*50,
PMEM_FILE_CREATE, 0666, &mapped_len, &is_pmem)) == NULL) {
fprintf(stderr, "pmem_map_file failed\n");
exit(0);
}
warehouse = (warehouse_entry*) pmemstart;//malloc(num_warehouses*sizeof(warehouse_entry));
district = (district_entry*) (pmemstart + num_warehouses*sizeof(warehouse_entry));//malloc(num_districts*sizeof(district_entry));
customer = (customer_entry*) (pmemstart + num_warehouses*sizeof(warehouse_entry) + num_districts*sizeof(district_entry));//malloc(num_customers*sizeof(customer_entry));
stock = (stock_entry*) (pmemstart + num_warehouses*sizeof(warehouse_entry) + num_districts*sizeof(district_entry) + num_stocks*sizeof(stock_entry));//malloc(num_stocks*sizeof(stock_entry));
item = (item_entry*) (pmemstart + num_warehouses*sizeof(warehouse_entry) + num_districts*sizeof(district_entry) + num_stocks*sizeof(stock_entry) + num_items*sizeof(item_entry) );//malloc(num_items*sizeof(item_entry));
history = (history_entry*) (pmemstart + num_warehouses*sizeof(warehouse_entry) + num_districts*sizeof(district_entry) + num_stocks*sizeof(stock_entry) + num_items*sizeof(item_entry) + num_histories*sizeof(history_entry));//malloc(num_histories*sizeof(history_entry));
order = (order_entry*) (pmemstart + num_warehouses*sizeof(warehouse_entry) + num_districts*sizeof(district_entry) + num_stocks*sizeof(stock_entry) + num_items*sizeof(item_entry) + num_histories*sizeof(history_entry) + num_orders*sizeof(order_entry));//malloc(num_orders*sizeof(order_entry));
new_order = (new_order_entry*) (pmemstart + num_warehouses*sizeof(warehouse_entry) + num_districts*sizeof(district_entry) + num_stocks*sizeof(stock_entry) + num_items*sizeof(item_entry) + num_histories*sizeof(history_entry) + num_orders*sizeof(order_entry) + num_new_orders*sizeof(new_order_entry));//malloc(num_new_orders*sizeof(new_order_entry));
order_line = (order_line_entry*) (pmemstart + num_warehouses*sizeof(warehouse_entry) + num_districts*sizeof(district_entry) + num_stocks*sizeof(stock_entry) + num_items*sizeof(item_entry) + num_histories*sizeof(history_entry) + num_orders*sizeof(order_entry) + num_new_orders*sizeof(new_order_entry) + num_order_lines*sizeof(order_line_entry));//malloc(num_order_lines*sizeof(order_line_entry));
rndm_seeds = new unsigned long[NUM_RNDM_SEEDS];
for(int i=0; i<NUM_RNDM_SEEDS; i++) {
srand(i);
rndm_seeds[i] = rand_local(1,NUM_RNDM_SEEDS*10);
}
//Korakit
//info removed
/*
std::cout<<"finished allocating tables"<<std::endl;
std::cout<<"warehouse_entry: "<<sizeof(warehouse_entry)<<std::endl;
std::cout<<"district_entry: "<<sizeof(district_entry)<<std::endl;
std::cout<<"customer_entry: "<<sizeof(customer_entry)<<std::endl;
std::cout<<"stock_entry: "<<sizeof(stock_entry)<<std::endl;
std::cout<<"item_entry: "<<sizeof(item_entry)<<std::endl;
std::cout<<"history_entry: "<<sizeof(history_entry)<<std::endl;
std::cout<<"order_entry: "<<sizeof(order_entry)<<std::endl;
std::cout<<"new_order_entry: "<<sizeof(new_order_entry)<<std::endl;
std::cout<<"order_line_entry: "<<sizeof(order_line_entry)<<std::endl;
*/
}
TPCC_DB::~TPCC_DB(){
free(warehouse);
free(district);
free(customer);
free(stock);
free(item);
free(history);
free(order);
free(new_order);
free(order_line);
}
void TPCC_DB::populate_tables() {
//std::cout<<"populating item table"<<std::endl;
for(int i=0; i<NUM_ITEMS; i++) {
fill_item_entry(i+1);
}
//std::cout<<"finished populating item table"<<std::endl;
for(int i=0; i<num_warehouses; i++) {
fill_warehouse_entry(i+1);
for(int j=0; j<NUM_ITEMS; j++) {
fill_stock_entry(i+1, j+1);
}
//std::cout<<"finished populating stock table"<<std::endl;
for(int j=0; j<10; j++) {
fill_district_entry(i+1, j+1);
for(int k=0; k<3000; k++) {
fill_customer_entry(i+1, j+1, k+1);
fill_history_entry(i+1, j+1, k+1);
fill_order_entry(i+1, j+1, k+1);
}
for(int k=2100; k<3000; k++) {
fill_new_order_entry(i+1, j+1, k+1, 0);
}
}
}
}
//Korakit
//remove MT stuff
/*
void TPCC_DB::acquire_locks(int threadId, queue_t &requestedLocks) {
// Acquire locks in order.
int i = -1;
while(!requestedLocks.empty()) {
i = requestedLocks.front();
perTxLocks[threadId].push(i);
requestedLocks.pop();
pthread_mutex_lock(&locks[i]);
}
}
void TPCC_DB::release_locks(int threadId) {
// Release locks in order
int i = -1;
while(!perTxLocks[threadId].empty()) {
i = perTxLocks[threadId].front();
perTxLocks[threadId].pop();
pthread_mutex_unlock(&locks[i]);
}
}
*/
void TPCC_DB::fill_item_entry(int _i_id) {
int indx = (_i_id-1);
item[indx].i_id = _i_id;
item[indx].i_im_id = rand_local(1,NUM_ITEMS);
random_a_string(14,24,item[indx].i_name);
item[indx].i_price = rand_local(1,100)*(1.0);
random_a_original_string(26,50,10,item[indx].i_data);
}
void TPCC_DB::fill_warehouse_entry(int _w_id) {
int indx = (_w_id-1);
warehouse[indx].w_id = _w_id;
random_a_string(6,10,warehouse[indx].w_name);
random_a_string(10,20,warehouse[indx].w_street_1);
random_a_string(10,20,warehouse[indx].w_street_2);
random_a_string(10,20,warehouse[indx].w_city);
random_a_string(2,2,warehouse[indx].w_state);
random_zip(warehouse[indx].w_zip);
warehouse[indx].w_tax = (rand_local(0,20))/100.0;
warehouse[indx].w_ytd = 300000.0;
}
void TPCC_DB::fill_stock_entry(int _s_w_id, int _s_i_id) {
//std::cout<<"entered fill stock entry: "<<_s_w_id<<", "<<_s_i_id<<std::endl;
int indx = (_s_w_id-1)*NUM_ITEMS + (_s_i_id-1);
stock[indx].s_i_id = _s_i_id;
//std::cout<<"1"<<std::endl;
stock[indx].s_w_id = _s_w_id;
//std::cout<<"1"<<std::endl;
stock[indx].s_quantity = rand_local(10,100);
//std::cout<<"1"<<std::endl;
random_a_string(24,24,stock[indx].s_dist_01);
//std::cout<<"1"<<std::endl;
random_a_string(24,24,stock[indx].s_dist_02);
//std::cout<<"1"<<std::endl;
random_a_string(24,24,stock[indx].s_dist_03);
//std::cout<<"1"<<std::endl;
random_a_string(24,24,stock[indx].s_dist_04);
//std::cout<<"1"<<std::endl;
random_a_string(24,24,stock[indx].s_dist_05);
//std::cout<<"1"<<std::endl;
random_a_string(24,24,stock[indx].s_dist_06);
//std::cout<<"1"<<std::endl;
random_a_string(24,24,stock[indx].s_dist_07);
//std::cout<<"1"<<std::endl;
random_a_string(24,24,stock[indx].s_dist_08);
//std::cout<<"1"<<std::endl;
random_a_string(24,24,stock[indx].s_dist_09);
//std::cout<<"1"<<std::endl;
random_a_string(24,24,stock[indx].s_dist_10);
//std::cout<<"1"<<std::endl;
stock[indx].s_ytd = 0.0;
//std::cout<<"1"<<std::endl;
stock[indx].s_order_cnt = 0.0;
//std::cout<<"1"<<std::endl;
stock[indx].s_remote_cnt = 0.0;
//std::cout<<"1"<<std::endl;
random_a_original_string(26,50,10,stock[indx].s_data);
//std::cout<<"exiting fill stock entry: "<<_s_w_id<<", "<<_s_i_id<<std::endl;
}
void TPCC_DB::fill_district_entry(int _d_w_id, int _d_id) {
int indx = (_d_w_id-1)*10 + (_d_id-1);
district[indx].d_id = _d_id;
district[indx].d_w_id = _d_w_id;
random_a_string(6,10,district[indx].d_name);
random_a_string(10,20,district[indx].d_street_1);
random_a_string(10,20,district[indx].d_street_2);
random_a_string(10,20,district[indx].d_city);
random_a_string(2,2,district[indx].d_state);
random_zip(district[indx].d_zip);
district[indx].d_tax = (rand_local(0,20))/100.0;
district[indx].d_ytd = 30000.0;
district[indx].d_next_o_id = 3001;
}
void TPCC_DB::fill_customer_entry(int _c_w_id, int _c_d_id, int _c_id) {
int indx = (_c_w_id-1)*10*3000 + (_c_d_id-1)*3000 + (_c_id-1);
customer[indx].c_id = _c_id;
customer[indx].c_d_id = _c_d_id;
customer[indx].c_w_id = _c_w_id;
random_a_string(16,16,customer[indx].c_last); // FIXME: check tpcc manual for exact setting
customer[indx].c_middle[0] = 'O';
customer[indx].c_middle[1] = 'E';
random_a_string(8,16,customer[indx].c_first);
random_a_string(10,20,customer[indx].c_street_1);
random_a_string(10,20,customer[indx].c_street_2);
random_a_string(10,20,customer[indx].c_city);
random_a_string(2,2,customer[indx].c_state);
random_zip(customer[indx].c_zip);
random_n_string(16,16, customer[indx].c_phone);
fill_time(customer[indx].c_since);
if(fastrand()%10 < 1) {
customer[indx].c_credit[0] = 'G';
customer[indx].c_credit[1] = 'C';
}
else {
customer[indx].c_credit[0] = 'B';
customer[indx].c_credit[1] = 'C';
}
customer[indx].c_credit_lim = 50000.0;
customer[indx].c_discount = (rand_local(0,50))/100.0;
customer[indx].c_balance = -10.0;
customer[indx].c_ytd_payment = 10.0;
customer[indx].c_payment_cnt = 1.0;
customer[indx].c_delivery_cnt = 0.0;
random_a_string(300,500,customer[indx].c_data);
}
void TPCC_DB::fill_history_entry(int _h_c_w_id, int _h_c_d_id, int _h_c_id) {
int indx = (_h_c_w_id-1)*10*3000 + (_h_c_d_id-1)*3000 + (_h_c_id-1);
history[indx].h_c_id = _h_c_id;
history[indx].h_c_d_id = _h_c_d_id;
history[indx].h_c_w_id = _h_c_w_id;
fill_time(history[indx].h_date);
history[indx].h_amount = 10.0;
random_a_string(12,24,history[indx].h_data);
}
void TPCC_DB::fill_order_entry(int _o_w_id, int _o_d_id, int _o_id) {
int indx = (_o_w_id-1)*10*3000 + (_o_d_id-1)*3000 + (_o_id-1);
order[indx].o_id = _o_id;
order[indx].o_c_id = random_3000[_o_id];
order[indx].o_d_id = _o_d_id;
order[indx].o_w_id = _o_w_id;
fill_time(order[indx].o_entry_d);
if(_o_id<2101)
order[indx].o_carrier_id = fastrand()%10 + 1;
else
order[indx].o_carrier_id = 0;
order[indx].o_ol_cnt = rand_local(5,15);
order[indx].o_all_local = 1.0;
for(int i=0; i<order[indx].o_ol_cnt; i++) {
fill_order_line_entry(_o_w_id, _o_d_id, _o_id, i, order[indx].o_entry_d);
}
}
void TPCC_DB::fill_order_line_entry(int _ol_w_id, int _ol_d_id, int _ol_o_id, int _o_ol_cnt, long long _o_entry_d) {
int indx = (_ol_w_id-1)*10*3000*15 + (_ol_d_id-1)*3000*15 + (_ol_o_id-1)*15 + _o_ol_cnt;
order_line[indx].ol_o_id = _ol_o_id;
order_line[indx].ol_d_id = _ol_d_id;
order_line[indx].ol_w_id = _ol_w_id;
order_line[indx].ol_number = _o_ol_cnt;
order_line[indx].ol_i_id = rand_local(1,NUM_ITEMS);
order_line[indx].ol_supply_w_id = _ol_w_id;
if(_ol_o_id < 2101) {
order_line[indx].ol_delivery_d = _o_entry_d;
order_line[indx].ol_amount = 0.0;
}
else {
order_line[indx].ol_delivery_d = 0;
order_line[indx].ol_amount = rand_local(1,999999)/100.0;
}
order_line[indx].ol_quantity = 5.0;
random_a_string(24,24,order_line[indx].ol_dist_info);
}
void TPCC_DB::fill_new_order_entry(int _no_w_id, int _no_d_id, int _no_o_id, int threadId) {
int indx = (_no_w_id-1)*10*900 + (_no_d_id-1)*900 + (_no_o_id-2101) % 900;
// OPT_ADDR((void*)(7), threadId, &new_order[indx], sizeof(new_order_entry));
// if(TPCC_DEBUG)
// std::cout<<"w_id, d_id, o_id, indx: "<<_no_w_id<<", "<<_no_d_id<<", "
// <<_no_o_id<<", "<<indx<<std::endl;
//Korakit
//do backup
//backUpInst->fill_new_order_entry_indx = indx;
//new_order[indx].indx = indx;
//backUpInst->new_order_entry_back = new_order[indx];
//flush_caches((void*)&backUpInst->fill_new_order_entry_indx, (unsigned)sizeof(backUpInst->fill_new_order_entry_indx));
//pmem_persist((void*)&backUpInst->new_order_entry_back, (unsigned)sizeof(backUpInst->new_order_entry_back));
//s_fence();
//backUpInst->fill_new_order_entry_back_valid=1;
//s_fence();
//just flush the cache
new_order[indx].no_o_id = _no_o_id;
new_order[indx].no_d_id = _no_d_id;
setpage(&new_order[indx]);
new_order[indx].no_w_id = _no_w_id;
pmem_persist((void*)&new_order[indx], (unsigned)sizeof(new_order[indx]));
}
int TPCC_DB::rand_local(int min, int max) {
return (min + (fastrand()%(max-min+1)));
}
void TPCC_DB::random_a_string(int min, int max, char* string_ptr) {
//std::cout<<"entered random a string"<<std::endl;
char alphabets[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N',
'O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//std::cout<<"2"<<std::endl;
int string_length = min + (fastrand()%(max-min+1));
//std::cout<<"2"<<std::endl;
for(int i=0; i<string_length; i++) {
string_ptr[max-1-i] = alphabets[fastrand()%26];
//std::cout<<"f3"<<std::endl;
}
//std::cout<<"2"<<std::endl;
for(int i=0; i<max-string_length; i++) {
string_ptr[max-1-i] = ' ';
//std::cout<<"f4"<<std::endl;
}
//std::cout<<"exiting random a string"<<std::endl;
}
void TPCC_DB::random_a_original_string(int min, int max, int probability, char* string_ptr) {
//FIXME: use probability and add ORIGINAL
random_a_string(min, max,string_ptr);
}
void TPCC_DB::random_zip(char* string_ptr) {
random_a_string(4,4,string_ptr);
for(int i=4; i<9; i++) {
string_ptr[i] = '1';
}
}
void TPCC_DB::random_n_string(int min, int max, char* string_ptr) {
char digits[10] = {'0','1','2','3','4','5','6','7','8','9'};
int string_length = min + (fastrand()%(max-min+1));
for(int i=0; i<string_length; i++) {
string_ptr[max-1-i] = digits[fastrand()%10];
}
for(int i=0; i<max-string_length; i++) {
string_ptr[max-1-i] = ' ';
}
}
void TPCC_DB::fill_time(long long &time_slot) {
//FIXME: put correct time
time_slot = 12112342433241;
}
void TPCC_DB::copy_district_info(district_entry &dest, district_entry &source) {
std::memcpy(&dest, &source, sizeof(district_entry));
}
void TPCC_DB::copy_customer_info(customer_entry &dest, customer_entry &source) {
std::memcpy(&dest, &source, sizeof(customer_entry));
}
void TPCC_DB::copy_new_order_info(new_order_entry &dest, new_order_entry &source) {
std::memcpy(&dest, &source, sizeof(new_order_entry));
}
void TPCC_DB::copy_order_info(order_entry &dest, order_entry &source) {
std::memcpy(&dest, &source, sizeof(order_entry));
}
void TPCC_DB::copy_stock_info(stock_entry &dest, stock_entry &source) {
std::memcpy(&dest, &source, sizeof(stock_entry));
}
void TPCC_DB::copy_order_line_info(order_line_entry &dest, order_line_entry &source) {
std::memcpy(&dest, &source, sizeof(order_line_entry));
}
void TPCC_DB::update_order_entry(int _w_id, short _d_id, int _o_id, int _c_id, int _ol_cnt, int threadId) {
int indx = (_w_id-1)*10*3000 + (_d_id-1)*3000 + (_o_id-1)%3000;
// OPT((void*)(8), threadId, &backUpInst->order_entry_back, &order[indx], sizeof(order_entry));
// OPT_ADDR((void*)(9), threadId, &order[indx], sizeof(order_entry));
// Korakit
// create backup
// fprintf(stdout, "thread=%d, line=%d\n", threadId, __LINE__);
//backUpInst->update_order_entry_indx = indx;
//order[indx].indx = indx;
//backUpInst->order_entry_back = order[indx];
//pmem_persist((void*)&backUpInst->update_order_entry_indx, (unsigned)sizeof(backUpInst->update_order_entry_indx));
//pmem_persist((void*)&backUpInst->order_entry_back, (unsigned)sizeof(backUpInst->order_entry_back));
//s_fence();
// fprintf(stdout, "thread=%d, line=%d\n", threadId, __LINE__);
//backUpInst->update_order_entry_back_valid = 1;
//s_fence();
order[indx].o_id = _o_id;
order[indx].o_carrier_id = 0;
order[indx].o_all_local = 1;
order[indx].o_ol_cnt = _ol_cnt;
order[indx].o_c_id = _c_id;
setpage(&order[indx]);
fill_time(order[indx].o_entry_d);
pmem_persist((void*)&order[indx], (unsigned)sizeof(order[indx]));
s_fence();
}
void TPCC_DB::update_stock_entry(int threadId, int _w_id, int _i_id, int _d_id, float &amount, int itr) {
int indx = (_w_id-1)*NUM_ITEMS + _i_id-1;
//int ol_quantity = get_random(threadId, 1, 10);
int ol_quantity = 7;
// OPT_ADDR((void*)(0x20), threadId, &stock[indx], sizeof(stock_entry));
// fprintf(stdout, "thread=%d, line=%d\n", threadId, __LINE__);
//backUpInst->update_stock_entry_indx[itr] = indx;
//stock[indx].indx = indx;
//backUpInst->stock_entry_back[itr] = stock[indx];
//backUpInst->update_stock_entry_num_valid = itr+1;
//pmem_persist((void*)&backUpInst->update_stock_entry_indx[itr], (unsigned)sizeof(backUpInst->update_stock_entry_indx[itr]));
//pmem_persist((void*)&backUpInst->stock_entry_back[itr], (unsigned)sizeof(backUpInst->stock_entry_back[itr]));
//s_fence();
// fprintf(stdout, "%d\n", __LINE__);
if(stock[indx].s_quantity - ol_quantity > 10) {
stock[indx].s_quantity -= ol_quantity;
}
else {
stock[indx].s_quantity -= ol_quantity;
stock[indx].s_quantity += 91;
}
stock[indx].s_ytd += ol_quantity;
setpage(&stock[indx]);
stock[indx].s_order_cnt += 1;
pmem_persist((void*)&stock[indx], (unsigned)sizeof(stock[indx]));
s_fence();
// fprintf(stdout, "%d\n", __LINE__);
//Korakit
//volatile
amount += ol_quantity * item[_i_id-1].i_price;
}
void TPCC_DB::new_order_tx(int threadId, int w_id, int d_id, int c_id) {
// OPT_VAL((void*)(1), threadId, (void*)backUpInst->district_back_valid.getPtr(), 0);
// OPT_VAL((void*)(2), threadId, (void*)backUpInst->fill_new_order_entry_back_valid.getPtr(), 0);
// OPT_VAL((void*)(3), threadId, (void*)backUpInst->update_order_entry_back_valid.getPtr(), 0);
// OPT_VAL((void*)(4), threadId, (void*)backUpInst->update_stock_entry_num_valid.getPtr(), 0);
int w_indx = (w_id-1);
int d_indx = (w_id-1)*10 + (d_id-1);
int c_indx = (w_id-1)*10*3000 + (d_id-1)*3000 + (c_id-1);
// OPT((void*)(5), threadId, &backUpInst->district_back, &district[d_indx], sizeof(backUpInst->district_back));
// OPT_ADDR((void*)(6), threadId, &backUpInst->new_order_entry_back, sizeof(backUpInst->new_order_entry_back));
/*
queue_t reqLocks;
reqLocks.push(d_indx); // Lock for district
*/
/*
if(TPCC_DEBUG)
std::cout<<"**NOTx** district lock id: "<<d_indx<<std::endl;
*/
// fprintf(stdout, "%d\n", __LINE__);
int ol_cnt = get_random(threadId, 5, 15);
int item_ids[ol_cnt];
for(int i=0; i<ol_cnt; i++) {
int new_item_id;
bool match;
do {
match = false;
new_item_id = get_random(threadId, 1, NUM_ITEMS);
for(int j=0; j<i; j++) {
if(new_item_id == item_ids[j]) {
match = true;
break;
}
}
} while (match);
item_ids[i] = new_item_id;
}
// fprintf(stdout, "%d\n", __LINE__);
std::sort(item_ids, item_ids+ol_cnt);
// fprintf(stdout, "%d\n", __LINE__);
/*
if(TPCC_DEBUG)
std::cout<<"**NOTx** ol_cnt: "<<ol_cnt<<std::endl;
*/
for(int i=0; i<ol_cnt; i++) {
int item_lock_id = num_warehouses*10 + (w_id-1)*NUM_ITEMS + item_ids[i] - 1;
/*
reqLocks.push(item_lock_id); // Lock for each item in stock table
*/
/*
if(TPCC_DEBUG)
std::cout<<"**NOTx** item lock id: "<<item_lock_id<<" thread id: "<<threadId<<std::endl;
*/
}
//Korakit
//remove MT stuff
//acquire_locks(threadId, reqLocks);
/*
if(TPCC_DEBUG)
std::cout<<"**NOTx** finished start tx: "<<std::endl;
*/
float w_tax = warehouse[w_indx].w_tax;
float d_tax = district[d_indx].d_tax;
int d_o_id = district[d_indx].d_next_o_id;
int no_indx = (w_id-1)*10*900 + (d_id-1)*900 + (d_o_id-2101) % 900;
int o_indx = (w_id-1)*10*3000 + (d_id-1)*3000 + (d_o_id-1)%3000;
//Korakit
//real stuff here
// okay we gonna try really simple stuff first
// let's force all writes when the transaction completes
// flush_caches(uint64_t addr, unsigned size);
// s_fence();
// fprintf(stdout, "%d\n", __LINE__);
//prepare backup log
//backUpInst->district_back_valid = 0;
//backUpInst->fill_new_order_entry_back_valid = 0;
//backUpInst->update_order_entry_back_valid = 0;
//backUpInst->update_stock_entry_num_valid = 0;
//s_fence();
// OPT_VAL((void*)(0x41), threadId, (void*)backUpInst->district_back_valid.getPtr(), 1);
// OPT_VAL((void*)(0x42), threadId, (void*)backUpInst->fill_new_order_entry_back_valid.getPtr(), 1);
// OPT_VAL((void*)(0x43), threadId, (void*)backUpInst->update_order_entry_back_valid.getPtr(), 1);
//backUpInst->log_valid = 1;
//pmem_persist((void*)&backUpInst->log_valid, (unsigned)sizeof(backUpInst->log_valid));
//s_fence();
for(int i=0; i<ol_cnt; i++) {
// OPT_ADDR((void*)(0x100UL+i), threadId, &backUpInst->stock_entry_back[i], sizeof(stock_entry));
}
//do backup
//fprintf(stdout, "%d\n", __LINE__);
//backUpInst->district_back = district[d_indx];
//pmem_persist(&backUpInst->district_back, sizeof(backUpInst->district_back));
district[d_indx].d_next_o_id++;
//flush district[d_indx].d_next_o_id++;
//pmem_persist((void*)&district[d_indx].d_next_o_id, (unsigned)sizeof(district[d_indx].d_next_o_id));
//s_fence();
// fprintf(stdout, "%d\n", __LINE__);
fill_new_order_entry(w_id,d_id,d_o_id, threadId);
// fprintf(stdout, "%d\n", __LINE__);
update_order_entry(w_id, d_id, d_o_id, c_id, ol_cnt, threadId);
// fprintf(stdout, "%d\n", __LINE__);
float total_amount = 0.0;
for(int i=0; i<ol_cnt; i++) {
update_stock_entry(threadId, w_id, item_ids[i], d_id, total_amount, i);
}
// fprintf(stdout, "%d\n", __LINE__);
//invalidate log entries
//backUpInst->log_valid = 0;
//pmem_persist((void*)&backUpInst->log_valid, (unsigned)sizeof(backUpInst->log_valid));
//s_fence();
// fprintf(stdout, "%d\n", __LINE__);
/////////////////
//Korakit
//debug removed
/*
if(TPCC_DEBUG)
std::cout<<"d_id, d_o_id, ol_cnt, total_amount: "<<d_id<<", "<<d_o_id<<", "<<
ol_cnt<<", "<<total_amount<<std::endl;
*/
//Korakit
//remove MT stuffs
//release_locks(threadId);
return;
}
unsigned long TPCC_DB::get_random(int thread_id) {
unsigned long tmp;
tmp = rndm_seeds[thread_id*10] = (rndm_seeds[thread_id*10] * 16807) % 2147483647;
//return rand()%(2^32-1);
return tmp;
}
unsigned long TPCC_DB::get_random(int thread_id, int min, int max) {
unsigned long tmp;
//return min+(rand()%(max-min+1));
tmp = rndm_seeds[thread_id*10] = (rndm_seeds[thread_id*10] * 16807) % 2147483647;
return min+(tmp%(max-min+1));
//return tmp
}
//Korakit
//debug removed
/*
void TPCC_DB::printStackPointer(int* sp, int thread_id) {
std::cout<<"Stack Heap: "<<sp<<std::endl;
}
*/
| 24,859 | 34.873016 | 397 |
cc
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/crc32c.h
|
#ifndef CRC32C_H
#define CRC32C_H
typedef uint32_t (*crc_func)(uint32_t crc, const void *buf, size_t len);
crc_func crc32c;
void crc32c_init(void);
#endif /* CRC32C_H */
| 179 | 17 | 72 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/slabs.h
|
/*
* Copyright 2018 Lenovo
*
* Licensed under the BSD-3 license. see LICENSE.Lenovo.txt for full text
*/
/*
* Note:
* Codes enclosed in `#ifdef PSLAB' and `#endif' are added by Lenovo for
* persistent memory support
*/
/* slabs memory allocation */
#ifndef SLABS_H
#define SLABS_H
/** Init the subsystem. 1st argument is the limit on no. of bytes to allocate,
0 if no limit. 2nd argument is the growth factor; each slab will use a chunk
size equal to the previous slab's chunk size times this factor.
3rd argument specifies if the slab allocator should allocate all memory
up front (if true), or allocate memory in chunks as it is needed (if false)
*/
void slabs_init(const size_t limit, const double factor, const bool prealloc, const uint32_t *slab_sizes);
/** Call only during init. Pre-allocates all available memory */
void slabs_prefill_global(void);
#ifdef PSLAB
int slabs_dump_sizes(uint32_t *slab_sizes, int max);
void slabs_prefill_global_from_pmem(void);
void slabs_update_policy(void);
int do_slabs_renewslab(const unsigned int id, char *ptr);
void do_slab_realloc(item *it, unsigned int id);
void do_slabs_free(void *ptr, const size_t size, unsigned int id);
#endif
/**
* Given object size, return id to use when allocating/freeing memory for object
* 0 means error: can't store such a large object
*/
unsigned int slabs_clsid(const size_t size);
/** Allocate object of given length. 0 on error */ /*@null@*/
#define SLABS_ALLOC_NO_NEWPAGE 1
void *slabs_alloc(const size_t size, unsigned int id, uint64_t *total_bytes, unsigned int flags);
/** Free previously allocated object */
void slabs_free(void *ptr, size_t size, unsigned int id);
/** Adjust the stats for memory requested */
void slabs_adjust_mem_requested(unsigned int id, size_t old, size_t ntotal);
/** Adjust global memory limit up or down */
bool slabs_adjust_mem_limit(size_t new_mem_limit);
/** Return a datum for stats in binary protocol */
bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c);
typedef struct {
unsigned int chunks_per_page;
unsigned int chunk_size;
long int free_chunks;
long int total_pages;
} slab_stats_automove;
void fill_slab_stats_automove(slab_stats_automove *am);
unsigned int global_page_pool_size(bool *mem_flag);
/** Fill buffer with stats */ /*@null@*/
void slabs_stats(ADD_STAT add_stats, void *c);
/* Hints as to freespace in slab class */
unsigned int slabs_available_chunks(unsigned int id, bool *mem_flag, uint64_t *total_bytes, unsigned int *chunks_perslab);
void slabs_mlock(void);
void slabs_munlock(void);
int start_slab_maintenance_thread(void);
void stop_slab_maintenance_thread(void);
enum reassign_result_type {
REASSIGN_OK=0, REASSIGN_RUNNING, REASSIGN_BADCLASS, REASSIGN_NOSPARE,
REASSIGN_SRC_DST_SAME
};
enum reassign_result_type slabs_reassign(int src, int dst);
void slabs_rebalancer_pause(void);
void slabs_rebalancer_resume(void);
#ifdef EXTSTORE
void slabs_set_storage(void *arg);
#endif
#endif
| 3,024 | 31.180851 | 122 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/pslab.h
|
/*
* Copyright 2018 Lenovo
*
* Licensed under the BSD-3 license. see LICENSE.Lenovo.txt for full text
*/
#ifndef PSLAB_H
#define PSLAB_H
#include <libpmem.h>
#define PSLAB_POLICY_DRAM 0
#define PSLAB_POLICY_PMEM 1
#define PSLAB_POLICY_BALANCED 2
#define pmem_member_persist(p, m) \
pmem_persist(&(p)->m, sizeof ((p)->m))
#define pmem_member_flush(p, m) \
pmem_flush(&(p)->m, sizeof ((p)->m))
#define pmem_flush_from(p, t, m) \
pmem_flush(&(p)->m, sizeof (t) - offsetof(t, m));
#define pslab_item_data_persist(it) pmem_persist((it)->data, ITEM_dtotal(it)
#define pslab_item_data_flush(it) pmem_flush((it)->data, ITEM_dtotal(it))
int pslab_create(char *pool_name, uint32_t pool_size, uint32_t slab_size,
uint32_t *slabclass_sizes, int slabclass_num);
int pslab_pre_recover(char *name, uint32_t *slab_sizes, int slab_max, int slab_page_size);
int pslab_do_recover(void);
time_t pslab_process_started(time_t process_started);
void pslab_update_flushtime(uint32_t time);
void pslab_use_slab(void *p, int id, unsigned int size);
void *pslab_get_free_slab(void *slab);
int pslab_contains(char *p);
uint64_t pslab_addr2off(void *addr);
extern bool pslab_force;
#endif
| 1,186 | 30.236842 | 90 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/config.h
|
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Set to nonzero if you want to include DTRACE */
/* #undef ENABLE_DTRACE */
/* Set to nonzero if you want to include SASL */
/* #undef ENABLE_SASL */
/* Set to nonzero if you want to enable a SASL pwdb */
/* #undef ENABLE_SASL_PWDB */
/* machine is bigendian */
/* #undef ENDIAN_BIG */
/* machine is littleendian */
#define ENDIAN_LITTLE 1
/* Set to nonzero if you want to enable extstorextstore */
/* #undef EXTSTORE */
/* Define to 1 if support accept4 */
#define HAVE_ACCEPT4 1
/* Define to 1 if you have the `clock_gettime' function. */
#define HAVE_CLOCK_GETTIME 1
/* Define this if you have an implementation of drop_privileges() */
/* #undef HAVE_DROP_PRIVILEGES */
/* Define this if you have an implementation of drop_worker_privileges() */
/* #undef HAVE_DROP_WORKER_PRIVILEGES */
/* GCC 64bit Atomics available */
/* #undef HAVE_GCC_64ATOMICS */
/* GCC Atomics available */
#define HAVE_GCC_ATOMICS 1
/* Define to 1 if support getopt_long */
#define HAVE_GETOPT_LONG 1
/* Define to 1 if you have the `getpagesizes' function. */
/* #undef HAVE_GETPAGESIZES */
/* Have ntohll */
/* #undef HAVE_HTONLL */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `memcntl' function. */
/* #undef HAVE_MEMCNTL */
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `mlockall' function. */
#define HAVE_MLOCKALL 1
/* Define to 1 if you have the `pledge' function. */
/* #undef HAVE_PLEDGE */
/* we have sasl_callback_ft */
/* #undef HAVE_SASL_CALLBACK_FT */
/* Set to nonzero if your SASL implementation supports SASL_CB_GETCONF */
/* #undef HAVE_SASL_CB_GETCONF */
/* Define to 1 if you have the <sasl/sasl.h> header file. */
/* #undef HAVE_SASL_SASL_H */
/* Define to 1 if you have the `setppriv' function. */
/* #undef HAVE_SETPPRIV */
/* Define to 1 if you have the `sigignore' function. */
#define HAVE_SIGIGNORE 1
/* Define to 1 if stdbool.h conforms to C99. */
#define HAVE_STDBOOL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define this if you have umem.h */
/* #undef HAVE_UMEM_H */
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if the system has the type `_Bool'. */
#define HAVE__BOOL 1
/* Machine need alignment */
/* #undef NEED_ALIGN */
/* Name of package */
#define PACKAGE "memcached"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "[email protected]"
/* Define to the full name of this package. */
#define PACKAGE_NAME "memcached"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "memcached 1.5.4"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "memcached"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.5.4"
/* Set to nonzero if you want to enable pslab */
#define PSLAB 1
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "1.5.4"
/* find sigignore on Linux */
#define _GNU_SOURCE 1
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* define to int if socklen_t not available */
/* #undef socklen_t */
#if HAVE_STDBOOL_H
#include <stdbool.h>
#else
#define bool char
#define false 0
#define true 1
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
| 4,134 | 24.368098 | 78 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/sasl_defs.h
|
#ifndef SASL_DEFS_H
#define SASL_DEFS_H 1
// Longest one I could find was ``9798-U-RSA-SHA1-ENC''
#define MAX_SASL_MECH_LEN 32
#if defined(HAVE_SASL_SASL_H) && defined(ENABLE_SASL)
#include <sasl/sasl.h>
void init_sasl(void);
extern char my_sasl_hostname[1025];
#else /* End of SASL support */
typedef void* sasl_conn_t;
#define init_sasl() {}
#define sasl_dispose(x) {}
#define sasl_server_new(a, b, c, d, e, f, g, h) 1
#define sasl_listmech(a, b, c, d, e, f, g, h) 1
#define sasl_server_start(a, b, c, d, e, f) 1
#define sasl_server_step(a, b, c, d, e) 1
#define sasl_getprop(a, b, c) {}
#define SASL_OK 0
#define SASL_CONTINUE -1
#endif /* sasl compat */
#endif /* SASL_DEFS_H */
| 693 | 20.6875 | 55 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/logger.h
|
/* logging functions */
#ifndef LOGGER_H
#define LOGGER_H
#include "bipbuffer.h"
/* TODO: starttime tunable */
#define LOGGER_BUF_SIZE 1024 * 64
#define LOGGER_WATCHER_BUF_SIZE 1024 * 256
#define LOGGER_ENTRY_MAX_SIZE 2048
#define GET_LOGGER() ((logger *) pthread_getspecific(logger_key));
/* Inlined from memcached.h - should go into sub header */
typedef unsigned int rel_time_t;
enum log_entry_type {
LOGGER_ASCII_CMD = 0,
LOGGER_EVICTION,
LOGGER_ITEM_GET,
LOGGER_ITEM_STORE,
LOGGER_CRAWLER_STATUS,
LOGGER_SLAB_MOVE,
#ifdef EXTSTORE
LOGGER_EXTSTORE_WRITE,
LOGGER_COMPACT_START,
LOGGER_COMPACT_ABORT,
LOGGER_COMPACT_READ_START,
LOGGER_COMPACT_READ_END,
LOGGER_COMPACT_END,
LOGGER_COMPACT_FRAGINFO,
#endif
};
enum log_entry_subtype {
LOGGER_TEXT_ENTRY = 0,
LOGGER_EVICTION_ENTRY,
LOGGER_ITEM_GET_ENTRY,
LOGGER_ITEM_STORE_ENTRY,
#ifdef EXTSTORE
LOGGER_EXT_WRITE_ENTRY,
#endif
};
enum logger_ret_type {
LOGGER_RET_OK = 0,
LOGGER_RET_NOSPACE,
LOGGER_RET_ERR
};
enum logger_parse_entry_ret {
LOGGER_PARSE_ENTRY_OK = 0,
LOGGER_PARSE_ENTRY_FULLBUF,
LOGGER_PARSE_ENTRY_FAILED
};
typedef const struct {
enum log_entry_subtype subtype;
int reqlen;
uint16_t eflags;
char *format;
} entry_details;
/* log entry intermediary structures */
struct logentry_eviction {
long long int exptime;
uint32_t latime;
uint16_t it_flags;
uint8_t nkey;
uint8_t clsid;
char key[];
};
#ifdef EXTSTORE
struct logentry_ext_write {
long long int exptime;
uint32_t latime;
uint16_t it_flags;
uint8_t nkey;
uint8_t clsid;
uint8_t bucket;
char key[];
};
#endif
struct logentry_item_get {
uint8_t was_found;
uint8_t nkey;
uint8_t clsid;
char key[];
};
struct logentry_item_store {
int status;
int cmd;
rel_time_t ttl;
uint8_t nkey;
uint8_t clsid;
char key[];
};
/* end intermediary structures */
typedef struct _logentry {
enum log_entry_subtype event;
uint16_t eflags;
uint64_t gid;
struct timeval tv; /* not monotonic! */
int size;
union {
void *entry; /* probably an item */
char end;
} data[];
} logentry;
#define LOG_SYSEVENTS (1<<1) /* threads start/stop/working */
#define LOG_FETCHERS (1<<2) /* get/gets/etc */
#define LOG_MUTATIONS (1<<3) /* set/append/incr/etc */
#define LOG_SYSERRORS (1<<4) /* malloc/etc errors */
#define LOG_CONNEVENTS (1<<5) /* new client, closed, etc */
#define LOG_EVICTIONS (1<<6) /* details of evicted items */
#define LOG_STRICT (1<<7) /* block worker instead of drop */
#define LOG_RAWCMDS (1<<9) /* raw ascii commands */
typedef struct _logger {
struct _logger *prev;
struct _logger *next;
pthread_mutex_t mutex; /* guard for this + *buf */
uint64_t written; /* entries written to the buffer */
uint64_t dropped; /* entries dropped */
uint64_t blocked; /* times blocked instead of dropped */
uint16_t fetcher_ratio; /* log one out of every N fetches */
uint16_t mutation_ratio; /* log one out of every N mutations */
uint16_t eflags; /* flags this logger should log */
bipbuf_t *buf;
const entry_details *entry_map;
} logger;
enum logger_watcher_type {
LOGGER_WATCHER_STDERR = 0,
LOGGER_WATCHER_CLIENT = 1
};
typedef struct {
void *c; /* original connection structure. still with source thread attached */
int sfd; /* client fd */
int id; /* id number for watcher list */
uint64_t skipped; /* lines skipped since last successful print */
bool failed_flush; /* recently failed to write out (EAGAIN), wait before retry */
enum logger_watcher_type t; /* stderr, client, syslog, etc */
uint16_t eflags; /* flags we are interested in */
bipbuf_t *buf; /* per-watcher output buffer */
} logger_watcher;
struct logger_stats {
uint64_t worker_dropped;
uint64_t worker_written;
uint64_t watcher_skipped;
uint64_t watcher_sent;
};
extern pthread_key_t logger_key;
/* public functions */
void logger_init(void);
logger *logger_create(void);
#define LOGGER_LOG(l, flag, type, ...) \
do { \
logger *myl = l; \
if (l == NULL) \
myl = GET_LOGGER(); \
if (myl->eflags & flag) \
logger_log(myl, type, __VA_ARGS__); \
} while (0)
enum logger_ret_type logger_log(logger *l, const enum log_entry_type event, const void *entry, ...);
enum logger_add_watcher_ret {
LOGGER_ADD_WATCHER_TOO_MANY = 0,
LOGGER_ADD_WATCHER_OK,
LOGGER_ADD_WATCHER_FAILED
};
enum logger_add_watcher_ret logger_add_watcher(void *c, const int sfd, uint16_t f);
#endif
| 4,680 | 24.032086 | 100 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/extstore.h
|
#ifndef EXTSTORE_H
#define EXTSTORE_H
/* A safe-to-read dataset for determining compaction.
* id is the array index.
*/
struct extstore_page_data {
uint64_t version;
uint64_t bytes_used;
unsigned int bucket;
};
/* Pages can have objects deleted from them at any time. This creates holes
* that can't be reused until the page is either evicted or all objects are
* deleted.
* bytes_fragmented is the total bytes for all of these holes.
* It is the size of all used pages minus each page's bytes_used value.
*/
struct extstore_stats {
uint64_t page_allocs;
uint64_t page_count; /* total page count */
uint64_t page_evictions;
uint64_t page_reclaims;
uint64_t page_size; /* size in bytes per page (supplied by caller) */
uint64_t pages_free; /* currently unallocated/unused pages */
uint64_t pages_used;
uint64_t objects_evicted;
uint64_t objects_read;
uint64_t objects_written;
uint64_t objects_used; /* total number of objects stored */
uint64_t bytes_evicted;
uint64_t bytes_written;
uint64_t bytes_read; /* wbuf - read -> bytes read from storage */
uint64_t bytes_used; /* total number of bytes stored */
uint64_t bytes_fragmented; /* see above comment */
struct extstore_page_data *page_data;
};
// TODO: Temporary configuration structure. A "real" library should have an
// extstore_set(enum, void *ptr) which hides the implementation.
// this is plenty for quick development.
struct extstore_conf {
unsigned int page_size; // ideally 64-256M in size
unsigned int page_count;
unsigned int page_buckets; // number of different writeable pages
unsigned int wbuf_size; // must divide cleanly into page_size
unsigned int wbuf_count; // this might get locked to "2 per active page"
unsigned int io_threadcount;
unsigned int io_depth; // with normal I/O, hits locks less. req'd for AIO
};
enum obj_io_mode {
OBJ_IO_READ = 0,
OBJ_IO_WRITE,
};
typedef struct _obj_io obj_io;
typedef void (*obj_io_cb)(void *e, obj_io *io, int ret);
/* An object for both reads and writes to the storage engine.
* Once an IO is submitted, ->next may be changed by the IO thread. It is not
* safe to further modify the IO stack until the entire request is completed.
*/
struct _obj_io {
void *data; /* user supplied data pointer */
struct _obj_io *next;
char *buf; /* buffer of data to read or write to */
struct iovec *iov; /* alternatively, use this iovec */
unsigned int iovcnt; /* number of IOV's */
unsigned int page_version; /* page version for read mode */
unsigned int len; /* for both modes */
unsigned int offset; /* for read mode */
unsigned short page_id; /* for read mode */
enum obj_io_mode mode;
/* callback pointers? */
obj_io_cb cb;
};
enum extstore_res {
EXTSTORE_INIT_BAD_WBUF_SIZE = 1,
EXTSTORE_INIT_NEED_MORE_WBUF,
EXTSTORE_INIT_NEED_MORE_BUCKETS,
EXTSTORE_INIT_PAGE_WBUF_ALIGNMENT,
EXTSTORE_INIT_OOM,
EXTSTORE_INIT_OPEN_FAIL,
EXTSTORE_INIT_THREAD_FAIL
};
const char *extstore_err(enum extstore_res res);
void *extstore_init(char *fn, struct extstore_conf *cf, enum extstore_res *res);
int extstore_write_request(void *ptr, unsigned int bucket, obj_io *io);
void extstore_write(void *ptr, obj_io *io);
int extstore_submit(void *ptr, obj_io *io);
/* count are the number of objects being removed, bytes are the original
* length of those objects. Bytes is optional but you can't track
* fragmentation without it.
*/
int extstore_check(void *ptr, unsigned int page_id, uint64_t page_version);
int extstore_delete(void *ptr, unsigned int page_id, uint64_t page_version, unsigned int count, unsigned int bytes);
void extstore_get_stats(void *ptr, struct extstore_stats *st);
/* add page data array to a stats structure.
* caller must allocate its stats.page_data memory first.
*/
void extstore_get_page_data(void *ptr, struct extstore_stats *st);
void extstore_run_maint(void *ptr);
void extstore_close_page(void *ptr, unsigned int page_id, uint64_t page_version);
#endif
| 4,091 | 36.541284 | 116 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/assoc.h
|
/* associative array */
void assoc_init(const int hashpower_init);
item *assoc_find(const char *key, const size_t nkey, const uint32_t hv);
int assoc_insert(item *item, const uint32_t hv);
void assoc_delete(const char *key, const size_t nkey, const uint32_t hv);
void do_assoc_move_next_bucket(void);
int start_assoc_maintenance_thread(void);
void stop_assoc_maintenance_thread(void);
extern unsigned int hashpower;
extern unsigned int item_lock_hashpower;
| 457 | 40.636364 | 73 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/run.sh
|
#!/usr/bin/env bash
sudo rm -rf /mnt/mem/*
sed -i "s/Werror/Wno-error" Makefile
make -j USE_PMDK=yes STD=-std=gnu99
sudo ./memcached -u root -m 0 -t 1 -o pslab_policy=pmem,pslab_file=/mnt/mem/pool,pslab_force > out
grep "ulog" out > time
log=$(awk '{sum+= $2;} END{print sum;}' time)
echo $1'log' $log
| 302 | 32.666667 | 98 |
sh
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/slab_automove_extstore.h
|
#ifndef SLAB_AUTOMOVE_EXTSTORE_H
#define SLAB_AUTOMOVE_EXTSTORE_H
void *slab_automove_extstore_init(struct settings *settings);
void slab_automove_extstore_free(void *arg);
void slab_automove_extstore_run(void *arg, int *src, int *dst);
#endif
| 246 | 26.444444 | 63 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/memcached.h
|
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2018 Lenovo
*
* Licensed under the BSD-3 license. see LICENSE.Lenovo.txt for full text
*/
/*
* Note:
* Codes enclosed in `#ifdef PSLAB' and `#endif' are added by Lenovo for
* persistent memory support
*/
/** \file
* The main memcached header holding commonly used data
* structures and function prototypes.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <event.h>
#include <netdb.h>
#include <pthread.h>
#include <unistd.h>
#include <assert.h>
#include "itoa_ljust.h"
#include "protocol_binary.h"
#include "cache.h"
#include "logger.h"
#ifdef EXTSTORE
#include "extstore.h"
#include "crc32c.h"
#endif
#ifdef PSLAB
#include "pslab.h"
#endif
#include "sasl_defs.h"
/** Maximum length of a key. */
#define KEY_MAX_LENGTH 250
/** Size of an incr buf. */
#define INCR_MAX_STORAGE_LEN 24
#define DATA_BUFFER_SIZE 2048
#define UDP_READ_BUFFER_SIZE 65536
#define UDP_MAX_PAYLOAD_SIZE 1400
#define UDP_HEADER_SIZE 8
#define MAX_SENDBUF_SIZE (256 * 1024 * 1024)
/* Up to 3 numbers (2 32bit, 1 64bit), spaces, newlines, null 0 */
#define SUFFIX_SIZE 50
/** Initial size of list of items being returned by "get". */
#define ITEM_LIST_INITIAL 200
/** Initial size of list of CAS suffixes appended to "gets" lines. */
#define SUFFIX_LIST_INITIAL 100
/** Initial size of the sendmsg() scatter/gather array. */
#define IOV_LIST_INITIAL 400
/** Initial number of sendmsg() argument structures to allocate. */
#define MSG_LIST_INITIAL 10
/** High water marks for buffer shrinking */
#define READ_BUFFER_HIGHWAT 8192
#define ITEM_LIST_HIGHWAT 400
#define IOV_LIST_HIGHWAT 600
#define MSG_LIST_HIGHWAT 100
/* Binary protocol stuff */
#define MIN_BIN_PKT_LENGTH 16
#define BIN_PKT_HDR_WORDS (MIN_BIN_PKT_LENGTH/sizeof(uint32_t))
/* Initial power multiplier for the hash table */
#define HASHPOWER_DEFAULT 16
#define HASHPOWER_MAX 32
/*
* We only reposition items in the LRU queue if they haven't been repositioned
* in this many seconds. That saves us from churning on frequently-accessed
* items.
*/
#define ITEM_UPDATE_INTERVAL 60
/* unistd.h is here */
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
/* Slab sizing definitions. */
#ifdef PSLAB
#define POWER_SMALLEST 2
#else
#define POWER_SMALLEST 1
#endif
#define POWER_LARGEST 256 /* actual cap is 255 */
#define SLAB_GLOBAL_PAGE_POOL 0 /* magic slab class for storing pages for reassignment */
#ifdef PSLAB
#define SLAB_GLOBAL_PAGE_POOL_PMEM 1 /* magic slab class for storing pmem pages for reassignment */
#endif
#define CHUNK_ALIGN_BYTES 8
/* slab class max is a 6-bit number, -1. */
#define MAX_NUMBER_OF_SLAB_CLASSES (63 + 1)
/** How long an object can reasonably be assumed to be locked before
harvesting it on a low memory condition. Default: disabled. */
#define TAIL_REPAIR_TIME_DEFAULT 0
/* warning: don't use these macros with a function, as it evals its arg twice */
#define ITEM_get_cas(i) (((i)->it_flags & ITEM_CAS) ? \
(i)->data->cas : (uint64_t)0)
#define ITEM_set_cas(i,v) { \
if ((i)->it_flags & ITEM_CAS) { \
(i)->data->cas = v; \
} \
}
#define ITEM_key(item) (((char*)&((item)->data)) \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#define ITEM_suffix(item) ((char*) &((item)->data) + (item)->nkey + 1 \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#define ITEM_data(item) ((char*) &((item)->data) + (item)->nkey + 1 \
+ (item)->nsuffix \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#define ITEM_ntotal(item) (sizeof(struct _stritem) + (item)->nkey + 1 \
+ (item)->nsuffix + (item)->nbytes \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
#ifdef PSLAB
#define ITEM_dtotal(item) (item)->nkey + 1 + (item)->nsuffix + (item)->nbytes \
+ (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0)
#endif
#define ITEM_clsid(item) ((item)->slabs_clsid & ~(3<<6))
#define ITEM_lruid(item) ((item)->slabs_clsid & (3<<6))
#define STAT_KEY_LEN 128
#define STAT_VAL_LEN 128
/** Append a simple stat with a stat name, value format and value */
#define APPEND_STAT(name, fmt, val) \
append_stat(name, add_stats, c, fmt, val);
/** Append an indexed stat with a stat name (with format), value format
and value */
#define APPEND_NUM_FMT_STAT(name_fmt, num, name, fmt, val) \
klen = snprintf(key_str, STAT_KEY_LEN, name_fmt, num, name); \
vlen = snprintf(val_str, STAT_VAL_LEN, fmt, val); \
add_stats(key_str, klen, val_str, vlen, c);
/** Common APPEND_NUM_FMT_STAT format. */
#define APPEND_NUM_STAT(num, name, fmt, val) \
APPEND_NUM_FMT_STAT("%d:%s", num, name, fmt, val)
/**
* Callback for any function producing stats.
*
* @param key the stat's key
* @param klen length of the key
* @param val the stat's value in an ascii form (e.g. text form of a number)
* @param vlen length of the value
* @parm cookie magic callback cookie
*/
typedef void (*ADD_STAT)(const char *key, const uint16_t klen,
const char *val, const uint32_t vlen,
const void *cookie);
/*
* NOTE: If you modify this table you _MUST_ update the function state_text
*/
/**
* Possible states of a connection.
*/
enum conn_states {
conn_listening, /**< the socket which listens for connections */
conn_new_cmd, /**< Prepare connection for next command */
conn_waiting, /**< waiting for a readable socket */
conn_read, /**< reading in a command line */
conn_parse_cmd, /**< try to parse a command from the input buffer */
conn_write, /**< writing out a simple response */
conn_nread, /**< reading in a fixed number of bytes */
conn_swallow, /**< swallowing unnecessary bytes w/o storing */
conn_closing, /**< closing this connection */
conn_mwrite, /**< writing out many items sequentially */
conn_closed, /**< connection is closed */
conn_watch, /**< held by the logger thread as a watcher */
conn_max_state /**< Max state value (used for assertion) */
};
enum bin_substates {
bin_no_state,
bin_reading_set_header,
bin_reading_cas_header,
bin_read_set_value,
bin_reading_get_key,
bin_reading_stat,
bin_reading_del_header,
bin_reading_incr_header,
bin_read_flush_exptime,
bin_reading_sasl_auth,
bin_reading_sasl_auth_data,
bin_reading_touch_key,
};
enum protocol {
ascii_prot = 3, /* arbitrary value. */
binary_prot,
negotiating_prot /* Discovering the protocol */
};
enum network_transport {
local_transport, /* Unix sockets*/
tcp_transport,
udp_transport
};
enum pause_thread_types {
PAUSE_WORKER_THREADS = 0,
PAUSE_ALL_THREADS,
RESUME_ALL_THREADS,
RESUME_WORKER_THREADS
};
#define IS_TCP(x) (x == tcp_transport)
#define IS_UDP(x) (x == udp_transport)
#define NREAD_ADD 1
#define NREAD_SET 2
#define NREAD_REPLACE 3
#define NREAD_APPEND 4
#define NREAD_PREPEND 5
#define NREAD_CAS 6
enum store_item_type {
NOT_STORED=0, STORED, EXISTS, NOT_FOUND, TOO_LARGE, NO_MEMORY
};
enum delta_result_type {
OK, NON_NUMERIC, EOM, DELTA_ITEM_NOT_FOUND, DELTA_ITEM_CAS_MISMATCH
};
/** Time relative to server start. Smaller than time_t on 64-bit systems. */
// TODO: Move to sub-header. needed in logger.h
//typedef unsigned int rel_time_t;
/** Use X macros to avoid iterating over the stats fields during reset and
* aggregation. No longer have to add new stats in 3+ places.
*/
#define SLAB_STATS_FIELDS \
X(set_cmds) \
X(get_hits) \
X(touch_hits) \
X(delete_hits) \
X(cas_hits) \
X(cas_badval) \
X(incr_hits) \
X(decr_hits)
/** Stats stored per slab (and per thread). */
struct slab_stats {
#define X(name) uint64_t name;
SLAB_STATS_FIELDS
#undef X
};
#define THREAD_STATS_FIELDS \
X(get_cmds) \
X(get_misses) \
X(get_expired) \
X(get_flushed) \
X(touch_cmds) \
X(touch_misses) \
X(delete_misses) \
X(incr_misses) \
X(decr_misses) \
X(cas_misses) \
X(bytes_read) \
X(bytes_written) \
X(flush_cmds) \
X(conn_yields) /* # of yields for connections (-R option)*/ \
X(auth_cmds) \
X(auth_errors) \
X(idle_kicks) /* idle connections killed */
#ifdef EXTSTORE
#define EXTSTORE_THREAD_STATS_FIELDS \
X(get_extstore) \
X(recache_from_extstore) \
X(miss_from_extstore) \
X(badcrc_from_extstore)
#endif
/**
* Stats stored per-thread.
*/
struct thread_stats {
pthread_mutex_t mutex;
#define X(name) uint64_t name;
THREAD_STATS_FIELDS
#ifdef EXTSTORE
EXTSTORE_THREAD_STATS_FIELDS
#endif
#undef X
struct slab_stats slab_stats[MAX_NUMBER_OF_SLAB_CLASSES];
uint64_t lru_hits[POWER_LARGEST];
};
/**
* Global stats. Only resettable stats should go into this structure.
*/
struct stats {
uint64_t total_items;
uint64_t total_conns;
uint64_t rejected_conns;
uint64_t malloc_fails;
uint64_t listen_disabled_num;
uint64_t slabs_moved; /* times slabs were moved around */
uint64_t slab_reassign_rescues; /* items rescued during slab move */
uint64_t slab_reassign_evictions_nomem; /* valid items lost during slab move */
uint64_t slab_reassign_inline_reclaim; /* valid items lost during slab move */
uint64_t slab_reassign_chunk_rescues; /* chunked-item chunks recovered */
uint64_t slab_reassign_busy_items; /* valid temporarily unmovable */
uint64_t slab_reassign_busy_deletes; /* refcounted items killed */
uint64_t lru_crawler_starts; /* Number of item crawlers kicked off */
uint64_t lru_maintainer_juggles; /* number of LRU bg pokes */
uint64_t time_in_listen_disabled_us; /* elapsed time in microseconds while server unable to process new connections */
uint64_t log_worker_dropped; /* logs dropped by worker threads */
uint64_t log_worker_written; /* logs written by worker threads */
uint64_t log_watcher_skipped; /* logs watchers missed */
uint64_t log_watcher_sent; /* logs sent to watcher buffers */
#ifdef EXTSTORE
uint64_t extstore_compact_lost; /* items lost because they were locked */
uint64_t extstore_compact_rescues; /* items re-written during compaction */
uint64_t extstore_compact_skipped; /* unhit items skipped during compaction */
#endif
struct timeval maxconns_entered; /* last time maxconns entered */
};
/**
* Global "state" stats. Reflects state that shouldn't be wiped ever.
* Ordered for some cache line locality for commonly updated counters.
*/
struct stats_state {
uint64_t curr_items;
uint64_t curr_bytes;
uint64_t curr_conns;
uint64_t hash_bytes; /* size used for hash tables */
unsigned int conn_structs;
unsigned int reserved_fds;
unsigned int hash_power_level; /* Better hope it's not over 9000 */
bool hash_is_expanding; /* If the hash table is being expanded */
bool accepting_conns; /* whether we are currently accepting */
bool slab_reassign_running; /* slab reassign in progress */
bool lru_crawler_running; /* crawl in progress */
};
#define MAX_VERBOSITY_LEVEL 2
/* When adding a setting, be sure to update process_stat_settings */
/**
* Globally accessible settings as derived from the commandline.
*/
struct settings {
size_t maxbytes;
int maxconns;
int port;
int udpport;
char *inter;
int verbose;
rel_time_t oldest_live; /* ignore existing items older than this */
uint64_t oldest_cas; /* ignore existing items with CAS values lower than this */
int evict_to_free;
char *socketpath; /* path to unix socket if using local socket */
int access; /* access mask (a la chmod) for unix domain socket */
double factor; /* chunk size growth factor */
int chunk_size;
int num_threads; /* number of worker (without dispatcher) libevent threads to run */
int num_threads_per_udp; /* number of worker threads serving each udp socket */
char prefix_delimiter; /* character that marks a key prefix (for stats) */
int detail_enabled; /* nonzero if we're collecting detailed stats */
int reqs_per_event; /* Maximum number of io to process on each
io-event. */
bool use_cas;
enum protocol binding_protocol;
int backlog;
int item_size_max; /* Maximum item size */
int slab_chunk_size_max; /* Upper end for chunks within slab pages. */
int slab_page_size; /* Slab's page units. */
bool sasl; /* SASL on/off */
bool maxconns_fast; /* Whether or not to early close connections */
bool lru_crawler; /* Whether or not to enable the autocrawler thread */
bool lru_maintainer_thread; /* LRU maintainer background thread */
bool lru_segmented; /* Use split or flat LRU's */
bool slab_reassign; /* Whether or not slab reassignment is allowed */
int slab_automove; /* Whether or not to automatically move slabs */
double slab_automove_ratio; /* youngest must be within pct of oldest */
unsigned int slab_automove_window; /* window mover for algorithm */
int hashpower_init; /* Starting hash power level */
bool shutdown_command; /* allow shutdown command */
int tail_repair_time; /* LRU tail refcount leak repair time */
bool flush_enabled; /* flush_all enabled */
bool dump_enabled; /* whether cachedump/metadump commands work */
char *hash_algorithm; /* Hash algorithm in use */
int lru_crawler_sleep; /* Microsecond sleep between items */
uint32_t lru_crawler_tocrawl; /* Number of items to crawl per run */
int hot_lru_pct; /* percentage of slab space for HOT_LRU */
int warm_lru_pct; /* percentage of slab space for WARM_LRU */
double hot_max_factor; /* HOT tail age relative to COLD tail */
double warm_max_factor; /* WARM tail age relative to COLD tail */
int crawls_persleep; /* Number of LRU crawls to run before sleeping */
bool inline_ascii_response; /* pre-format the VALUE line for ASCII responses */
bool temp_lru; /* TTL < temporary_ttl uses TEMP_LRU */
uint32_t temporary_ttl; /* temporary LRU threshold */
int idle_timeout; /* Number of seconds to let connections idle */
unsigned int logger_watcher_buf_size; /* size of logger's per-watcher buffer */
unsigned int logger_buf_size; /* size of per-thread logger buffer */
bool drop_privileges; /* Whether or not to drop unnecessary process privileges */
bool relaxed_privileges; /* Relax process restrictions when running testapp */
#ifdef EXTSTORE
unsigned int ext_item_size; /* minimum size of items to store externally */
unsigned int ext_item_age; /* max age of tail item before storing ext. */
unsigned int ext_low_ttl; /* remaining TTL below this uses own pages */
unsigned int ext_recache_rate; /* counter++ % recache_rate == 0 > recache */
unsigned int ext_wbuf_size; /* read only note for the engine */
unsigned int ext_compact_under; /* when fewer than this many pages, compact */
unsigned int ext_drop_under; /* when fewer than this many pages, drop COLD items */
double ext_max_frag; /* ideal maximum page fragmentation */
double slab_automove_freeratio; /* % of memory to hold free as buffer */
bool ext_drop_unread; /* skip unread items during compaction */
/* per-slab-class free chunk limit */
unsigned int ext_free_memchunks[MAX_NUMBER_OF_SLAB_CLASSES];
#endif
#ifdef PSLAB
size_t pslab_size; /* pmem slab pool size */
unsigned int pslab_policy; /* pmem slab allocation policy */
bool pslab_recover; /* do recovery from pmem slab pool */
#endif
};
extern struct stats stats;
extern struct stats_state stats_state;
extern time_t process_started;
extern struct settings settings;
#define ITEM_LINKED 1
#define ITEM_CAS 2
/* temp */
#define ITEM_SLABBED 4
/* Item was fetched at least once in its lifetime */
#define ITEM_FETCHED 8
/* Appended on fetch, removed on LRU shuffling */
#define ITEM_ACTIVE 16
/* If an item's storage are chained chunks. */
#define ITEM_CHUNKED 32
#define ITEM_CHUNK 64
#ifdef PSLAB
/* If an item is stored in pmem */
#define ITEM_PSLAB 64
#endif
#ifdef EXTSTORE
/* ITEM_data bulk is external to item */
#define ITEM_HDR 128
#endif
/**
* Structure for storing items within memcached.
*/
typedef struct _stritem {
/* Protected by LRU locks */
struct _stritem *next;
struct _stritem *prev;
/* Rest are protected by an item lock */
struct _stritem *h_next; /* hash chain next */
rel_time_t time; /* least recent access */
rel_time_t exptime; /* expire time */
int nbytes; /* size of data */
unsigned short refcount;
uint8_t nsuffix; /* length of flags-and-length string */
uint8_t it_flags; /* ITEM_* above */
uint8_t slabs_clsid;/* which slab class we're in */
uint8_t nkey; /* key length, w/terminating null and padding */
/* this odd type prevents type-punning issues when we do
* the little shuffle to save space when not using CAS. */
union {
uint64_t cas;
char end;
} data[];
/* if it_flags & ITEM_CAS we have 8 bytes CAS */
/* then null-terminated key */
/* then " flags length\r\n" (no terminating null) */
/* then data with terminating \r\n (no terminating null; it's binary!) */
} item;
// TODO: If we eventually want user loaded modules, we can't use an enum :(
enum crawler_run_type {
CRAWLER_AUTOEXPIRE=0, CRAWLER_EXPIRED, CRAWLER_METADUMP
};
typedef struct {
struct _stritem *next;
struct _stritem *prev;
struct _stritem *h_next; /* hash chain next */
rel_time_t time; /* least recent access */
rel_time_t exptime; /* expire time */
int nbytes; /* size of data */
unsigned short refcount;
uint8_t nsuffix; /* length of flags-and-length string */
uint8_t it_flags; /* ITEM_* above */
uint8_t slabs_clsid;/* which slab class we're in */
uint8_t nkey; /* key length, w/terminating null and padding */
uint32_t remaining; /* Max keys to crawl per slab per invocation */
uint64_t reclaimed; /* items reclaimed during this crawl. */
uint64_t unfetched; /* items reclaimed unfetched during this crawl. */
uint64_t checked; /* items examined during this crawl. */
} crawler;
/* Header when an item is actually a chunk of another item. */
typedef struct _strchunk {
struct _strchunk *next; /* points within its own chain. */
struct _strchunk *prev; /* can potentially point to the head. */
struct _stritem *head; /* always points to the owner chunk */
int size; /* available chunk space in bytes */
int used; /* chunk space used */
int nbytes; /* used. */
unsigned short refcount; /* used? */
uint8_t orig_clsid; /* For obj hdr chunks slabs_clsid is fake. */
uint8_t it_flags; /* ITEM_* above. */
uint8_t slabs_clsid; /* Same as above. */
#ifdef PSLAB
_Bool pslab : 1;
uint64_t next_poff; /* offset of next chunk in pmem */
#endif
char data[];
} item_chunk;
#ifdef EXTSTORE
typedef struct {
unsigned int page_version; /* from IO header */
unsigned int offset; /* from IO header */
unsigned short page_id; /* from IO header */
} item_hdr;
#endif
typedef struct {
pthread_t thread_id; /* unique ID of this thread */
struct event_base *base; /* libevent handle this thread uses */
struct event notify_event; /* listen event for notify pipe */
int notify_receive_fd; /* receiving end of notify pipe */
int notify_send_fd; /* sending end of notify pipe */
struct thread_stats stats; /* Stats generated by this thread */
struct conn_queue *new_conn_queue; /* queue of new connections to handle */
cache_t *suffix_cache; /* suffix cache */
#ifdef EXTSTORE
cache_t *io_cache; /* IO objects */
void *storage; /* data object for storage system */
#endif
logger *l; /* logger buffer */
void *lru_bump_buf; /* async LRU bump buffer */
} LIBEVENT_THREAD;
typedef struct conn conn;
#ifdef EXTSTORE
typedef struct _io_wrap {
obj_io io;
struct _io_wrap *next;
conn *c;
item *hdr_it; /* original header item. */
unsigned int iovec_start; /* start of the iovecs for this IO */
unsigned int iovec_count; /* total number of iovecs */
unsigned int iovec_data; /* specific index of data iovec */
bool miss; /* signal a miss to unlink hdr_it */
bool badcrc; /* signal a crc failure */
bool active; // FIXME: canary for test. remove
} io_wrap;
#endif
/**
* The structure representing a connection into memcached.
*/
struct conn {
int sfd;
sasl_conn_t *sasl_conn;
bool authenticated;
enum conn_states state;
enum bin_substates substate;
rel_time_t last_cmd_time;
struct event event;
short ev_flags;
short which; /** which events were just triggered */
char *rbuf; /** buffer to read commands into */
char *rcurr; /** but if we parsed some already, this is where we stopped */
int rsize; /** total allocated size of rbuf */
int rbytes; /** how much data, starting from rcur, do we have unparsed */
char *wbuf;
char *wcurr;
int wsize;
int wbytes;
/** which state to go into after finishing current write */
enum conn_states write_and_go;
void *write_and_free; /** free this memory after finishing writing */
char *ritem; /** when we read in an item's value, it goes here */
int rlbytes;
/* data for the nread state */
/**
* item is used to hold an item structure created after reading the command
* line of set/add/replace commands, but before we finished reading the actual
* data. The data is read into ITEM_data(item) to avoid extra copying.
*/
void *item; /* for commands set/add/replace */
/* data for the swallow state */
int sbytes; /* how many bytes to swallow */
/* data for the mwrite state */
struct iovec *iov;
int iovsize; /* number of elements allocated in iov[] */
int iovused; /* number of elements used in iov[] */
struct msghdr *msglist;
int msgsize; /* number of elements allocated in msglist[] */
int msgused; /* number of elements used in msglist[] */
int msgcurr; /* element in msglist[] being transmitted now */
int msgbytes; /* number of bytes in current msg */
item **ilist; /* list of items to write out */
int isize;
item **icurr;
int ileft;
char **suffixlist;
int suffixsize;
char **suffixcurr;
int suffixleft;
#ifdef EXTSTORE
int io_wrapleft;
unsigned int recache_counter;
io_wrap *io_wraplist; /* linked list of io_wraps */
bool io_queued; /* FIXME: debugging flag */
#endif
enum protocol protocol; /* which protocol this connection speaks */
enum network_transport transport; /* what transport is used by this connection */
/* data for UDP clients */
int request_id; /* Incoming UDP request ID, if this is a UDP "connection" */
struct sockaddr_in6 request_addr; /* udp: Who sent the most recent request */
socklen_t request_addr_size;
unsigned char *hdrbuf; /* udp packet headers */
int hdrsize; /* number of headers' worth of space is allocated */
bool noreply; /* True if the reply should not be sent. */
/* current stats command */
struct {
char *buffer;
size_t size;
size_t offset;
} stats;
/* Binary protocol stuff */
/* This is where the binary header goes */
protocol_binary_request_header binary_header;
uint64_t cas; /* the cas to return */
short cmd; /* current command being processed */
int opaque;
int keylen;
conn *next; /* Used for generating a list of conn structures */
LIBEVENT_THREAD *thread; /* Pointer to the thread object serving this connection */
uint32_t objid;
};
/* array of conn structures, indexed by file descriptor */
extern conn **conns;
/* current time of day (updated periodically) */
extern volatile rel_time_t current_time;
/* TODO: Move to slabs.h? */
extern volatile int slab_rebalance_signal;
struct slab_rebalance {
void *slab_start;
void *slab_end;
void *slab_pos;
int s_clsid;
int d_clsid;
uint32_t busy_items;
uint32_t rescues;
uint32_t evictions_nomem;
uint32_t inline_reclaim;
uint32_t chunk_rescues;
uint32_t busy_deletes;
uint32_t busy_loops;
uint8_t done;
};
extern struct slab_rebalance slab_rebal;
#ifdef EXTSTORE
extern void *ext_storage;
#endif
/*
* Functions
*/
void do_accept_new_conns(const bool do_accept);
enum delta_result_type do_add_delta(conn *c, const char *key,
const size_t nkey, const bool incr,
const int64_t delta, char *buf,
uint64_t *cas, const uint32_t hv);
enum store_item_type do_store_item(item *item, int comm, conn* c, const uint32_t hv);
conn *conn_new(const int sfd, const enum conn_states init_state, const int event_flags, const int read_buffer_size, enum network_transport transport, struct event_base *base);
void conn_worker_readd(conn *c);
extern int daemonize(int nochdir, int noclose);
#define mutex_lock(x) pthread_mutex_lock(x)
#define mutex_unlock(x) pthread_mutex_unlock(x)
#include "stats.h"
#include "slabs.h"
#include "assoc.h"
#include "items.h"
#include "crawler.h"
#include "trace.h"
#include "hash.h"
#include "util.h"
/*
* Functions such as the libevent-related calls that need to do cross-thread
* communication in multithreaded mode (rather than actually doing the work
* in the current thread) are called via "dispatch_" frontends, which are
* also #define-d to directly call the underlying code in singlethreaded mode.
*/
void memcached_thread_init(int nthreads, void *arg);
void redispatch_conn(conn *c);
void dispatch_conn_new(int sfd, enum conn_states init_state, int event_flags, int read_buffer_size, enum network_transport transport);
void sidethread_conn_close(conn *c);
/* Lock wrappers for cache functions that are called from main loop. */
enum delta_result_type add_delta(conn *c, const char *key,
const size_t nkey, const int incr,
const int64_t delta, char *buf,
uint64_t *cas);
void accept_new_conns(const bool do_accept);
conn *conn_from_freelist(void);
bool conn_add_to_freelist(conn *c);
void conn_close_idle(conn *c);
item *item_alloc(char *key, size_t nkey, int flags, rel_time_t exptime, int nbytes);
#define DO_UPDATE true
#define DONT_UPDATE false
item *item_get(const char *key, const size_t nkey, conn *c, const bool do_update);
item *item_touch(const char *key, const size_t nkey, uint32_t exptime, conn *c);
int item_link(item *it);
void item_remove(item *it);
int item_replace(item *it, item *new_it, const uint32_t hv);
void item_unlink(item *it);
void item_lock(uint32_t hv);
void *item_trylock(uint32_t hv);
void item_trylock_unlock(void *arg);
void item_unlock(uint32_t hv);
void pause_threads(enum pause_thread_types type);
#define refcount_incr(it) ++(it->refcount)
#define refcount_decr(it) --(it->refcount)
void STATS_LOCK(void);
void STATS_UNLOCK(void);
void threadlocal_stats_reset(void);
void threadlocal_stats_aggregate(struct thread_stats *stats);
void slab_stats_aggregate(struct thread_stats *stats, struct slab_stats *out);
/* Stat processing functions */
void append_stat(const char *name, ADD_STAT add_stats, conn *c,
const char *fmt, ...);
enum store_item_type store_item(item *item, int comm, conn *c);
#if HAVE_DROP_PRIVILEGES
extern void drop_privileges(void);
#else
#define drop_privileges()
#endif
#if HAVE_DROP_WORKER_PRIVILEGES
extern void drop_worker_privileges(void);
#else
#define drop_worker_privileges()
#endif
/* If supported, give compiler hints for branch prediction. */
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
#define __builtin_expect(x, expected_value) (x)
#endif
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
| 28,992 | 34.749692 | 175 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/crawler.h
|
#ifndef CRAWLER_H
#define CRAWLER_H
typedef struct {
uint64_t histo[61];
uint64_t ttl_hourplus;
uint64_t noexp;
uint64_t reclaimed;
uint64_t seen;
rel_time_t start_time;
rel_time_t end_time;
bool run_complete;
} crawlerstats_t;
struct crawler_expired_data {
pthread_mutex_t lock;
crawlerstats_t crawlerstats[POWER_LARGEST];
/* redundant with crawlerstats_t so we can get overall start/stop/done */
rel_time_t start_time;
rel_time_t end_time;
bool crawl_complete;
bool is_external; /* whether this was an alloc local or remote to the module. */
};
enum crawler_result_type {
CRAWLER_OK=0, CRAWLER_RUNNING, CRAWLER_BADCLASS, CRAWLER_NOTSTARTED, CRAWLER_ERROR
};
int start_item_crawler_thread(void);
int stop_item_crawler_thread(void);
int init_lru_crawler(void *arg);
enum crawler_result_type lru_crawler_crawl(char *slabs, enum crawler_run_type, void *c, const int sfd);
int lru_crawler_start(uint8_t *ids, uint32_t remaining,
const enum crawler_run_type type, void *data,
void *c, const int sfd);
void lru_crawler_pause(void);
void lru_crawler_resume(void);
#endif
| 1,191 | 29.564103 | 103 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/slab_automove.h
|
#ifndef SLAB_AUTOMOVE_H
#define SLAB_AUTOMOVE_H
/* default automove functions */
void *slab_automove_init(struct settings *settings);
void slab_automove_free(void *arg);
void slab_automove_run(void *arg, int *src, int *dst);
typedef void *(*slab_automove_init_func)(struct settings *settings);
typedef void (*slab_automove_free_func)(void *arg);
typedef void (*slab_automove_run_func)(void *arg, int *src, int *dst);
typedef struct {
slab_automove_init_func init;
slab_automove_free_func free;
slab_automove_run_func run;
} slab_automove_reg_t;
#endif
| 568 | 27.45 | 70 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/storage.h
|
#ifndef STORAGE_H
#define STORAGE_H
int lru_maintainer_store(void *storage, const int clsid);
int start_storage_compact_thread(void *arg);
void storage_compact_pause(void);
void storage_compact_resume(void);
#endif
| 217 | 20.8 | 57 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/stats.h
|
/* stats */
void stats_prefix_init(void);
void stats_prefix_clear(void);
void stats_prefix_record_get(const char *key, const size_t nkey, const bool is_hit);
void stats_prefix_record_delete(const char *key, const size_t nkey);
void stats_prefix_record_set(const char *key, const size_t nkey);
/*@null@*/
char *stats_prefix_dump(int *length);
| 342 | 37.111111 | 84 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/itoa_ljust.h
|
#ifndef ITOA_LJUST_H
#define ITOA_LJUST_H
//=== itoa_ljust.h - Fast integer to ascii conversion
//
// Fast and simple integer to ASCII conversion:
//
// - 32 and 64-bit integers
// - signed and unsigned
// - user supplied buffer must be large enough for all decimal digits
// in value plus minus sign if negative
// - left-justified
// - NUL terminated
// - return value is pointer to NUL terminator
//
// Copyright (c) 2016 Arturo Martin-de-Nicolas
// [email protected]
// https://github.com/amdn/itoa_ljust/
//===----------------------------------------------------------------------===//
#include <stdint.h>
char* itoa_u32(uint32_t u, char* buffer);
char* itoa_32( int32_t i, char* buffer);
char* itoa_u64(uint64_t u, char* buffer);
char* itoa_64( int64_t i, char* buffer);
#endif // ITOA_LJUST_H
| 822 | 27.37931 | 80 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/murmur3_hash.h
|
//-----------------------------------------------------------------------------
// MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
#ifndef MURMURHASH3_H
#define MURMURHASH3_H
//-----------------------------------------------------------------------------
// Platform-specific functions and macros
#include <stdint.h>
#include <stddef.h>
//-----------------------------------------------------------------------------
uint32_t MurmurHash3_x86_32(const void *key, size_t length);
//-----------------------------------------------------------------------------
#endif // MURMURHASH3_H
| 681 | 33.1 | 79 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/util.h
|
/* fast-enough functions for uriencoding strings. */
void uriencode_init(void);
bool uriencode(const char *src, char *dst, const size_t srclen, const size_t dstlen);
/*
* Wrappers around strtoull/strtoll that are safer and easier to
* use. For tests and assumptions, see internal_tests.c.
*
* str a NULL-terminated base decimal 10 unsigned integer
* out out parameter, if conversion succeeded
*
* returns true if conversion succeeded.
*/
bool safe_strtoull(const char *str, uint64_t *out);
bool safe_strtoll(const char *str, int64_t *out);
bool safe_strtoul(const char *str, uint32_t *out);
bool safe_strtol(const char *str, int32_t *out);
bool safe_strtod(const char *str, double *out);
#ifndef HAVE_HTONLL
extern uint64_t htonll(uint64_t);
extern uint64_t ntohll(uint64_t);
#endif
#ifdef __GCC
# define __gcc_attribute__ __attribute__
#else
# define __gcc_attribute__(x)
#endif
/**
* Vararg variant of perror that makes for more useful error messages
* when reporting with parameters.
*
* @param fmt a printf format
*/
void vperror(const char *fmt, ...)
__gcc_attribute__ ((format (printf, 1, 2)));
| 1,127 | 27.923077 | 85 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/protocol_binary.h
|
/*
* Copyright (c) <2008>, Sun Microsystems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY SUN MICROSYSTEMS, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Summary: Constants used by to implement the binary protocol.
*
* Copy: See Copyright for the status of this software.
*
* Author: Trond Norbye <[email protected]>
*/
#ifndef PROTOCOL_BINARY_H
#define PROTOCOL_BINARY_H
/**
* This file contains definitions of the constants and packet formats
* defined in the binary specification. Please note that you _MUST_ remember
* to convert each multibyte field to / from network byte order to / from
* host order.
*/
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Definition of the legal "magic" values used in a packet.
* See section 3.1 Magic byte
*/
typedef enum {
PROTOCOL_BINARY_REQ = 0x80,
PROTOCOL_BINARY_RES = 0x81
} protocol_binary_magic;
/**
* Definition of the valid response status numbers.
* See section 3.2 Response Status
*/
typedef enum {
PROTOCOL_BINARY_RESPONSE_SUCCESS = 0x00,
PROTOCOL_BINARY_RESPONSE_KEY_ENOENT = 0x01,
PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS = 0x02,
PROTOCOL_BINARY_RESPONSE_E2BIG = 0x03,
PROTOCOL_BINARY_RESPONSE_EINVAL = 0x04,
PROTOCOL_BINARY_RESPONSE_NOT_STORED = 0x05,
PROTOCOL_BINARY_RESPONSE_DELTA_BADVAL = 0x06,
PROTOCOL_BINARY_RESPONSE_AUTH_ERROR = 0x20,
PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE = 0x21,
PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND = 0x81,
PROTOCOL_BINARY_RESPONSE_ENOMEM = 0x82
} protocol_binary_response_status;
/**
* Definition of the different command opcodes.
* See section 3.3 Command Opcodes
*/
typedef enum {
PROTOCOL_BINARY_CMD_GET = 0x00,
PROTOCOL_BINARY_CMD_SET = 0x01,
PROTOCOL_BINARY_CMD_ADD = 0x02,
PROTOCOL_BINARY_CMD_REPLACE = 0x03,
PROTOCOL_BINARY_CMD_DELETE = 0x04,
PROTOCOL_BINARY_CMD_INCREMENT = 0x05,
PROTOCOL_BINARY_CMD_DECREMENT = 0x06,
PROTOCOL_BINARY_CMD_QUIT = 0x07,
PROTOCOL_BINARY_CMD_FLUSH = 0x08,
PROTOCOL_BINARY_CMD_GETQ = 0x09,
PROTOCOL_BINARY_CMD_NOOP = 0x0a,
PROTOCOL_BINARY_CMD_VERSION = 0x0b,
PROTOCOL_BINARY_CMD_GETK = 0x0c,
PROTOCOL_BINARY_CMD_GETKQ = 0x0d,
PROTOCOL_BINARY_CMD_APPEND = 0x0e,
PROTOCOL_BINARY_CMD_PREPEND = 0x0f,
PROTOCOL_BINARY_CMD_STAT = 0x10,
PROTOCOL_BINARY_CMD_SETQ = 0x11,
PROTOCOL_BINARY_CMD_ADDQ = 0x12,
PROTOCOL_BINARY_CMD_REPLACEQ = 0x13,
PROTOCOL_BINARY_CMD_DELETEQ = 0x14,
PROTOCOL_BINARY_CMD_INCREMENTQ = 0x15,
PROTOCOL_BINARY_CMD_DECREMENTQ = 0x16,
PROTOCOL_BINARY_CMD_QUITQ = 0x17,
PROTOCOL_BINARY_CMD_FLUSHQ = 0x18,
PROTOCOL_BINARY_CMD_APPENDQ = 0x19,
PROTOCOL_BINARY_CMD_PREPENDQ = 0x1a,
PROTOCOL_BINARY_CMD_TOUCH = 0x1c,
PROTOCOL_BINARY_CMD_GAT = 0x1d,
PROTOCOL_BINARY_CMD_GATQ = 0x1e,
PROTOCOL_BINARY_CMD_GATK = 0x23,
PROTOCOL_BINARY_CMD_GATKQ = 0x24,
PROTOCOL_BINARY_CMD_SASL_LIST_MECHS = 0x20,
PROTOCOL_BINARY_CMD_SASL_AUTH = 0x21,
PROTOCOL_BINARY_CMD_SASL_STEP = 0x22,
/* These commands are used for range operations and exist within
* this header for use in other projects. Range operations are
* not expected to be implemented in the memcached server itself.
*/
PROTOCOL_BINARY_CMD_RGET = 0x30,
PROTOCOL_BINARY_CMD_RSET = 0x31,
PROTOCOL_BINARY_CMD_RSETQ = 0x32,
PROTOCOL_BINARY_CMD_RAPPEND = 0x33,
PROTOCOL_BINARY_CMD_RAPPENDQ = 0x34,
PROTOCOL_BINARY_CMD_RPREPEND = 0x35,
PROTOCOL_BINARY_CMD_RPREPENDQ = 0x36,
PROTOCOL_BINARY_CMD_RDELETE = 0x37,
PROTOCOL_BINARY_CMD_RDELETEQ = 0x38,
PROTOCOL_BINARY_CMD_RINCR = 0x39,
PROTOCOL_BINARY_CMD_RINCRQ = 0x3a,
PROTOCOL_BINARY_CMD_RDECR = 0x3b,
PROTOCOL_BINARY_CMD_RDECRQ = 0x3c
/* End Range operations */
} protocol_binary_command;
/**
* Definition of the data types in the packet
* See section 3.4 Data Types
*/
typedef enum {
PROTOCOL_BINARY_RAW_BYTES = 0x00
} protocol_binary_datatypes;
/**
* Definition of the header structure for a request packet.
* See section 2
*/
typedef union {
struct {
uint8_t magic;
uint8_t opcode;
uint16_t keylen;
uint8_t extlen;
uint8_t datatype;
uint16_t reserved;
uint32_t bodylen;
uint32_t opaque;
uint64_t cas;
} request;
uint8_t bytes[24];
} protocol_binary_request_header;
/**
* Definition of the header structure for a response packet.
* See section 2
*/
typedef union {
struct {
uint8_t magic;
uint8_t opcode;
uint16_t keylen;
uint8_t extlen;
uint8_t datatype;
uint16_t status;
uint32_t bodylen;
uint32_t opaque;
uint64_t cas;
} response;
uint8_t bytes[24];
} protocol_binary_response_header;
/**
* Definition of a request-packet containing no extras
*/
typedef union {
struct {
protocol_binary_request_header header;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header)];
} protocol_binary_request_no_extras;
/**
* Definition of a response-packet containing no extras
*/
typedef union {
struct {
protocol_binary_response_header header;
} message;
uint8_t bytes[sizeof(protocol_binary_response_header)];
} protocol_binary_response_no_extras;
/**
* Definition of the packet used by the get, getq, getk and getkq command.
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_get;
typedef protocol_binary_request_no_extras protocol_binary_request_getq;
typedef protocol_binary_request_no_extras protocol_binary_request_getk;
typedef protocol_binary_request_no_extras protocol_binary_request_getkq;
/**
* Definition of the packet returned from a successful get, getq, getk and
* getkq.
* See section 4
*/
typedef union {
struct {
protocol_binary_response_header header;
struct {
uint32_t flags;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_response_header) + 4];
} protocol_binary_response_get;
typedef protocol_binary_response_get protocol_binary_response_getq;
typedef protocol_binary_response_get protocol_binary_response_getk;
typedef protocol_binary_response_get protocol_binary_response_getkq;
/**
* Definition of the packet used by the delete command
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_delete;
/**
* Definition of the packet returned by the delete command
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_delete;
/**
* Definition of the packet used by the flush command
* See section 4
* Please note that the expiration field is optional, so remember to see
* check the header.bodysize to see if it is present.
*/
typedef union {
struct {
protocol_binary_request_header header;
struct {
uint32_t expiration;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header) + 4];
} protocol_binary_request_flush;
/**
* Definition of the packet returned by the flush command
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_flush;
/**
* Definition of the packet used by set, add and replace
* See section 4
*/
typedef union {
struct {
protocol_binary_request_header header;
struct {
uint32_t flags;
uint32_t expiration;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header) + 8];
} protocol_binary_request_set;
typedef protocol_binary_request_set protocol_binary_request_add;
typedef protocol_binary_request_set protocol_binary_request_replace;
/**
* Definition of the packet returned by set, add and replace
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_set;
typedef protocol_binary_response_no_extras protocol_binary_response_add;
typedef protocol_binary_response_no_extras protocol_binary_response_replace;
/**
* Definition of the noop packet
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_noop;
/**
* Definition of the packet returned by the noop command
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_noop;
/**
* Definition of the structure used by the increment and decrement
* command.
* See section 4
*/
typedef union {
struct {
protocol_binary_request_header header;
struct {
uint64_t delta;
uint64_t initial;
uint32_t expiration;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header) + 20];
} protocol_binary_request_incr;
typedef protocol_binary_request_incr protocol_binary_request_decr;
/**
* Definition of the response from an incr or decr command
* command.
* See section 4
*/
typedef union {
struct {
protocol_binary_response_header header;
struct {
uint64_t value;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_response_header) + 8];
} protocol_binary_response_incr;
typedef protocol_binary_response_incr protocol_binary_response_decr;
/**
* Definition of the quit
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_quit;
/**
* Definition of the packet returned by the quit command
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_quit;
/**
* Definition of the packet used by append and prepend command
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_append;
typedef protocol_binary_request_no_extras protocol_binary_request_prepend;
/**
* Definition of the packet returned from a successful append or prepend
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_append;
typedef protocol_binary_response_no_extras protocol_binary_response_prepend;
/**
* Definition of the packet used by the version command
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_version;
/**
* Definition of the packet returned from a successful version command
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_version;
/**
* Definition of the packet used by the stats command.
* See section 4
*/
typedef protocol_binary_request_no_extras protocol_binary_request_stats;
/**
* Definition of the packet returned from a successful stats command
* See section 4
*/
typedef protocol_binary_response_no_extras protocol_binary_response_stats;
/**
* Definition of the packet used by the touch command.
*/
typedef union {
struct {
protocol_binary_request_header header;
struct {
uint32_t expiration;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header) + 4];
} protocol_binary_request_touch;
/**
* Definition of the packet returned from the touch command
*/
typedef protocol_binary_response_no_extras protocol_binary_response_touch;
/**
* Definition of the packet used by the GAT(Q) command.
*/
typedef union {
struct {
protocol_binary_request_header header;
struct {
uint32_t expiration;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header) + 4];
} protocol_binary_request_gat;
typedef protocol_binary_request_gat protocol_binary_request_gatq;
typedef protocol_binary_request_gat protocol_binary_request_gatk;
typedef protocol_binary_request_gat protocol_binary_request_gatkq;
/**
* Definition of the packet returned from the GAT(Q)
*/
typedef protocol_binary_response_get protocol_binary_response_gat;
typedef protocol_binary_response_get protocol_binary_response_gatq;
typedef protocol_binary_response_get protocol_binary_response_gatk;
typedef protocol_binary_response_get protocol_binary_response_gatkq;
/**
* Definition of a request for a range operation.
* See http://code.google.com/p/memcached/wiki/RangeOps
*
* These types are used for range operations and exist within
* this header for use in other projects. Range operations are
* not expected to be implemented in the memcached server itself.
*/
typedef union {
struct {
protocol_binary_response_header header;
struct {
uint16_t size;
uint8_t reserved;
uint8_t flags;
uint32_t max_results;
} body;
} message;
uint8_t bytes[sizeof(protocol_binary_request_header) + 4];
} protocol_binary_request_rangeop;
typedef protocol_binary_request_rangeop protocol_binary_request_rget;
typedef protocol_binary_request_rangeop protocol_binary_request_rset;
typedef protocol_binary_request_rangeop protocol_binary_request_rsetq;
typedef protocol_binary_request_rangeop protocol_binary_request_rappend;
typedef protocol_binary_request_rangeop protocol_binary_request_rappendq;
typedef protocol_binary_request_rangeop protocol_binary_request_rprepend;
typedef protocol_binary_request_rangeop protocol_binary_request_rprependq;
typedef protocol_binary_request_rangeop protocol_binary_request_rdelete;
typedef protocol_binary_request_rangeop protocol_binary_request_rdeleteq;
typedef protocol_binary_request_rangeop protocol_binary_request_rincr;
typedef protocol_binary_request_rangeop protocol_binary_request_rincrq;
typedef protocol_binary_request_rangeop protocol_binary_request_rdecr;
typedef protocol_binary_request_rangeop protocol_binary_request_rdecrq;
#ifdef __cplusplus
}
#endif
#endif /* PROTOCOL_BINARY_H */
| 16,525 | 34.087049 | 80 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/items.h
|
/*
* Copyright 2018 Lenovo
*
* Licensed under the BSD-3 license. see LICENSE.Lenovo.txt for full text
*/
/*
* Note:
* Codes enclosed in `#ifdef PSLAB' and `#endif' are added by Lenovo for
* persistent memory support
*/
#define HOT_LRU 0
#define WARM_LRU 64
#define COLD_LRU 128
#define TEMP_LRU 192
#define CLEAR_LRU(id) (id & ~(3<<6))
#define GET_LRU(id) (id & (3<<6))
/* See items.c */
uint64_t get_cas_id(void);
/*@null@*/
item *do_item_alloc(char *key, const size_t nkey, const unsigned int flags, const rel_time_t exptime, const int nbytes);
item_chunk *do_item_alloc_chunk(item_chunk *ch, const size_t bytes_remain);
item *do_item_alloc_pull(const size_t ntotal, const unsigned int id);
void item_free(item *it);
bool item_size_ok(const size_t nkey, const int flags, const int nbytes);
int do_item_link(item *it, const uint32_t hv); /** may fail if transgresses limits */
#ifdef PSLAB
void do_item_relink(item *it, const uint32_t hv);
#endif
void do_item_unlink(item *it, const uint32_t hv);
void do_item_unlink_nolock(item *it, const uint32_t hv);
void do_item_remove(item *it);
void do_item_update(item *it); /** update LRU time to current and reposition */
void do_item_update_nolock(item *it);
int do_item_replace(item *it, item *new_it, const uint32_t hv);
int item_is_flushed(item *it);
void do_item_linktail_q(item *it);
void do_item_unlinktail_q(item *it);
item *do_item_crawl_q(item *it);
void *item_lru_bump_buf_create(void);
#define LRU_PULL_EVICT 1
#define LRU_PULL_CRAWL_BLOCKS 2
#define LRU_PULL_RETURN_ITEM 4 /* fill info struct if available */
struct lru_pull_tail_return {
item *it;
uint32_t hv;
};
int lru_pull_tail(const int orig_id, const int cur_lru,
const uint64_t total_bytes, const uint8_t flags, const rel_time_t max_age,
struct lru_pull_tail_return *ret_it);
/*@null@*/
char *item_cachedump(const unsigned int slabs_clsid, const unsigned int limit, unsigned int *bytes);
void item_stats(ADD_STAT add_stats, void *c);
void do_item_stats_add_crawl(const int i, const uint64_t reclaimed,
const uint64_t unfetched, const uint64_t checked);
void item_stats_totals(ADD_STAT add_stats, void *c);
/*@null@*/
void item_stats_sizes(ADD_STAT add_stats, void *c);
void item_stats_sizes_init(void);
void item_stats_sizes_enable(ADD_STAT add_stats, void *c);
void item_stats_sizes_disable(ADD_STAT add_stats, void *c);
void item_stats_sizes_add(item *it);
void item_stats_sizes_remove(item *it);
bool item_stats_sizes_status(void);
/* stats getter for slab automover */
typedef struct {
int64_t evicted;
int64_t outofmemory;
uint32_t age;
} item_stats_automove;
void fill_item_stats_automove(item_stats_automove *am);
item *do_item_get(const char *key, const size_t nkey, const uint32_t hv, conn *c, const bool do_update);
item *do_item_touch(const char *key, const size_t nkey, uint32_t exptime, const uint32_t hv, conn *c);
void item_stats_reset(void);
extern pthread_mutex_t lru_locks[POWER_LARGEST];
int start_lru_maintainer_thread(void *arg);
int stop_lru_maintainer_thread(void);
int init_lru_maintainer(void);
void lru_maintainer_pause(void);
void lru_maintainer_resume(void);
void *lru_bump_buf_create(void);
#ifdef EXTSTORE
#define STORAGE_delete(e, it) \
do { \
if (it->it_flags & ITEM_HDR) { \
item_hdr *hdr = (item_hdr *)ITEM_data(it); \
extstore_delete(e, hdr->page_id, hdr->page_version, \
1, ITEM_ntotal(it)); \
} \
} while (0)
#else
#define STORAGE_delete(...)
#endif
| 3,550 | 31.577982 | 120 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/trace.h
|
#ifndef TRACE_H
#define TRACE_H
#ifdef ENABLE_DTRACE
#include "memcached_dtrace.h"
#else
#define MEMCACHED_ASSOC_DELETE(arg0, arg1, arg2)
#define MEMCACHED_ASSOC_DELETE_ENABLED() (0)
#define MEMCACHED_ASSOC_FIND(arg0, arg1, arg2)
#define MEMCACHED_ASSOC_FIND_ENABLED() (0)
#define MEMCACHED_ASSOC_INSERT(arg0, arg1, arg2)
#define MEMCACHED_ASSOC_INSERT_ENABLED() (0)
#define MEMCACHED_COMMAND_ADD(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_ADD_ENABLED() (0)
#define MEMCACHED_COMMAND_APPEND(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_APPEND_ENABLED() (0)
#define MEMCACHED_COMMAND_CAS(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_CAS_ENABLED() (0)
#define MEMCACHED_COMMAND_DECR(arg0, arg1, arg2, arg3)
#define MEMCACHED_COMMAND_DECR_ENABLED() (0)
#define MEMCACHED_COMMAND_DELETE(arg0, arg1, arg2)
#define MEMCACHED_COMMAND_DELETE_ENABLED() (0)
#define MEMCACHED_COMMAND_GET(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_GET_ENABLED() (0)
#define MEMCACHED_COMMAND_TOUCH(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_TOUCH_ENABLED() (0)
#define MEMCACHED_COMMAND_INCR(arg0, arg1, arg2, arg3)
#define MEMCACHED_COMMAND_INCR_ENABLED() (0)
#define MEMCACHED_COMMAND_PREPEND(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_PREPEND_ENABLED() (0)
#define MEMCACHED_COMMAND_REPLACE(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_REPLACE_ENABLED() (0)
#define MEMCACHED_COMMAND_SET(arg0, arg1, arg2, arg3, arg4)
#define MEMCACHED_COMMAND_SET_ENABLED() (0)
#define MEMCACHED_CONN_ALLOCATE(arg0)
#define MEMCACHED_CONN_ALLOCATE_ENABLED() (0)
#define MEMCACHED_CONN_CREATE(arg0)
#define MEMCACHED_CONN_CREATE_ENABLED() (0)
#define MEMCACHED_CONN_DESTROY(arg0)
#define MEMCACHED_CONN_DESTROY_ENABLED() (0)
#define MEMCACHED_CONN_DISPATCH(arg0, arg1)
#define MEMCACHED_CONN_DISPATCH_ENABLED() (0)
#define MEMCACHED_CONN_RELEASE(arg0)
#define MEMCACHED_CONN_RELEASE_ENABLED() (0)
#define MEMCACHED_ITEM_LINK(arg0, arg1, arg2)
#define MEMCACHED_ITEM_LINK_ENABLED() (0)
#define MEMCACHED_ITEM_REMOVE(arg0, arg1, arg2)
#define MEMCACHED_ITEM_REMOVE_ENABLED() (0)
#define MEMCACHED_ITEM_REPLACE(arg0, arg1, arg2, arg3, arg4, arg5)
#define MEMCACHED_ITEM_REPLACE_ENABLED() (0)
#define MEMCACHED_ITEM_UNLINK(arg0, arg1, arg2)
#define MEMCACHED_ITEM_UNLINK_ENABLED() (0)
#define MEMCACHED_ITEM_UPDATE(arg0, arg1, arg2)
#define MEMCACHED_ITEM_UPDATE_ENABLED() (0)
#define MEMCACHED_PROCESS_COMMAND_END(arg0, arg1, arg2)
#define MEMCACHED_PROCESS_COMMAND_END_ENABLED() (0)
#define MEMCACHED_PROCESS_COMMAND_START(arg0, arg1, arg2)
#define MEMCACHED_PROCESS_COMMAND_START_ENABLED() (0)
#define MEMCACHED_SLABS_ALLOCATE(arg0, arg1, arg2, arg3)
#define MEMCACHED_SLABS_ALLOCATE_ENABLED() (0)
#define MEMCACHED_SLABS_ALLOCATE_FAILED(arg0, arg1)
#define MEMCACHED_SLABS_ALLOCATE_FAILED_ENABLED() (0)
#define MEMCACHED_SLABS_FREE(arg0, arg1, arg2)
#define MEMCACHED_SLABS_FREE_ENABLED() (0)
#define MEMCACHED_SLABS_SLABCLASS_ALLOCATE(arg0)
#define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_ENABLED() (0)
#define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_FAILED(arg0)
#define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_FAILED_ENABLED() (0)
#endif
#endif
| 3,179 | 43.166667 | 66 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/jenkins_hash.h
|
#ifndef JENKINS_HASH_H
#define JENKINS_HASH_H
#ifdef __cplusplus
extern "C" {
#endif
uint32_t jenkins_hash(const void *key, size_t length);
#ifdef __cplusplus
}
#endif
#endif /* JENKINS_HASH_H */
| 213 | 12.375 | 54 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/cache.h
|
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#ifndef CACHE_H
#define CACHE_H
#include <pthread.h>
#ifdef HAVE_UMEM_H
#include <umem.h>
#define cache_t umem_cache_t
#define cache_alloc(a) umem_cache_alloc(a, UMEM_DEFAULT)
#define do_cache_alloc(a) umem_cache_alloc(a, UMEM_DEFAULT)
#define cache_free(a, b) umem_cache_free(a, b)
#define do_cache_free(a, b) umem_cache_free(a, b)
#define cache_create(a,b,c,d,e) umem_cache_create((char*)a, b, c, d, e, NULL, NULL, NULL, 0)
#define cache_destroy(a) umem_cache_destroy(a);
#else
#ifndef NDEBUG
/* may be used for debug purposes */
extern int cache_error;
#endif
/**
* Constructor used to initialize allocated objects
*
* @param obj pointer to the object to initialized.
* @param notused1 This parameter is currently not used.
* @param notused2 This parameter is currently not used.
* @return you should return 0, but currently this is not checked
*/
typedef int cache_constructor_t(void* obj, void* notused1, int notused2);
/**
* Destructor used to clean up allocated objects before they are
* returned to the operating system.
*
* @param obj pointer to the object to clean up.
* @param notused1 This parameter is currently not used.
* @param notused2 This parameter is currently not used.
* @return you should return 0, but currently this is not checked
*/
typedef void cache_destructor_t(void* obj, void* notused);
/**
* Definition of the structure to keep track of the internal details of
* the cache allocator. Touching any of these variables results in
* undefined behavior.
*/
typedef struct {
/** Mutex to protect access to the structure */
pthread_mutex_t mutex;
/** Name of the cache objects in this cache (provided by the caller) */
char *name;
/** List of pointers to available buffers in this cache */
void **ptr;
/** The size of each element in this cache */
size_t bufsize;
/** The capacity of the list of elements */
int freetotal;
/** The current number of free elements */
int freecurr;
/** The constructor to be called each time we allocate more memory */
cache_constructor_t* constructor;
/** The destructor to be called each time before we release memory */
cache_destructor_t* destructor;
} cache_t;
/**
* Create an object cache.
*
* The object cache will let you allocate objects of the same size. It is fully
* MT safe, so you may allocate objects from multiple threads without having to
* do any synchronization in the application code.
*
* @param name the name of the object cache. This name may be used for debug purposes
* and may help you track down what kind of object you have problems with
* (buffer overruns, leakage etc)
* @param bufsize the size of each object in the cache
* @param align the alignment requirements of the objects in the cache.
* @param constructor the function to be called to initialize memory when we need
* to allocate more memory from the os.
* @param destructor the function to be called before we release the memory back
* to the os.
* @return a handle to an object cache if successful, NULL otherwise.
*/
cache_t* cache_create(const char* name, size_t bufsize, size_t align,
cache_constructor_t* constructor,
cache_destructor_t* destructor);
/**
* Destroy an object cache.
*
* Destroy and invalidate an object cache. You should return all buffers allocated
* with cache_alloc by using cache_free before calling this function. Not doing
* so results in undefined behavior (the buffers may or may not be invalidated)
*
* @param handle the handle to the object cache to destroy.
*/
void cache_destroy(cache_t* handle);
/**
* Allocate an object from the cache.
*
* @param handle the handle to the object cache to allocate from
* @return a pointer to an initialized object from the cache, or NULL if
* the allocation cannot be satisfied.
*/
void* cache_alloc(cache_t* handle);
void* do_cache_alloc(cache_t* handle);
/**
* Return an object back to the cache.
*
* The caller should return the object in an initialized state so that
* the object may be returned in an expected state from cache_alloc.
*
* @param handle handle to the object cache to return the object to
* @param ptr pointer to the object to return.
*/
void cache_free(cache_t* handle, void* ptr);
void do_cache_free(cache_t* handle, void* ptr);
#endif
#endif
| 4,498 | 36.181818 | 92 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/bipbuffer.h
|
#ifndef BIPBUFFER_H
#define BIPBUFFER_H
typedef struct
{
unsigned long int size;
/* region A */
unsigned int a_start, a_end;
/* region B */
unsigned int b_end;
/* is B inuse? */
int b_inuse;
unsigned char data[];
} bipbuf_t;
/**
* Create a new bip buffer.
*
* malloc()s space
*
* @param[in] size The size of the buffer */
bipbuf_t *bipbuf_new(const unsigned int size);
/**
* Initialise a bip buffer. Use memory provided by user.
*
* No malloc()s are performed.
*
* @param[in] size The size of the array */
void bipbuf_init(bipbuf_t* me, const unsigned int size);
/**
* Free the bip buffer */
void bipbuf_free(bipbuf_t *me);
/* TODO: DOCUMENTATION */
unsigned char *bipbuf_request(bipbuf_t* me, const int size);
int bipbuf_push(bipbuf_t* me, const int size);
/**
* @param[in] data The data to be offered to the buffer
* @param[in] size The size of the data to be offered
* @return number of bytes offered */
int bipbuf_offer(bipbuf_t *me, const unsigned char *data, const int size);
/**
* Look at data. Don't move cursor
*
* @param[in] len The length of the data to be peeked
* @return data on success, NULL if we can't peek at this much data */
unsigned char *bipbuf_peek(const bipbuf_t* me, const unsigned int len);
/**
* Look at data. Don't move cursor
*
* @param[in] len The length of the data returned
* @return data on success, NULL if nothing available */
unsigned char *bipbuf_peek_all(const bipbuf_t* me, unsigned int *len);
/**
* Get pointer to data to read. Move the cursor on.
*
* @param[in] len The length of the data to be polled
* @return pointer to data, NULL if we can't poll this much data */
unsigned char *bipbuf_poll(bipbuf_t* me, const unsigned int size);
/**
* @return the size of the bipbuffer */
int bipbuf_size(const bipbuf_t* me);
/**
* @return 1 if buffer is empty; 0 otherwise */
int bipbuf_is_empty(const bipbuf_t* me);
/**
* @return how much space we have assigned */
int bipbuf_used(const bipbuf_t* cb);
/**
* @return bytes of unused space */
int bipbuf_unused(const bipbuf_t* me);
#endif /* BIPBUFFER_H */
| 2,118 | 23.079545 | 74 |
h
|
null |
NearPMSW-main/nearpm/logging/memcached-pmem-NDP/hash.h
|
#ifndef HASH_H
#define HASH_H
typedef uint32_t (*hash_func)(const void *key, size_t length);
hash_func hash;
enum hashfunc_type {
JENKINS_HASH=0, MURMUR3_HASH
};
int hash_init(enum hashfunc_type type);
#endif /* HASH_H */
| 237 | 14.866667 | 62 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/run.sh
|
#!/usr/bin/env bash
sudo rm -rf /mnt/mem/*
make -j USE_PMDK=yes STD=-std=gnu99
sudo ./src/redis-server redis.conf1 > out
grep "ulog" out > time
log=$(awk '{sum+= $2;} END{print sum;}' time)
echo $1'log' $log
| 208 | 25.125 | 45 |
sh
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/help.h
|
/* Automatically generated by utils/generate-command-help.rb, do not edit. */
#ifndef __REDIS_HELP_H
#define __REDIS_HELP_H
static char *commandGroups[] = {
"generic",
"string",
"list",
"set",
"sorted_set",
"hash",
"pubsub",
"transactions",
"connection",
"server",
"scripting",
"hyperloglog",
"cluster",
"geo"
};
struct commandHelp {
char *name;
char *params;
char *summary;
int group;
char *since;
} commandHelp[] = {
{ "APPEND",
"key value",
"Append a value to a key",
1,
"2.0.0" },
{ "AUTH",
"password",
"Authenticate to the server",
8,
"1.0.0" },
{ "BGREWRITEAOF",
"-",
"Asynchronously rewrite the append-only file",
9,
"1.0.0" },
{ "BGSAVE",
"-",
"Asynchronously save the dataset to disk",
9,
"1.0.0" },
{ "BITCOUNT",
"key [start end]",
"Count set bits in a string",
1,
"2.6.0" },
{ "BITFIELD",
"key [GET type offset] [SET type offset value] [INCRBY type offset increment] [OVERFLOW WRAP|SAT|FAIL]",
"Perform arbitrary bitfield integer operations on strings",
1,
"3.2.0" },
{ "BITOP",
"operation destkey key [key ...]",
"Perform bitwise operations between strings",
1,
"2.6.0" },
{ "BITPOS",
"key bit [start] [end]",
"Find first bit set or clear in a string",
1,
"2.8.7" },
{ "BLPOP",
"key [key ...] timeout",
"Remove and get the first element in a list, or block until one is available",
2,
"2.0.0" },
{ "BRPOP",
"key [key ...] timeout",
"Remove and get the last element in a list, or block until one is available",
2,
"2.0.0" },
{ "BRPOPLPUSH",
"source destination timeout",
"Pop a value from a list, push it to another list and return it; or block until one is available",
2,
"2.2.0" },
{ "CLIENT GETNAME",
"-",
"Get the current connection name",
9,
"2.6.9" },
{ "CLIENT KILL",
"[ip:port] [ID client-id] [TYPE normal|master|slave|pubsub] [ADDR ip:port] [SKIPME yes/no]",
"Kill the connection of a client",
9,
"2.4.0" },
{ "CLIENT LIST",
"-",
"Get the list of client connections",
9,
"2.4.0" },
{ "CLIENT PAUSE",
"timeout",
"Stop processing commands from clients for some time",
9,
"2.9.50" },
{ "CLIENT REPLY",
"ON|OFF|SKIP",
"Instruct the server whether to reply to commands",
9,
"3.2" },
{ "CLIENT SETNAME",
"connection-name",
"Set the current connection name",
9,
"2.6.9" },
{ "CLUSTER ADDSLOTS",
"slot [slot ...]",
"Assign new hash slots to receiving node",
12,
"3.0.0" },
{ "CLUSTER COUNT-FAILURE-REPORTS",
"node-id",
"Return the number of failure reports active for a given node",
12,
"3.0.0" },
{ "CLUSTER COUNTKEYSINSLOT",
"slot",
"Return the number of local keys in the specified hash slot",
12,
"3.0.0" },
{ "CLUSTER DELSLOTS",
"slot [slot ...]",
"Set hash slots as unbound in receiving node",
12,
"3.0.0" },
{ "CLUSTER FAILOVER",
"[FORCE|TAKEOVER]",
"Forces a slave to perform a manual failover of its master.",
12,
"3.0.0" },
{ "CLUSTER FORGET",
"node-id",
"Remove a node from the nodes table",
12,
"3.0.0" },
{ "CLUSTER GETKEYSINSLOT",
"slot count",
"Return local key names in the specified hash slot",
12,
"3.0.0" },
{ "CLUSTER INFO",
"-",
"Provides info about Redis Cluster node state",
12,
"3.0.0" },
{ "CLUSTER KEYSLOT",
"key",
"Returns the hash slot of the specified key",
12,
"3.0.0" },
{ "CLUSTER MEET",
"ip port",
"Force a node cluster to handshake with another node",
12,
"3.0.0" },
{ "CLUSTER NODES",
"-",
"Get Cluster config for the node",
12,
"3.0.0" },
{ "CLUSTER REPLICATE",
"node-id",
"Reconfigure a node as a slave of the specified master node",
12,
"3.0.0" },
{ "CLUSTER RESET",
"[HARD|SOFT]",
"Reset a Redis Cluster node",
12,
"3.0.0" },
{ "CLUSTER SAVECONFIG",
"-",
"Forces the node to save cluster state on disk",
12,
"3.0.0" },
{ "CLUSTER SET-CONFIG-EPOCH",
"config-epoch",
"Set the configuration epoch in a new node",
12,
"3.0.0" },
{ "CLUSTER SETSLOT",
"slot IMPORTING|MIGRATING|STABLE|NODE [node-id]",
"Bind a hash slot to a specific node",
12,
"3.0.0" },
{ "CLUSTER SLAVES",
"node-id",
"List slave nodes of the specified master node",
12,
"3.0.0" },
{ "CLUSTER SLOTS",
"-",
"Get array of Cluster slot to node mappings",
12,
"3.0.0" },
{ "COMMAND",
"-",
"Get array of Redis command details",
9,
"2.8.13" },
{ "COMMAND COUNT",
"-",
"Get total number of Redis commands",
9,
"2.8.13" },
{ "COMMAND GETKEYS",
"-",
"Extract keys given a full Redis command",
9,
"2.8.13" },
{ "COMMAND INFO",
"command-name [command-name ...]",
"Get array of specific Redis command details",
9,
"2.8.13" },
{ "CONFIG GET",
"parameter",
"Get the value of a configuration parameter",
9,
"2.0.0" },
{ "CONFIG RESETSTAT",
"-",
"Reset the stats returned by INFO",
9,
"2.0.0" },
{ "CONFIG REWRITE",
"-",
"Rewrite the configuration file with the in memory configuration",
9,
"2.8.0" },
{ "CONFIG SET",
"parameter value",
"Set a configuration parameter to the given value",
9,
"2.0.0" },
{ "DBSIZE",
"-",
"Return the number of keys in the selected database",
9,
"1.0.0" },
{ "DEBUG OBJECT",
"key",
"Get debugging information about a key",
9,
"1.0.0" },
{ "DEBUG SEGFAULT",
"-",
"Make the server crash",
9,
"1.0.0" },
{ "DECR",
"key",
"Decrement the integer value of a key by one",
1,
"1.0.0" },
{ "DECRBY",
"key decrement",
"Decrement the integer value of a key by the given number",
1,
"1.0.0" },
{ "DEL",
"key [key ...]",
"Delete a key",
0,
"1.0.0" },
{ "DISCARD",
"-",
"Discard all commands issued after MULTI",
7,
"2.0.0" },
{ "DUMP",
"key",
"Return a serialized version of the value stored at the specified key.",
0,
"2.6.0" },
{ "ECHO",
"message",
"Echo the given string",
8,
"1.0.0" },
{ "EVAL",
"script numkeys key [key ...] arg [arg ...]",
"Execute a Lua script server side",
10,
"2.6.0" },
{ "EVALSHA",
"sha1 numkeys key [key ...] arg [arg ...]",
"Execute a Lua script server side",
10,
"2.6.0" },
{ "EXEC",
"-",
"Execute all commands issued after MULTI",
7,
"1.2.0" },
{ "EXISTS",
"key [key ...]",
"Determine if a key exists",
0,
"1.0.0" },
{ "EXPIRE",
"key seconds",
"Set a key's time to live in seconds",
0,
"1.0.0" },
{ "EXPIREAT",
"key timestamp",
"Set the expiration for a key as a UNIX timestamp",
0,
"1.2.0" },
{ "FLUSHALL",
"-",
"Remove all keys from all databases",
9,
"1.0.0" },
{ "FLUSHDB",
"-",
"Remove all keys from the current database",
9,
"1.0.0" },
{ "GEOADD",
"key longitude latitude member [longitude latitude member ...]",
"Add one or more geospatial items in the geospatial index represented using a sorted set",
13,
"3.2.0" },
{ "GEODIST",
"key member1 member2 [unit]",
"Returns the distance between two members of a geospatial index",
13,
"3.2.0" },
{ "GEOHASH",
"key member [member ...]",
"Returns members of a geospatial index as standard geohash strings",
13,
"3.2.0" },
{ "GEOPOS",
"key member [member ...]",
"Returns longitude and latitude of members of a geospatial index",
13,
"3.2.0" },
{ "GEORADIUS",
"key longitude latitude radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]",
"Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point",
13,
"3.2.0" },
{ "GEORADIUSBYMEMBER",
"key member radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]",
"Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member",
13,
"3.2.0" },
{ "GET",
"key",
"Get the value of a key",
1,
"1.0.0" },
{ "GETBIT",
"key offset",
"Returns the bit value at offset in the string value stored at key",
1,
"2.2.0" },
{ "GETRANGE",
"key start end",
"Get a substring of the string stored at a key",
1,
"2.4.0" },
{ "GETSET",
"key value",
"Set the string value of a key and return its old value",
1,
"1.0.0" },
{ "HDEL",
"key field [field ...]",
"Delete one or more hash fields",
5,
"2.0.0" },
{ "HEXISTS",
"key field",
"Determine if a hash field exists",
5,
"2.0.0" },
{ "HGET",
"key field",
"Get the value of a hash field",
5,
"2.0.0" },
{ "HGETALL",
"key",
"Get all the fields and values in a hash",
5,
"2.0.0" },
{ "HINCRBY",
"key field increment",
"Increment the integer value of a hash field by the given number",
5,
"2.0.0" },
{ "HINCRBYFLOAT",
"key field increment",
"Increment the float value of a hash field by the given amount",
5,
"2.6.0" },
{ "HKEYS",
"key",
"Get all the fields in a hash",
5,
"2.0.0" },
{ "HLEN",
"key",
"Get the number of fields in a hash",
5,
"2.0.0" },
{ "HMGET",
"key field [field ...]",
"Get the values of all the given hash fields",
5,
"2.0.0" },
{ "HMSET",
"key field value [field value ...]",
"Set multiple hash fields to multiple values",
5,
"2.0.0" },
{ "HSCAN",
"key cursor [MATCH pattern] [COUNT count]",
"Incrementally iterate hash fields and associated values",
5,
"2.8.0" },
{ "HSET",
"key field value",
"Set the string value of a hash field",
5,
"2.0.0" },
{ "HSETNX",
"key field value",
"Set the value of a hash field, only if the field does not exist",
5,
"2.0.0" },
{ "HSTRLEN",
"key field",
"Get the length of the value of a hash field",
5,
"3.2.0" },
{ "HVALS",
"key",
"Get all the values in a hash",
5,
"2.0.0" },
{ "INCR",
"key",
"Increment the integer value of a key by one",
1,
"1.0.0" },
{ "INCRBY",
"key increment",
"Increment the integer value of a key by the given amount",
1,
"1.0.0" },
{ "INCRBYFLOAT",
"key increment",
"Increment the float value of a key by the given amount",
1,
"2.6.0" },
{ "INFO",
"[section]",
"Get information and statistics about the server",
9,
"1.0.0" },
{ "KEYS",
"pattern",
"Find all keys matching the given pattern",
0,
"1.0.0" },
{ "LASTSAVE",
"-",
"Get the UNIX time stamp of the last successful save to disk",
9,
"1.0.0" },
{ "LINDEX",
"key index",
"Get an element from a list by its index",
2,
"1.0.0" },
{ "LINSERT",
"key BEFORE|AFTER pivot value",
"Insert an element before or after another element in a list",
2,
"2.2.0" },
{ "LLEN",
"key",
"Get the length of a list",
2,
"1.0.0" },
{ "LPOP",
"key",
"Remove and get the first element in a list",
2,
"1.0.0" },
{ "LPUSH",
"key value [value ...]",
"Prepend one or multiple values to a list",
2,
"1.0.0" },
{ "LPUSHX",
"key value",
"Prepend a value to a list, only if the list exists",
2,
"2.2.0" },
{ "LRANGE",
"key start stop",
"Get a range of elements from a list",
2,
"1.0.0" },
{ "LREM",
"key count value",
"Remove elements from a list",
2,
"1.0.0" },
{ "LSET",
"key index value",
"Set the value of an element in a list by its index",
2,
"1.0.0" },
{ "LTRIM",
"key start stop",
"Trim a list to the specified range",
2,
"1.0.0" },
{ "MGET",
"key [key ...]",
"Get the values of all the given keys",
1,
"1.0.0" },
{ "MIGRATE",
"host port key|"" destination-db timeout [COPY] [REPLACE] [KEYS key]",
"Atomically transfer a key from a Redis instance to another one.",
0,
"2.6.0" },
{ "MONITOR",
"-",
"Listen for all requests received by the server in real time",
9,
"1.0.0" },
{ "MOVE",
"key db",
"Move a key to another database",
0,
"1.0.0" },
{ "MSET",
"key value [key value ...]",
"Set multiple keys to multiple values",
1,
"1.0.1" },
{ "MSETNX",
"key value [key value ...]",
"Set multiple keys to multiple values, only if none of the keys exist",
1,
"1.0.1" },
{ "MULTI",
"-",
"Mark the start of a transaction block",
7,
"1.2.0" },
{ "OBJECT",
"subcommand [arguments [arguments ...]]",
"Inspect the internals of Redis objects",
0,
"2.2.3" },
{ "PERSIST",
"key",
"Remove the expiration from a key",
0,
"2.2.0" },
{ "PEXPIRE",
"key milliseconds",
"Set a key's time to live in milliseconds",
0,
"2.6.0" },
{ "PEXPIREAT",
"key milliseconds-timestamp",
"Set the expiration for a key as a UNIX timestamp specified in milliseconds",
0,
"2.6.0" },
{ "PFADD",
"key element [element ...]",
"Adds the specified elements to the specified HyperLogLog.",
11,
"2.8.9" },
{ "PFCOUNT",
"key [key ...]",
"Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s).",
11,
"2.8.9" },
{ "PFMERGE",
"destkey sourcekey [sourcekey ...]",
"Merge N different HyperLogLogs into a single one.",
11,
"2.8.9" },
{ "PING",
"[message]",
"Ping the server",
8,
"1.0.0" },
{ "PSETEX",
"key milliseconds value",
"Set the value and expiration in milliseconds of a key",
1,
"2.6.0" },
{ "PSUBSCRIBE",
"pattern [pattern ...]",
"Listen for messages published to channels matching the given patterns",
6,
"2.0.0" },
{ "PTTL",
"key",
"Get the time to live for a key in milliseconds",
0,
"2.6.0" },
{ "PUBLISH",
"channel message",
"Post a message to a channel",
6,
"2.0.0" },
{ "PUBSUB",
"subcommand [argument [argument ...]]",
"Inspect the state of the Pub/Sub subsystem",
6,
"2.8.0" },
{ "PUNSUBSCRIBE",
"[pattern [pattern ...]]",
"Stop listening for messages posted to channels matching the given patterns",
6,
"2.0.0" },
{ "QUIT",
"-",
"Close the connection",
8,
"1.0.0" },
{ "RANDOMKEY",
"-",
"Return a random key from the keyspace",
0,
"1.0.0" },
{ "READONLY",
"-",
"Enables read queries for a connection to a cluster slave node",
12,
"3.0.0" },
{ "READWRITE",
"-",
"Disables read queries for a connection to a cluster slave node",
12,
"3.0.0" },
{ "RENAME",
"key newkey",
"Rename a key",
0,
"1.0.0" },
{ "RENAMENX",
"key newkey",
"Rename a key, only if the new key does not exist",
0,
"1.0.0" },
{ "RESTORE",
"key ttl serialized-value [REPLACE]",
"Create a key using the provided serialized value, previously obtained using DUMP.",
0,
"2.6.0" },
{ "ROLE",
"-",
"Return the role of the instance in the context of replication",
9,
"2.8.12" },
{ "RPOP",
"key",
"Remove and get the last element in a list",
2,
"1.0.0" },
{ "RPOPLPUSH",
"source destination",
"Remove the last element in a list, prepend it to another list and return it",
2,
"1.2.0" },
{ "RPUSH",
"key value [value ...]",
"Append one or multiple values to a list",
2,
"1.0.0" },
{ "RPUSHX",
"key value",
"Append a value to a list, only if the list exists",
2,
"2.2.0" },
{ "SADD",
"key member [member ...]",
"Add one or more members to a set",
3,
"1.0.0" },
{ "SAVE",
"-",
"Synchronously save the dataset to disk",
9,
"1.0.0" },
{ "SCAN",
"cursor [MATCH pattern] [COUNT count]",
"Incrementally iterate the keys space",
0,
"2.8.0" },
{ "SCARD",
"key",
"Get the number of members in a set",
3,
"1.0.0" },
{ "SCRIPT DEBUG",
"YES|SYNC|NO",
"Set the debug mode for executed scripts.",
10,
"3.2.0" },
{ "SCRIPT EXISTS",
"script [script ...]",
"Check existence of scripts in the script cache.",
10,
"2.6.0" },
{ "SCRIPT FLUSH",
"-",
"Remove all the scripts from the script cache.",
10,
"2.6.0" },
{ "SCRIPT KILL",
"-",
"Kill the script currently in execution.",
10,
"2.6.0" },
{ "SCRIPT LOAD",
"script",
"Load the specified Lua script into the script cache.",
10,
"2.6.0" },
{ "SDIFF",
"key [key ...]",
"Subtract multiple sets",
3,
"1.0.0" },
{ "SDIFFSTORE",
"destination key [key ...]",
"Subtract multiple sets and store the resulting set in a key",
3,
"1.0.0" },
{ "SELECT",
"index",
"Change the selected database for the current connection",
8,
"1.0.0" },
{ "SET",
"key value [EX seconds] [PX milliseconds] [NX|XX]",
"Set the string value of a key",
1,
"1.0.0" },
{ "SETBIT",
"key offset value",
"Sets or clears the bit at offset in the string value stored at key",
1,
"2.2.0" },
{ "SETEX",
"key seconds value",
"Set the value and expiration of a key",
1,
"2.0.0" },
{ "SETNX",
"key value",
"Set the value of a key, only if the key does not exist",
1,
"1.0.0" },
{ "SETRANGE",
"key offset value",
"Overwrite part of a string at key starting at the specified offset",
1,
"2.2.0" },
{ "SHUTDOWN",
"[NOSAVE|SAVE]",
"Synchronously save the dataset to disk and then shut down the server",
9,
"1.0.0" },
{ "SINTER",
"key [key ...]",
"Intersect multiple sets",
3,
"1.0.0" },
{ "SINTERSTORE",
"destination key [key ...]",
"Intersect multiple sets and store the resulting set in a key",
3,
"1.0.0" },
{ "SISMEMBER",
"key member",
"Determine if a given value is a member of a set",
3,
"1.0.0" },
{ "SLAVEOF",
"host port",
"Make the server a slave of another instance, or promote it as master",
9,
"1.0.0" },
{ "SLOWLOG",
"subcommand [argument]",
"Manages the Redis slow queries log",
9,
"2.2.12" },
{ "SMEMBERS",
"key",
"Get all the members in a set",
3,
"1.0.0" },
{ "SMOVE",
"source destination member",
"Move a member from one set to another",
3,
"1.0.0" },
{ "SORT",
"key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]",
"Sort the elements in a list, set or sorted set",
0,
"1.0.0" },
{ "SPOP",
"key [count]",
"Remove and return one or multiple random members from a set",
3,
"1.0.0" },
{ "SRANDMEMBER",
"key [count]",
"Get one or multiple random members from a set",
3,
"1.0.0" },
{ "SREM",
"key member [member ...]",
"Remove one or more members from a set",
3,
"1.0.0" },
{ "SSCAN",
"key cursor [MATCH pattern] [COUNT count]",
"Incrementally iterate Set elements",
3,
"2.8.0" },
{ "STRLEN",
"key",
"Get the length of the value stored in a key",
1,
"2.2.0" },
{ "SUBSCRIBE",
"channel [channel ...]",
"Listen for messages published to the given channels",
6,
"2.0.0" },
{ "SUNION",
"key [key ...]",
"Add multiple sets",
3,
"1.0.0" },
{ "SUNIONSTORE",
"destination key [key ...]",
"Add multiple sets and store the resulting set in a key",
3,
"1.0.0" },
{ "SYNC",
"-",
"Internal command used for replication",
9,
"1.0.0" },
{ "TIME",
"-",
"Return the current server time",
9,
"2.6.0" },
{ "TTL",
"key",
"Get the time to live for a key",
0,
"1.0.0" },
{ "TYPE",
"key",
"Determine the type stored at key",
0,
"1.0.0" },
{ "UNSUBSCRIBE",
"[channel [channel ...]]",
"Stop listening for messages posted to the given channels",
6,
"2.0.0" },
{ "UNWATCH",
"-",
"Forget about all watched keys",
7,
"2.2.0" },
{ "WAIT",
"numslaves timeout",
"Wait for the synchronous replication of all the write commands sent in the context of the current connection",
0,
"3.0.0" },
{ "WATCH",
"key [key ...]",
"Watch the given keys to determine execution of the MULTI/EXEC block",
7,
"2.2.0" },
{ "ZADD",
"key [NX|XX] [CH] [INCR] score member [score member ...]",
"Add one or more members to a sorted set, or update its score if it already exists",
4,
"1.2.0" },
{ "ZCARD",
"key",
"Get the number of members in a sorted set",
4,
"1.2.0" },
{ "ZCOUNT",
"key min max",
"Count the members in a sorted set with scores within the given values",
4,
"2.0.0" },
{ "ZINCRBY",
"key increment member",
"Increment the score of a member in a sorted set",
4,
"1.2.0" },
{ "ZINTERSTORE",
"destination numkeys key [key ...] [WEIGHTS weight] [AGGREGATE SUM|MIN|MAX]",
"Intersect multiple sorted sets and store the resulting sorted set in a new key",
4,
"2.0.0" },
{ "ZLEXCOUNT",
"key min max",
"Count the number of members in a sorted set between a given lexicographical range",
4,
"2.8.9" },
{ "ZRANGE",
"key start stop [WITHSCORES]",
"Return a range of members in a sorted set, by index",
4,
"1.2.0" },
{ "ZRANGEBYLEX",
"key min max [LIMIT offset count]",
"Return a range of members in a sorted set, by lexicographical range",
4,
"2.8.9" },
{ "ZRANGEBYSCORE",
"key min max [WITHSCORES] [LIMIT offset count]",
"Return a range of members in a sorted set, by score",
4,
"1.0.5" },
{ "ZRANK",
"key member",
"Determine the index of a member in a sorted set",
4,
"2.0.0" },
{ "ZREM",
"key member [member ...]",
"Remove one or more members from a sorted set",
4,
"1.2.0" },
{ "ZREMRANGEBYLEX",
"key min max",
"Remove all members in a sorted set between the given lexicographical range",
4,
"2.8.9" },
{ "ZREMRANGEBYRANK",
"key start stop",
"Remove all members in a sorted set within the given indexes",
4,
"2.0.0" },
{ "ZREMRANGEBYSCORE",
"key min max",
"Remove all members in a sorted set within the given scores",
4,
"1.2.0" },
{ "ZREVRANGE",
"key start stop [WITHSCORES]",
"Return a range of members in a sorted set, by index, with scores ordered from high to low",
4,
"1.2.0" },
{ "ZREVRANGEBYLEX",
"key max min [LIMIT offset count]",
"Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings.",
4,
"2.8.9" },
{ "ZREVRANGEBYSCORE",
"key max min [WITHSCORES] [LIMIT offset count]",
"Return a range of members in a sorted set, by score, with scores ordered from high to low",
4,
"2.2.0" },
{ "ZREVRANK",
"key member",
"Determine the index of a member in a sorted set, with scores ordered from high to low",
4,
"2.0.0" },
{ "ZSCAN",
"key cursor [MATCH pattern] [COUNT count]",
"Incrementally iterate sorted sets elements and associated scores",
4,
"2.8.0" },
{ "ZSCORE",
"key member",
"Get the score associated with the given member in a sorted set",
4,
"1.2.0" },
{ "ZUNIONSTORE",
"destination numkeys key [key ...] [WEIGHTS weight] [AGGREGATE SUM|MIN|MAX]",
"Add multiple sorted sets and store the resulting sorted set in a new key",
4,
"2.0.0" }
};
#endif
| 24,462 | 23.030452 | 134 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/sha1.h
|
#ifndef SHA1_H
#define SHA1_H
/* ================ sha1.h ================ */
/*
SHA-1 in C
By Steve Reid <[email protected]>
100% Public Domain
*/
typedef struct {
uint32_t state[5];
uint32_t count[2];
unsigned char buffer[64];
} SHA1_CTX;
void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
void SHA1Init(SHA1_CTX* context);
void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
#ifdef REDIS_TEST
int sha1Test(int argc, char **argv);
#endif
#endif
| 566 | 21.68 | 76 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/config.h
|
/*
* Copyright (c) 2009-2012, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __CONFIG_H
#define __CONFIG_H
#ifdef __APPLE__
#include <AvailabilityMacros.h>
#endif
#ifdef __linux__
#include <linux/version.h>
#include <features.h>
#endif
/* Define redis_fstat to fstat or fstat64() */
#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6)
#define redis_fstat fstat64
#define redis_stat stat64
#else
#define redis_fstat fstat
#define redis_stat stat
#endif
/* Test for proc filesystem */
#ifdef __linux__
#define HAVE_PROC_STAT 1
#define HAVE_PROC_MAPS 1
#define HAVE_PROC_SMAPS 1
#define HAVE_PROC_SOMAXCONN 1
#endif
/* Test for task_info() */
#if defined(__APPLE__)
#define HAVE_TASKINFO 1
#endif
/* Test for backtrace() */
#if defined(__APPLE__) || (defined(__linux__) && defined(__GLIBC__))
#define HAVE_BACKTRACE 1
#endif
/* MSG_NOSIGNAL. */
#ifdef __linux__
#define HAVE_MSG_NOSIGNAL 1
#endif
/* Test for polling API */
#ifdef __linux__
#define HAVE_EPOLL 1
#endif
#if (defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__)
#define HAVE_KQUEUE 1
#endif
#ifdef __sun
#include <sys/feature_tests.h>
#ifdef _DTRACE_VERSION
#define HAVE_EVPORT 1
#endif
#endif
/* Define aof_fsync to fdatasync() in Linux and fsync() for all the rest */
#ifdef __linux__
#define aof_fsync fdatasync
#else
#define aof_fsync fsync
#endif
/* Define rdb_fsync_range to sync_file_range() on Linux, otherwise we use
* the plain fsync() call. */
#ifdef __linux__
#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
#if (LINUX_VERSION_CODE >= 0x020611 && __GLIBC_PREREQ(2, 6))
#define HAVE_SYNC_FILE_RANGE 1
#endif
#else
#if (LINUX_VERSION_CODE >= 0x020611)
#define HAVE_SYNC_FILE_RANGE 1
#endif
#endif
#endif
#ifdef HAVE_SYNC_FILE_RANGE
#define rdb_fsync_range(fd,off,size) sync_file_range(fd,off,size,SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE)
#else
#define rdb_fsync_range(fd,off,size) fsync(fd)
#endif
/* Check if we can use setproctitle().
* BSD systems have support for it, we provide an implementation for
* Linux and osx. */
#if (defined __NetBSD__ || defined __FreeBSD__ || defined __OpenBSD__)
#define USE_SETPROCTITLE
#endif
#if ((defined __linux && defined(__GLIBC__)) || defined __APPLE__)
#define USE_SETPROCTITLE
#define INIT_SETPROCTITLE_REPLACEMENT
void spt_init(int argc, char *argv[]);
void setproctitle(const char *fmt, ...);
#endif
/* Byte ordering detection */
#include <sys/types.h> /* This will likely define BYTE_ORDER */
#ifndef BYTE_ORDER
#if (BSD >= 199103)
# include <machine/endian.h>
#else
#if defined(linux) || defined(__linux__)
# include <endian.h>
#else
#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
#if defined(__i386__) || defined(__x86_64__) || defined(__amd64__) || \
defined(vax) || defined(ns32000) || defined(sun386) || \
defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
defined(__alpha__) || defined(__alpha)
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
defined(apollo) || defined(__convex__) || defined(_CRAY) || \
defined(__hppa) || defined(__hp9000) || \
defined(__hp9000s300) || defined(__hp9000s700) || \
defined (BIT_ZERO_ON_LEFT) || defined(m68k) || defined(__sparc)
#define BYTE_ORDER BIG_ENDIAN
#endif
#endif /* linux */
#endif /* BSD */
#endif /* BYTE_ORDER */
/* Sometimes after including an OS-specific header that defines the
* endianess we end with __BYTE_ORDER but not with BYTE_ORDER that is what
* the Redis code uses. In this case let's define everything without the
* underscores. */
#ifndef BYTE_ORDER
#ifdef __BYTE_ORDER
#if defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN)
#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN __LITTLE_ENDIAN
#endif
#ifndef BIG_ENDIAN
#define BIG_ENDIAN __BIG_ENDIAN
#endif
#if (__BYTE_ORDER == __LITTLE_ENDIAN)
#define BYTE_ORDER LITTLE_ENDIAN
#else
#define BYTE_ORDER BIG_ENDIAN
#endif
#endif
#endif
#endif
#if !defined(BYTE_ORDER) || \
(BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN)
/* you must determine what the correct bit order is for
* your compiler - the next line is an intentional error
* which will force your compiles to bomb until you fix
* the above macros.
*/
#error "Undefined or invalid BYTE_ORDER"
#endif
#if (__i386 || __amd64 || __powerpc__) && __GNUC__
#define GNUC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if defined(__clang__)
#define HAVE_ATOMIC
#endif
#if (defined(__GLIBC__) && defined(__GLIBC_PREREQ))
#if (GNUC_VERSION >= 40100 && __GLIBC_PREREQ(2, 6))
#define HAVE_ATOMIC
#endif
#endif
#endif
#endif
| 6,550 | 30.195238 | 130 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/bio.h
|
/*
* Copyright (c) 2009-2012, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* Exported API */
void bioInit(void);
void bioCreateBackgroundJob(int type, void *arg1, void *arg2, void *arg3);
unsigned long long bioPendingJobsOfType(int type);
void bioWaitPendingJobsLE(int type, unsigned long long num);
time_t bioOlderJobOfType(int type);
void bioKillThreads(void);
/* Background job opcodes */
#define BIO_CLOSE_FILE 0 /* Deferred close(2) syscall. */
#define BIO_AOF_FSYNC 1 /* Deferred AOF fsync. */
#define BIO_NUM_OPS 2
| 2,073 | 48.380952 | 78 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/ae.h
|
/* A simple event-driven programming library. Originally I wrote this code
* for the Jim's event-loop (Jim is a Tcl interpreter) but later translated
* it in form of a library for easy reuse.
*
* Copyright (c) 2006-2012, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __AE_H__
#define __AE_H__
#include <time.h>
#define AE_OK 0
#define AE_ERR -1
#define AE_NONE 0
#define AE_READABLE 1
#define AE_WRITABLE 2
#define AE_FILE_EVENTS 1
#define AE_TIME_EVENTS 2
#define AE_ALL_EVENTS (AE_FILE_EVENTS|AE_TIME_EVENTS)
#define AE_DONT_WAIT 4
#define AE_NOMORE -1
#define AE_DELETED_EVENT_ID -1
/* Macros */
#define AE_NOTUSED(V) ((void) V)
struct aeEventLoop;
/* Types and data structures */
typedef void aeFileProc(struct aeEventLoop *eventLoop, int fd, void *clientData, int mask);
typedef int aeTimeProc(struct aeEventLoop *eventLoop, long long id, void *clientData);
typedef void aeEventFinalizerProc(struct aeEventLoop *eventLoop, void *clientData);
typedef void aeBeforeSleepProc(struct aeEventLoop *eventLoop);
/* File event structure */
typedef struct aeFileEvent {
int mask; /* one of AE_(READABLE|WRITABLE) */
aeFileProc *rfileProc;
aeFileProc *wfileProc;
void *clientData;
} aeFileEvent;
/* Time event structure */
typedef struct aeTimeEvent {
long long id; /* time event identifier. */
long when_sec; /* seconds */
long when_ms; /* milliseconds */
aeTimeProc *timeProc;
aeEventFinalizerProc *finalizerProc;
void *clientData;
struct aeTimeEvent *next;
} aeTimeEvent;
/* A fired event */
typedef struct aeFiredEvent {
int fd;
int mask;
} aeFiredEvent;
/* State of an event based program */
typedef struct aeEventLoop {
int maxfd; /* highest file descriptor currently registered */
int setsize; /* max number of file descriptors tracked */
long long timeEventNextId;
time_t lastTime; /* Used to detect system clock skew */
aeFileEvent *events; /* Registered events */
aeFiredEvent *fired; /* Fired events */
aeTimeEvent *timeEventHead;
int stop;
void *apidata; /* This is used for polling API specific data */
aeBeforeSleepProc *beforesleep;
} aeEventLoop;
/* Prototypes */
aeEventLoop *aeCreateEventLoop(int setsize);
void aeDeleteEventLoop(aeEventLoop *eventLoop);
void aeStop(aeEventLoop *eventLoop);
int aeCreateFileEvent(aeEventLoop *eventLoop, int fd, int mask,
aeFileProc *proc, void *clientData);
void aeDeleteFileEvent(aeEventLoop *eventLoop, int fd, int mask);
int aeGetFileEvents(aeEventLoop *eventLoop, int fd);
long long aeCreateTimeEvent(aeEventLoop *eventLoop, long long milliseconds,
aeTimeProc *proc, void *clientData,
aeEventFinalizerProc *finalizerProc);
int aeDeleteTimeEvent(aeEventLoop *eventLoop, long long id);
int aeProcessEvents(aeEventLoop *eventLoop, int flags);
int aeWait(int fd, int mask, long long milliseconds);
void aeMain(aeEventLoop *eventLoop);
char *aeGetApiName(void);
void aeSetBeforeSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *beforesleep);
int aeGetSetSize(aeEventLoop *eventLoop);
int aeResizeSetSize(aeEventLoop *eventLoop, int setsize);
#endif
| 4,681 | 36.758065 | 91 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/geo.h
|
#ifndef __GEO_H__
#define __GEO_H__
#include "server.h"
/* Structures used inside geo.c in order to represent points and array of
* points on the earth. */
typedef struct geoPoint {
double longitude;
double latitude;
double dist;
double score;
char *member;
} geoPoint;
typedef struct geoArray {
struct geoPoint *array;
size_t buckets;
size_t used;
} geoArray;
#endif
| 405 | 16.652174 | 73 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/cluster.h
|
#ifndef __CLUSTER_H
#define __CLUSTER_H
/*-----------------------------------------------------------------------------
* Redis cluster data structures, defines, exported API.
*----------------------------------------------------------------------------*/
#define CLUSTER_SLOTS 16384
#define CLUSTER_OK 0 /* Everything looks ok */
#define CLUSTER_FAIL 1 /* The cluster can't work */
#define CLUSTER_NAMELEN 40 /* sha1 hex length */
#define CLUSTER_PORT_INCR 10000 /* Cluster port = baseport + PORT_INCR */
/* The following defines are amount of time, sometimes expressed as
* multiplicators of the node timeout value (when ending with MULT). */
#define CLUSTER_DEFAULT_NODE_TIMEOUT 15000
#define CLUSTER_DEFAULT_SLAVE_VALIDITY 10 /* Slave max data age factor. */
#define CLUSTER_DEFAULT_REQUIRE_FULL_COVERAGE 1
#define CLUSTER_FAIL_REPORT_VALIDITY_MULT 2 /* Fail report validity. */
#define CLUSTER_FAIL_UNDO_TIME_MULT 2 /* Undo fail if master is back. */
#define CLUSTER_FAIL_UNDO_TIME_ADD 10 /* Some additional time. */
#define CLUSTER_FAILOVER_DELAY 5 /* Seconds */
#define CLUSTER_DEFAULT_MIGRATION_BARRIER 1
#define CLUSTER_MF_TIMEOUT 5000 /* Milliseconds to do a manual failover. */
#define CLUSTER_MF_PAUSE_MULT 2 /* Master pause manual failover mult. */
#define CLUSTER_SLAVE_MIGRATION_DELAY 5000 /* Delay for slave migration. */
/* Redirection errors returned by getNodeByQuery(). */
#define CLUSTER_REDIR_NONE 0 /* Node can serve the request. */
#define CLUSTER_REDIR_CROSS_SLOT 1 /* -CROSSSLOT request. */
#define CLUSTER_REDIR_UNSTABLE 2 /* -TRYAGAIN redirection required */
#define CLUSTER_REDIR_ASK 3 /* -ASK redirection required. */
#define CLUSTER_REDIR_MOVED 4 /* -MOVED redirection required. */
#define CLUSTER_REDIR_DOWN_STATE 5 /* -CLUSTERDOWN, global state. */
#define CLUSTER_REDIR_DOWN_UNBOUND 6 /* -CLUSTERDOWN, unbound slot. */
struct clusterNode;
/* clusterLink encapsulates everything needed to talk with a remote node. */
typedef struct clusterLink {
mstime_t ctime; /* Link creation time */
int fd; /* TCP socket file descriptor */
sds sndbuf; /* Packet send buffer */
sds rcvbuf; /* Packet reception buffer */
struct clusterNode *node; /* Node related to this link if any, or NULL */
} clusterLink;
/* Cluster node flags and macros. */
#define CLUSTER_NODE_MASTER 1 /* The node is a master */
#define CLUSTER_NODE_SLAVE 2 /* The node is a slave */
#define CLUSTER_NODE_PFAIL 4 /* Failure? Need acknowledge */
#define CLUSTER_NODE_FAIL 8 /* The node is believed to be malfunctioning */
#define CLUSTER_NODE_MYSELF 16 /* This node is myself */
#define CLUSTER_NODE_HANDSHAKE 32 /* We have still to exchange the first ping */
#define CLUSTER_NODE_NOADDR 64 /* We don't know the address of this node */
#define CLUSTER_NODE_MEET 128 /* Send a MEET message to this node */
#define CLUSTER_NODE_MIGRATE_TO 256 /* Master elegible for replica migration. */
#define CLUSTER_NODE_NULL_NAME "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
#define nodeIsMaster(n) ((n)->flags & CLUSTER_NODE_MASTER)
#define nodeIsSlave(n) ((n)->flags & CLUSTER_NODE_SLAVE)
#define nodeInHandshake(n) ((n)->flags & CLUSTER_NODE_HANDSHAKE)
#define nodeHasAddr(n) (!((n)->flags & CLUSTER_NODE_NOADDR))
#define nodeWithoutAddr(n) ((n)->flags & CLUSTER_NODE_NOADDR)
#define nodeTimedOut(n) ((n)->flags & CLUSTER_NODE_PFAIL)
#define nodeFailed(n) ((n)->flags & CLUSTER_NODE_FAIL)
/* Reasons why a slave is not able to failover. */
#define CLUSTER_CANT_FAILOVER_NONE 0
#define CLUSTER_CANT_FAILOVER_DATA_AGE 1
#define CLUSTER_CANT_FAILOVER_WAITING_DELAY 2
#define CLUSTER_CANT_FAILOVER_EXPIRED 3
#define CLUSTER_CANT_FAILOVER_WAITING_VOTES 4
#define CLUSTER_CANT_FAILOVER_RELOG_PERIOD (60*5) /* seconds. */
/* This structure represent elements of node->fail_reports. */
typedef struct clusterNodeFailReport {
struct clusterNode *node; /* Node reporting the failure condition. */
mstime_t time; /* Time of the last report from this node. */
} clusterNodeFailReport;
typedef struct clusterNode {
mstime_t ctime; /* Node object creation time. */
char name[CLUSTER_NAMELEN]; /* Node name, hex string, sha1-size */
int flags; /* CLUSTER_NODE_... */
uint64_t configEpoch; /* Last configEpoch observed for this node */
unsigned char slots[CLUSTER_SLOTS/8]; /* slots handled by this node */
int numslots; /* Number of slots handled by this node */
int numslaves; /* Number of slave nodes, if this is a master */
struct clusterNode **slaves; /* pointers to slave nodes */
struct clusterNode *slaveof; /* pointer to the master node. Note that it
may be NULL even if the node is a slave
if we don't have the master node in our
tables. */
mstime_t ping_sent; /* Unix time we sent latest ping */
mstime_t pong_received; /* Unix time we received the pong */
mstime_t fail_time; /* Unix time when FAIL flag was set */
mstime_t voted_time; /* Last time we voted for a slave of this master */
mstime_t repl_offset_time; /* Unix time we received offset for this node */
mstime_t orphaned_time; /* Starting time of orphaned master condition */
long long repl_offset; /* Last known repl offset for this node. */
char ip[NET_IP_STR_LEN]; /* Latest known IP address of this node */
int port; /* Latest known port of this node */
clusterLink *link; /* TCP/IP link with this node */
list *fail_reports; /* List of nodes signaling this as failing */
} clusterNode;
typedef struct clusterState {
clusterNode *myself; /* This node */
uint64_t currentEpoch;
int state; /* CLUSTER_OK, CLUSTER_FAIL, ... */
int size; /* Num of master nodes with at least one slot */
dict *nodes; /* Hash table of name -> clusterNode structures */
dict *nodes_black_list; /* Nodes we don't re-add for a few seconds. */
clusterNode *migrating_slots_to[CLUSTER_SLOTS];
clusterNode *importing_slots_from[CLUSTER_SLOTS];
clusterNode *slots[CLUSTER_SLOTS];
zskiplist *slots_to_keys;
/* The following fields are used to take the slave state on elections. */
mstime_t failover_auth_time; /* Time of previous or next election. */
int failover_auth_count; /* Number of votes received so far. */
int failover_auth_sent; /* True if we already asked for votes. */
int failover_auth_rank; /* This slave rank for current auth request. */
uint64_t failover_auth_epoch; /* Epoch of the current election. */
int cant_failover_reason; /* Why a slave is currently not able to
failover. See the CANT_FAILOVER_* macros. */
/* Manual failover state in common. */
mstime_t mf_end; /* Manual failover time limit (ms unixtime).
It is zero if there is no MF in progress. */
/* Manual failover state of master. */
clusterNode *mf_slave; /* Slave performing the manual failover. */
/* Manual failover state of slave. */
long long mf_master_offset; /* Master offset the slave needs to start MF
or zero if stil not received. */
int mf_can_start; /* If non-zero signal that the manual failover
can start requesting masters vote. */
/* The followign fields are used by masters to take state on elections. */
uint64_t lastVoteEpoch; /* Epoch of the last vote granted. */
int todo_before_sleep; /* Things to do in clusterBeforeSleep(). */
long long stats_bus_messages_sent; /* Num of msg sent via cluster bus. */
long long stats_bus_messages_received; /* Num of msg rcvd via cluster bus.*/
} clusterState;
/* clusterState todo_before_sleep flags. */
#define CLUSTER_TODO_HANDLE_FAILOVER (1<<0)
#define CLUSTER_TODO_UPDATE_STATE (1<<1)
#define CLUSTER_TODO_SAVE_CONFIG (1<<2)
#define CLUSTER_TODO_FSYNC_CONFIG (1<<3)
/* Redis cluster messages header */
/* Note that the PING, PONG and MEET messages are actually the same exact
* kind of packet. PONG is the reply to ping, in the exact format as a PING,
* while MEET is a special PING that forces the receiver to add the sender
* as a node (if it is not already in the list). */
#define CLUSTERMSG_TYPE_PING 0 /* Ping */
#define CLUSTERMSG_TYPE_PONG 1 /* Pong (reply to Ping) */
#define CLUSTERMSG_TYPE_MEET 2 /* Meet "let's join" message */
#define CLUSTERMSG_TYPE_FAIL 3 /* Mark node xxx as failing */
#define CLUSTERMSG_TYPE_PUBLISH 4 /* Pub/Sub Publish propagation */
#define CLUSTERMSG_TYPE_FAILOVER_AUTH_REQUEST 5 /* May I failover? */
#define CLUSTERMSG_TYPE_FAILOVER_AUTH_ACK 6 /* Yes, you have my vote */
#define CLUSTERMSG_TYPE_UPDATE 7 /* Another node slots configuration */
#define CLUSTERMSG_TYPE_MFSTART 8 /* Pause clients for manual failover */
/* Initially we don't know our "name", but we'll find it once we connect
* to the first node, using the getsockname() function. Then we'll use this
* address for all the next messages. */
typedef struct {
char nodename[CLUSTER_NAMELEN];
uint32_t ping_sent;
uint32_t pong_received;
char ip[NET_IP_STR_LEN]; /* IP address last time it was seen */
uint16_t port; /* port last time it was seen */
uint16_t flags; /* node->flags copy */
uint16_t notused1; /* Some room for future improvements. */
uint32_t notused2;
} clusterMsgDataGossip;
typedef struct {
char nodename[CLUSTER_NAMELEN];
} clusterMsgDataFail;
typedef struct {
uint32_t channel_len;
uint32_t message_len;
/* We can't reclare bulk_data as bulk_data[] since this structure is
* nested. The 8 bytes are removed from the count during the message
* length computation. */
unsigned char bulk_data[8];
} clusterMsgDataPublish;
typedef struct {
uint64_t configEpoch; /* Config epoch of the specified instance. */
char nodename[CLUSTER_NAMELEN]; /* Name of the slots owner. */
unsigned char slots[CLUSTER_SLOTS/8]; /* Slots bitmap. */
} clusterMsgDataUpdate;
union clusterMsgData {
/* PING, MEET and PONG */
struct {
/* Array of N clusterMsgDataGossip structures */
clusterMsgDataGossip gossip[1];
} ping;
/* FAIL */
struct {
clusterMsgDataFail about;
} fail;
/* PUBLISH */
struct {
clusterMsgDataPublish msg;
} publish;
/* UPDATE */
struct {
clusterMsgDataUpdate nodecfg;
} update;
};
#define CLUSTER_PROTO_VER 0 /* Cluster bus protocol version. */
typedef struct {
char sig[4]; /* Siganture "RCmb" (Redis Cluster message bus). */
uint32_t totlen; /* Total length of this message */
uint16_t ver; /* Protocol version, currently set to 0. */
uint16_t notused0; /* 2 bytes not used. */
uint16_t type; /* Message type */
uint16_t count; /* Only used for some kind of messages. */
uint64_t currentEpoch; /* The epoch accordingly to the sending node. */
uint64_t configEpoch; /* The config epoch if it's a master, or the last
epoch advertised by its master if it is a
slave. */
uint64_t offset; /* Master replication offset if node is a master or
processed replication offset if node is a slave. */
char sender[CLUSTER_NAMELEN]; /* Name of the sender node */
unsigned char myslots[CLUSTER_SLOTS/8];
char slaveof[CLUSTER_NAMELEN];
char notused1[32]; /* 32 bytes reserved for future usage. */
uint16_t port; /* Sender TCP base port */
uint16_t flags; /* Sender node flags */
unsigned char state; /* Cluster state from the POV of the sender */
unsigned char mflags[3]; /* Message flags: CLUSTERMSG_FLAG[012]_... */
union clusterMsgData data;
} clusterMsg;
#define CLUSTERMSG_MIN_LEN (sizeof(clusterMsg)-sizeof(union clusterMsgData))
/* Message flags better specify the packet content or are used to
* provide some information about the node state. */
#define CLUSTERMSG_FLAG0_PAUSED (1<<0) /* Master paused for manual failover. */
#define CLUSTERMSG_FLAG0_FORCEACK (1<<1) /* Give ACK to AUTH_REQUEST even if
master is up. */
/* ---------------------- API exported outside cluster.c -------------------- */
clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *ask);
int clusterRedirectBlockedClientIfNeeded(client *c);
void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_code);
#endif /* __CLUSTER_H */
| 13,090 | 48.965649 | 193 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/crc64.h
|
#ifndef CRC64_H
#define CRC64_H
#include <stdint.h>
uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l);
#ifdef REDIS_TEST
int crc64Test(int argc, char *argv[]);
#endif
#endif
| 193 | 13.923077 | 65 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/debugmacro.h
|
/* This file contains debugging macros to be used when investigating issues.
*
* -----------------------------------------------------------------------------
*
* Copyright (c) 2016, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#define D(...) \
do { \
FILE *fp = fopen("/tmp/log.txt","a"); \
fprintf(fp,"%s:%s:%d:\t", __FILE__, __func__, __LINE__); \
fprintf(fp,__VA_ARGS__); \
fprintf(fp,"\n"); \
fclose(fp); \
} while (0);
| 2,356 | 55.119048 | 80 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/intset.h
|
/*
* Copyright (c) 2009-2012, Pieter Noordhuis <pcnoordhuis at gmail dot com>
* Copyright (c) 2009-2012, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __INTSET_H
#define __INTSET_H
#include <stdint.h>
typedef struct intset {
uint32_t encoding;
uint32_t length;
int8_t contents[];
} intset;
intset *intsetNew(void);
intset *intsetAdd(intset *is, int64_t value, uint8_t *success);
intset *intsetRemove(intset *is, int64_t value, int *success);
uint8_t intsetFind(intset *is, int64_t value);
int64_t intsetRandom(intset *is);
uint8_t intsetGet(intset *is, uint32_t pos, int64_t *value);
uint32_t intsetLen(intset *is);
size_t intsetBlobLen(intset *is);
#ifdef REDIS_TEST
int intsetTest(int argc, char *argv[]);
#endif
#endif // __INTSET_H
| 2,296 | 40.763636 | 78 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/sds.h
|
/* SDSLib 2.0 -- A C dynamic strings library
*
* Copyright (c) 2006-2015, Salvatore Sanfilippo <antirez at gmail dot com>
* Copyright (c) 2015, Oran Agra
* Copyright (c) 2015, Redis Labs, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __SDS_H
#define __SDS_H
#define SDS_MAX_PREALLOC (1024*1024)
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#ifdef USE_PMDK
#include "libpmemobj.h"
#endif
typedef char *sds;
/* Note: sdshdr5 is never used, we just access the flags byte directly.
* However is here to document the layout of type 5 SDS strings. */
struct __attribute__ ((__packed__)) sdshdr5 {
unsigned char flags; /* 3 lsb of type, and 5 msb of string length */
char buf[];
};
struct __attribute__ ((__packed__)) sdshdr8 {
uint8_t len; /* used */
uint8_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
char buf[];
};
struct __attribute__ ((__packed__)) sdshdr16 {
uint16_t len; /* used */
uint16_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
char buf[];
};
struct __attribute__ ((__packed__)) sdshdr32 {
uint32_t len; /* used */
uint32_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
char buf[];
};
struct __attribute__ ((__packed__)) sdshdr64 {
uint64_t len; /* used */
uint64_t alloc; /* excluding the header and null terminator */
unsigned char flags; /* 3 lsb of type, 5 unused bits */
char buf[];
};
#define SDS_TYPE_5 0
#define SDS_TYPE_8 1
#define SDS_TYPE_16 2
#define SDS_TYPE_32 3
#define SDS_TYPE_64 4
#define SDS_TYPE_MASK 7
#define SDS_TYPE_BITS 3
#define SDS_HDR_VAR(T,s) struct sdshdr##T *sh = (void*)((s)-(sizeof(struct sdshdr##T)));
#define SDS_HDR(T,s) ((struct sdshdr##T *)((s)-(sizeof(struct sdshdr##T))))
#define SDS_TYPE_5_LEN(f) ((f)>>SDS_TYPE_BITS)
static inline size_t sdslen(const sds s) {
unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) {
case SDS_TYPE_5:
return SDS_TYPE_5_LEN(flags);
case SDS_TYPE_8:
return SDS_HDR(8,s)->len;
case SDS_TYPE_16:
return SDS_HDR(16,s)->len;
case SDS_TYPE_32:
return SDS_HDR(32,s)->len;
case SDS_TYPE_64:
return SDS_HDR(64,s)->len;
}
return 0;
}
static inline size_t sdsavail(const sds s) {
unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) {
case SDS_TYPE_5: {
return 0;
}
case SDS_TYPE_8: {
SDS_HDR_VAR(8,s);
return sh->alloc - sh->len;
}
case SDS_TYPE_16: {
SDS_HDR_VAR(16,s);
return sh->alloc - sh->len;
}
case SDS_TYPE_32: {
SDS_HDR_VAR(32,s);
return sh->alloc - sh->len;
}
case SDS_TYPE_64: {
SDS_HDR_VAR(64,s);
return sh->alloc - sh->len;
}
}
return 0;
}
static inline void sdssetlen(sds s, size_t newlen) {
unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) {
case SDS_TYPE_5:
{
unsigned char *fp = ((unsigned char*)s)-1;
*fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS);
}
break;
case SDS_TYPE_8:
SDS_HDR(8,s)->len = newlen;
break;
case SDS_TYPE_16:
SDS_HDR(16,s)->len = newlen;
break;
case SDS_TYPE_32:
SDS_HDR(32,s)->len = newlen;
break;
case SDS_TYPE_64:
SDS_HDR(64,s)->len = newlen;
break;
}
}
static inline void sdsinclen(sds s, size_t inc) {
unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) {
case SDS_TYPE_5:
{
unsigned char *fp = ((unsigned char*)s)-1;
unsigned char newlen = SDS_TYPE_5_LEN(flags)+inc;
*fp = SDS_TYPE_5 | (newlen << SDS_TYPE_BITS);
}
break;
case SDS_TYPE_8:
SDS_HDR(8,s)->len += inc;
break;
case SDS_TYPE_16:
SDS_HDR(16,s)->len += inc;
break;
case SDS_TYPE_32:
SDS_HDR(32,s)->len += inc;
break;
case SDS_TYPE_64:
SDS_HDR(64,s)->len += inc;
break;
}
}
/* sdsalloc() = sdsavail() + sdslen() */
static inline size_t sdsalloc(const sds s) {
unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) {
case SDS_TYPE_5:
return SDS_TYPE_5_LEN(flags);
case SDS_TYPE_8:
return SDS_HDR(8,s)->alloc;
case SDS_TYPE_16:
return SDS_HDR(16,s)->alloc;
case SDS_TYPE_32:
return SDS_HDR(32,s)->alloc;
case SDS_TYPE_64:
return SDS_HDR(64,s)->alloc;
}
return 0;
}
static inline void sdssetalloc(sds s, size_t newlen) {
unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) {
case SDS_TYPE_5:
/* Nothing to do, this type has no total allocation info. */
break;
case SDS_TYPE_8:
SDS_HDR(8,s)->alloc = newlen;
break;
case SDS_TYPE_16:
SDS_HDR(16,s)->alloc = newlen;
break;
case SDS_TYPE_32:
SDS_HDR(32,s)->alloc = newlen;
break;
case SDS_TYPE_64:
SDS_HDR(64,s)->alloc = newlen;
break;
}
}
sds sdsnewlen(const void *init, size_t initlen);
sds sdsnew(const char *init);
sds sdsempty(void);
sds sdsdup(const sds s);
void sdsfree(sds s);
sds sdsgrowzero(sds s, size_t len);
sds sdscatlen(sds s, const void *t, size_t len);
sds sdscat(sds s, const char *t);
sds sdscatsds(sds s, const sds t);
sds sdscpylen(sds s, const char *t, size_t len);
sds sdscpy(sds s, const char *t);
#ifdef USE_PMDK
sds sdsnewlenPM(const void *init, size_t initlen);
sds sdsdupPM(const sds s, void **oid_reference);
void sdsfreePM(sds s);
PMEMoid *sdsPMEMoidBackReference(sds s);
#endif
sds sdscatvprintf(sds s, const char *fmt, va_list ap);
#ifdef __GNUC__
sds sdscatprintf(sds s, const char *fmt, ...)
__attribute__((format(printf, 2, 3)));
#else
sds sdscatprintf(sds s, const char *fmt, ...);
#endif
sds sdscatfmt(sds s, char const *fmt, ...);
sds sdstrim(sds s, const char *cset);
void sdsrange(sds s, int start, int end);
void sdsupdatelen(sds s);
void sdsclear(sds s);
int sdscmp(const sds s1, const sds s2);
sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, int *count);
void sdsfreesplitres(sds *tokens, int count);
void sdstolower(sds s);
void sdstoupper(sds s);
sds sdsfromlonglong(long long value);
sds sdscatrepr(sds s, const char *p, size_t len);
sds *sdssplitargs(const char *line, int *argc);
sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen);
sds sdsjoin(char **argv, int argc, char *sep);
sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen);
/* Low level functions exposed to the user API */
sds sdsMakeRoomFor(sds s, size_t addlen);
void sdsIncrLen(sds s, int incr);
sds sdsRemoveFreeSpace(sds s);
size_t sdsAllocSize(sds s);
void *sdsAllocPtr(sds s);
/* Export the allocator used by SDS to the program using SDS.
* Sometimes the program SDS is linked to, may use a different set of
* allocators, but may want to allocate or free things that SDS will
* respectively free or allocate. */
void *sds_malloc(size_t size);
void *sds_realloc(void *ptr, size_t size);
void sds_free(void *ptr);
#ifdef REDIS_TEST
int sdsTest(int argc, char *argv[]);
#endif
#endif
| 9,170 | 31.178947 | 88 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/zmalloc.h
|
/* zmalloc - total amount of allocated memory aware version of malloc()
*
* Copyright (c) 2009-2010, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __ZMALLOC_H
#define __ZMALLOC_H
/* Double expansion needed for stringification of macro values. */
#define __xstr(s) __str(s)
#define __str(s) #s
#if defined(USE_TCMALLOC)
#define ZMALLOC_LIB ("tcmalloc-" __xstr(TC_VERSION_MAJOR) "." __xstr(TC_VERSION_MINOR))
#include <google/tcmalloc.h>
#if (TC_VERSION_MAJOR == 1 && TC_VERSION_MINOR >= 6) || (TC_VERSION_MAJOR > 1)
#define HAVE_MALLOC_SIZE 1
#define zmalloc_size(p) tc_malloc_size(p)
#else
#error "Newer version of tcmalloc required"
#endif
#elif defined(USE_JEMALLOC)
#define ZMALLOC_LIB ("jemalloc-" __xstr(JEMALLOC_VERSION_MAJOR) "." __xstr(JEMALLOC_VERSION_MINOR) "." __xstr(JEMALLOC_VERSION_BUGFIX))
#include <jemalloc/jemalloc.h>
#if (JEMALLOC_VERSION_MAJOR == 2 && JEMALLOC_VERSION_MINOR >= 1) || (JEMALLOC_VERSION_MAJOR > 2)
#define HAVE_MALLOC_SIZE 1
#define zmalloc_size(p) je_malloc_usable_size(p)
#else
#error "Newer version of jemalloc required"
#endif
#elif defined(__APPLE__)
#include <malloc/malloc.h>
#define HAVE_MALLOC_SIZE 1
#define zmalloc_size(p) malloc_size(p)
#endif
#ifndef ZMALLOC_LIB
#define ZMALLOC_LIB "libc"
#endif
void *zmalloc(size_t size);
void *zcalloc(size_t size);
void *zrealloc(void *ptr, size_t size);
void zfree(void *ptr);
char *zstrdup(const char *s);
size_t zmalloc_used_memory(void);
void zmalloc_enable_thread_safeness(void);
void zmalloc_set_oom_handler(void (*oom_handler)(size_t));
float zmalloc_get_fragmentation_ratio(size_t rss);
size_t zmalloc_get_rss(void);
size_t zmalloc_get_private_dirty(void);
size_t zmalloc_get_smap_bytes_by_field(char *field);
size_t zmalloc_get_memory_size(void);
void zlibc_free(void *ptr);
#ifndef HAVE_MALLOC_SIZE
size_t zmalloc_size(void *ptr);
#endif
#endif /* __ZMALLOC_H */
| 3,411 | 37.772727 | 135 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/redisassert.h
|
/* redisassert.h -- Drop in replacemnet assert.h that prints the stack trace
* in the Redis logs.
*
* This file should be included instead of "assert.h" inside libraries used by
* Redis that are using assertions, so instead of Redis disappearing with
* SIGABORT, we get the details and stack trace inside the log file.
*
* ----------------------------------------------------------------------------
*
* Copyright (c) 2006-2012, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __REDIS_ASSERT_H__
#define __REDIS_ASSERT_H__
#include <unistd.h> /* for _exit() */
#define assert(_e) ((_e)?(void)0 : (_serverAssert(#_e,__FILE__,__LINE__),_exit(1)))
void _serverAssert(char *estr, char *file, int line);
#endif
| 2,276 | 46.4375 | 83 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/anet.h
|
/* anet.c -- Basic TCP socket stuff made a bit less boring
*
* Copyright (c) 2006-2012, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ANET_H
#define ANET_H
#include <sys/types.h>
#define ANET_OK 0
#define ANET_ERR -1
#define ANET_ERR_LEN 256
/* Flags used with certain functions. */
#define ANET_NONE 0
#define ANET_IP_ONLY (1<<0)
#if defined(__sun) || defined(_AIX)
#define AF_LOCAL AF_UNIX
#endif
#ifdef _AIX
#undef ip_len
#endif
int anetTcpConnect(char *err, char *addr, int port);
int anetTcpNonBlockConnect(char *err, char *addr, int port);
int anetTcpNonBlockBindConnect(char *err, char *addr, int port, char *source_addr);
int anetTcpNonBlockBestEffortBindConnect(char *err, char *addr, int port, char *source_addr);
int anetUnixConnect(char *err, char *path);
int anetUnixNonBlockConnect(char *err, char *path);
int anetRead(int fd, char *buf, int count);
int anetResolve(char *err, char *host, char *ipbuf, size_t ipbuf_len);
int anetResolveIP(char *err, char *host, char *ipbuf, size_t ipbuf_len);
int anetTcpServer(char *err, int port, char *bindaddr, int backlog);
int anetTcp6Server(char *err, int port, char *bindaddr, int backlog);
int anetUnixServer(char *err, char *path, mode_t perm, int backlog);
int anetTcpAccept(char *err, int serversock, char *ip, size_t ip_len, int *port);
int anetUnixAccept(char *err, int serversock);
int anetWrite(int fd, char *buf, int count);
int anetNonBlock(char *err, int fd);
int anetBlock(char *err, int fd);
int anetEnableTcpNoDelay(char *err, int fd);
int anetDisableTcpNoDelay(char *err, int fd);
int anetTcpKeepAlive(char *err, int fd);
int anetSendTimeout(char *err, int fd, long long ms);
int anetPeerToString(int fd, char *ip, size_t ip_len, int *port);
int anetKeepAlive(char *err, int fd, int interval);
int anetSockName(int fd, char *ip, size_t ip_len, int *port);
int anetFormatAddr(char *fmt, size_t fmt_len, char *ip, int port);
int anetFormatPeer(int fd, char *fmt, size_t fmt_len);
int anetFormatSock(int fd, char *fmt, size_t fmt_len);
#endif
| 3,562 | 42.987654 | 93 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/lzfP.h
|
/*
* Copyright (c) 2000-2007 Marc Alexander Lehmann <[email protected]>
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU General Public License ("GPL") version 2 or any later version,
* in which case the provisions of the GPL are applicable instead of
* the above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use your
* version of this file under the BSD license, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete the
* provisions above, a recipient may use your version of this file under
* either the BSD or the GPL.
*/
#ifndef LZFP_h
#define LZFP_h
#define STANDALONE 1 /* at the moment, this is ok. */
#ifndef STANDALONE
# include "lzf.h"
#endif
/*
* Size of hashtable is (1 << HLOG) * sizeof (char *)
* decompression is independent of the hash table size
* the difference between 15 and 14 is very small
* for small blocks (and 14 is usually a bit faster).
* For a low-memory/faster configuration, use HLOG == 13;
* For best compression, use 15 or 16 (or more, up to 22).
*/
#ifndef HLOG
# define HLOG 16
#endif
/*
* Sacrifice very little compression quality in favour of compression speed.
* This gives almost the same compression as the default code, and is
* (very roughly) 15% faster. This is the preferred mode of operation.
*/
#ifndef VERY_FAST
# define VERY_FAST 1
#endif
/*
* Sacrifice some more compression quality in favour of compression speed.
* (roughly 1-2% worse compression for large blocks and
* 9-10% for small, redundant, blocks and >>20% better speed in both cases)
* In short: when in need for speed, enable this for binary data,
* possibly disable this for text data.
*/
#ifndef ULTRA_FAST
# define ULTRA_FAST 0
#endif
/*
* Unconditionally aligning does not cost very much, so do it if unsure
*/
#ifndef STRICT_ALIGN
# define STRICT_ALIGN !(defined(__i386) || defined (__amd64))
#endif
/*
* You may choose to pre-set the hash table (might be faster on some
* modern cpus and large (>>64k) blocks, and also makes compression
* deterministic/repeatable when the configuration otherwise is the same).
*/
#ifndef INIT_HTAB
# define INIT_HTAB 0
#endif
/*
* Avoid assigning values to errno variable? for some embedding purposes
* (linux kernel for example), this is necessary. NOTE: this breaks
* the documentation in lzf.h. Avoiding errno has no speed impact.
*/
#ifndef AVOID_ERRNO
# define AVOID_ERRNO 0
#endif
/*
* Whether to pass the LZF_STATE variable as argument, or allocate it
* on the stack. For small-stack environments, define this to 1.
* NOTE: this breaks the prototype in lzf.h.
*/
#ifndef LZF_STATE_ARG
# define LZF_STATE_ARG 0
#endif
/*
* Whether to add extra checks for input validity in lzf_decompress
* and return EINVAL if the input stream has been corrupted. This
* only shields against overflowing the input buffer and will not
* detect most corrupted streams.
* This check is not normally noticeable on modern hardware
* (<1% slowdown), but might slow down older cpus considerably.
*/
#ifndef CHECK_INPUT
# define CHECK_INPUT 1
#endif
/*
* Whether to store pointers or offsets inside the hash table. On
* 64 bit architetcures, pointers take up twice as much space,
* and might also be slower. Default is to autodetect.
*/
/*#define LZF_USER_OFFSETS autodetect */
/*****************************************************************************/
/* nothing should be changed below */
#ifdef __cplusplus
# include <cstring>
# include <climits>
using namespace std;
#else
# include <string.h>
# include <limits.h>
#endif
#ifndef LZF_USE_OFFSETS
# if defined (WIN32)
# define LZF_USE_OFFSETS defined(_M_X64)
# else
# if __cplusplus > 199711L
# include <cstdint>
# else
# include <stdint.h>
# endif
# define LZF_USE_OFFSETS (UINTPTR_MAX > 0xffffffffU)
# endif
#endif
typedef unsigned char u8;
#if LZF_USE_OFFSETS
# define LZF_HSLOT_BIAS ((const u8 *)in_data)
typedef unsigned int LZF_HSLOT;
#else
# define LZF_HSLOT_BIAS 0
typedef const u8 *LZF_HSLOT;
#endif
typedef LZF_HSLOT LZF_STATE[1 << (HLOG)];
#if !STRICT_ALIGN
/* for unaligned accesses we need a 16 bit datatype. */
# if USHRT_MAX == 65535
typedef unsigned short u16;
# elif UINT_MAX == 65535
typedef unsigned int u16;
# else
# undef STRICT_ALIGN
# define STRICT_ALIGN 1
# endif
#endif
#if ULTRA_FAST
# undef VERY_FAST
#endif
#endif
| 5,826 | 30.327957 | 79 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/sdsalloc.h
|
/* SDSLib 2.0 -- A C dynamic strings library
*
* Copyright (c) 2006-2015, Salvatore Sanfilippo <antirez at gmail dot com>
* Copyright (c) 2015, Redis Labs, Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* SDS allocator selection.
*
* This file is used in order to change the SDS allocator at compile time.
* Just define the following defines to what you want to use. Also add
* the include of your alternate allocator if needed (not needed in order
* to use the default libc allocator). */
#include "zmalloc.h"
#define s_malloc zmalloc
#define s_realloc zrealloc
#define s_free zfree
| 2,083 | 47.465116 | 78 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/version.h
|
#define REDIS_VERSION "3.2.703_NVML"
| 37 | 18 | 36 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/testhelp.h
|
/* This is a really minimal testing framework for C.
*
* Example:
*
* test_cond("Check if 1 == 1", 1==1)
* test_cond("Check if 5 > 10", 5 > 10)
* test_report()
*
* ----------------------------------------------------------------------------
*
* Copyright (c) 2010-2012, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __TESTHELP_H
#define __TESTHELP_H
int __failed_tests = 0;
int __test_num = 0;
#define test_cond(descr,_c) do { \
__test_num++; printf("%d - %s: ", __test_num, descr); \
if(_c) printf("PASSED\n"); else {printf("FAILED\n"); __failed_tests++;} \
} while(0);
#define test_report() do { \
printf("%d tests, %d passed, %d failed\n", __test_num, \
__test_num-__failed_tests, __failed_tests); \
if (__failed_tests) { \
printf("=== WARNING === We have failed tests here...\n"); \
exit(1); \
} \
} while(0);
#endif
| 2,431 | 40.931034 | 79 |
h
|
null |
NearPMSW-main/nearpm/logging/redis/redis-NDP/src/ziplist.h
|
/*
* Copyright (c) 2009-2012, Pieter Noordhuis <pcnoordhuis at gmail dot com>
* Copyright (c) 2009-2012, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _ZIPLIST_H
#define _ZIPLIST_H
#define ZIPLIST_HEAD 0
#define ZIPLIST_TAIL 1
unsigned char *ziplistNew(void);
unsigned char *ziplistMerge(unsigned char **first, unsigned char **second);
unsigned char *ziplistPush(unsigned char *zl, unsigned char *s, unsigned int slen, int where);
unsigned char *ziplistIndex(unsigned char *zl, int index);
unsigned char *ziplistNext(unsigned char *zl, unsigned char *p);
unsigned char *ziplistPrev(unsigned char *zl, unsigned char *p);
unsigned int ziplistGet(unsigned char *p, unsigned char **sval, unsigned int *slen, long long *lval);
unsigned char *ziplistInsert(unsigned char *zl, unsigned char *p, unsigned char *s, unsigned int slen);
unsigned char *ziplistDelete(unsigned char *zl, unsigned char **p);
unsigned char *ziplistDeleteRange(unsigned char *zl, int index, unsigned int num);
unsigned int ziplistCompare(unsigned char *p, unsigned char *s, unsigned int slen);
unsigned char *ziplistFind(unsigned char *p, unsigned char *vstr, unsigned int vlen, unsigned int skip);
unsigned int ziplistLen(unsigned char *zl);
size_t ziplistBlobLen(unsigned char *zl);
#ifdef REDIS_TEST
int ziplistTest(int argc, char *argv[]);
#endif
#endif /* _ZIPLIST_H */
| 2,890 | 49.719298 | 104 |
h
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.