Skip to content

Commit 539d6aa

Browse files
authored
Merge branch 'develop' into fix-format-specifiers
2 parents dde15c1 + 50d2a17 commit 539d6aa

36 files changed

Lines changed: 2245 additions & 549 deletions

.github/workflows/build.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,19 @@ jobs:
3232
- uses: actions/checkout@v2
3333
- name: Prepare
3434
run: bash scripts/install_dependency.sh
35-
- name: Configure CMake
36-
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
35+
- name: Configure CMake with LSan
36+
run: |
37+
cmake -B ${{github.workspace}}/build \
38+
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
39+
-DCMAKE_C_FLAGS="-fsanitize=leak" \
40+
-DCMAKE_CXX_FLAGS="-fsanitize=leak"
3741
- name: Build
3842
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
39-
- name: Test
43+
- name: Test with LSan
4044
working-directory: ${{github.workspace}}/build
41-
run: ctest -C ${{env.BUILD_TYPE}}
45+
run: |
46+
export ASAN_OPTIONS="detect_leaks=1:halt_on_error=1:verbosity=1"
47+
ctest -C ${{env.BUILD_TYPE}} --output-on-failure
4248
4349
selfhosted:
4450
runs-on: self-hosted

.github/workflows/npm-release.yml

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
name: NPM Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
push:
7+
branches:
8+
- develop
9+
paths:
10+
- 'libCacheSim-node/**'
11+
12+
env:
13+
BUILD_TYPE: Release
14+
15+
jobs:
16+
create-release:
17+
if: github.event_name == 'release'
18+
runs-on: ubuntu-latest
19+
outputs:
20+
release_created: ${{ steps.release.outputs.release_created }}
21+
version: ${{ steps.package.outputs.version }}
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Synchronize Node.js binding version
28+
run: |
29+
echo "Synchronizing Node.js binding version with main project..."
30+
python3 scripts/sync_node_version.py
31+
32+
- name: Get package version
33+
id: package
34+
working-directory: libCacheSim-node
35+
run: |
36+
VERSION=$(node -p "require('./package.json').version")
37+
echo "version=$VERSION" >> $GITHUB_OUTPUT
38+
echo "Version: $VERSION"
39+
40+
- name: Check if release exists
41+
id: check_release
42+
run: |
43+
VERSION="${{ steps.package.outputs.version }}"
44+
if gh release view "v$VERSION" > /dev/null 2>&1; then
45+
echo "Release v$VERSION already exists"
46+
echo "exists=true" >> $GITHUB_OUTPUT
47+
else
48+
echo "Release v$VERSION does not exist"
49+
echo "exists=false" >> $GITHUB_OUTPUT
50+
fi
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Create GitHub Release
55+
id: release
56+
if: steps.check_release.outputs.exists == 'false'
57+
uses: actions/create-release@v1
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
with:
61+
tag_name: v${{ steps.package.outputs.version }}
62+
release_name: Release v${{ steps.package.outputs.version }}
63+
body: |
64+
Release v${{ steps.package.outputs.version }}
65+
66+
## Installation
67+
```bash
68+
npm install libcachesim-node
69+
```
70+
71+
## Supported Platforms
72+
- Linux x64
73+
74+
Pre-compiled binaries are automatically downloaded during installation.
75+
draft: false
76+
prerelease: false
77+
78+
build-and-publish:
79+
if: github.event_name == 'release'
80+
needs: create-release
81+
runs-on: ubuntu-latest
82+
83+
steps:
84+
- name: Checkout code
85+
uses: actions/checkout@v4
86+
with:
87+
fetch-depth: 0
88+
89+
- name: Synchronize Node.js binding version
90+
run: |
91+
echo "Synchronizing Node.js binding version with main project..."
92+
python3 scripts/sync_node_version.py
93+
94+
- name: Setup Node.js
95+
uses: actions/setup-node@v4
96+
with:
97+
node-version: '18'
98+
registry-url: 'https://registry.npmjs.org'
99+
100+
- name: Install system dependencies
101+
run: |
102+
sudo apt-get update
103+
sudo apt-get install -y build-essential cmake libglib2.0-dev libzstd-dev
104+
105+
- name: Build libCacheSim
106+
run: |
107+
echo "Building libCacheSim for Linux x64..."
108+
mkdir -p _build
109+
cd _build
110+
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} .. -DCMAKE_VERBOSE_MAKEFILE=ON
111+
echo "Starting build..."
112+
make -j$(nproc) VERBOSE=1
113+
114+
- name: Prepare vendored library
115+
run: |
116+
mkdir -p libCacheSim-node/vendor/include
117+
cp _build/liblibCacheSim.a libCacheSim-node/vendor/
118+
cp -r libCacheSim/include/* libCacheSim-node/vendor/include/
119+
120+
- name: Install Node.js dependencies
121+
working-directory: libCacheSim-node
122+
run: npm install
123+
124+
- name: Build and upload prebuilt binary
125+
working-directory: libCacheSim-node
126+
run: |
127+
echo "Building Node.js addon for Linux x64..."
128+
echo "Node.js version: $(node --version)"
129+
echo "NPM version: $(npm --version)"
130+
ls -la ../
131+
ls -la ../_build/
132+
CFLAGS=-fPIC CXXFLAGS=-fPIC npx prebuild --upload-all --verbose
133+
env:
134+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
136+
- name: Test binary
137+
working-directory: libCacheSim-node
138+
run: |
139+
echo "Testing binary load for Linux x64..."
140+
ls -la
141+
ls -la prebuilds/ || echo "No prebuilds directory found"
142+
node -e "console.log('Testing binary load...'); try { require('./index.js'); console.log('Binary loaded successfully!'); } catch(e) { console.error('Failed to load binary:', e); process.exit(1); }"
143+
144+
publish-npm:
145+
if: github.event_name == 'release'
146+
needs: build-and-publish
147+
runs-on: ubuntu-latest
148+
149+
steps:
150+
- name: Checkout code
151+
uses: actions/checkout@v4
152+
153+
- name: Synchronize Node.js binding version
154+
run: |
155+
echo "Synchronizing Node.js binding version with main project..."
156+
python3 scripts/sync_node_version.py
157+
158+
- name: Setup Node.js
159+
uses: actions/setup-node@v4
160+
with:
161+
node-version: '18'
162+
registry-url: 'https://registry.npmjs.org'
163+
164+
- name: Install system dependencies
165+
run: |
166+
sudo apt-get update
167+
sudo apt-get install -y build-essential cmake libglib2.0-dev libzstd-dev
168+
169+
- name: Build libCacheSim
170+
run: |
171+
mkdir -p _build
172+
cd _build
173+
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} ..
174+
make -j$(nproc)
175+
176+
- name: Prepare vendored library
177+
run: |
178+
mkdir -p libCacheSim-node/vendor/include
179+
cp _build/liblibCacheSim.a libCacheSim-node/vendor/
180+
cp -r libCacheSim/include/* libCacheSim-node/vendor/include/
181+
182+
183+
- name: Publish to NPM
184+
working-directory: libCacheSim-node
185+
run: npm publish --access public
186+
env:
187+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ project(libCacheSim)
33
set(DESCRIPTION "a high performance cache simulation library")
44
set(PROJECT_WEB "http://cachesim.com")
55

6-
set(${PROJECT_NAME}_VERSION_MAJOR 0)
7-
set(${PROJECT_NAME}_VERSION_MINOR 1)
8-
set(${PROJECT_NAME}_VERSION_PATCH 0)
9-
set(${PROJECT_NAME}_RELEASE_VERSION ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR})
10-
set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_RELEASE_VERSION}.${${PROJECT_NAME}_VERSION_PATCH})
6+
# Include version utilities
7+
include(cmake/Version.cmake)
8+
9+
# Setup version from version.txt
10+
setup_project_version(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/version.txt")
1111

1212
set(CMAKE_CXX_STANDARD 17)
1313
set(CMAKE_CXX_STANDARD_REQUIRED On)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ The compressed traces can be used with libCacheSim without decompression. And li
328328
| WikiCDN | 2019 | object | [link](https://wikitech.wikimedia.org/wiki/Analytics/Data_Lake/Traffic/Caching) | [link](https://ftp.pdl.cmu.edu/pub/datasets/twemcacheWorkload/cacheDatasets/wiki/) |
329329
| Tencent CBS | 2020 | block | [link](http://iotta.snia.org/traces/parallel?only=27917) | [link](https://ftp.pdl.cmu.edu/pub/datasets/twemcacheWorkload/cacheDatasets/tencentBlock/) |
330330
| Alibaba Block | 2020 | block | [link](https://github.com/alibaba/block-traces) | [link](https://ftp.pdl.cmu.edu/pub/datasets/twemcacheWorkload/cacheDatasets/alibabaBlock/) |
331-
| Twitter | 2020 | key-value | [link](https://github.com/twitter/cache-traces) | [link](https://ftp.pdl.cmu.edu/pub/datasets/twemcacheWorkload/cacheDatasets/twitter/) |
331+
| Twitter | 2020 | key-value | [link](https://github.com/twitter/cache-trace) | [link](https://ftp.pdl.cmu.edu/pub/datasets/twemcacheWorkload/cacheDatasets/twitter/) |
332332
| MetaKV | 2022 | key-value | [link](https://cachelib.org/docs/Cache_Library_User_Guides/Cachebench_FB_HW_eval/#list-of-traces) | [link](https://ftp.pdl.cmu.edu/pub/datasets/twemcacheWorkload/cacheDatasets/metaKV/) |
333333
| MetaCDN | 2023 | object | [link](https://cachelib.org/docs/Cache_Library_User_Guides/Cachebench_FB_HW_eval/#list-of-traces) | [link](https://ftp.pdl.cmu.edu/pub/datasets/twemcacheWorkload/cacheDatasets/metaCDN/) |
334334

cmake/Version.cmake

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,51 @@
1+
# Version parsing utilities for libCacheSim
2+
# Based on xgboost version handling
13

2-
# from xgboost
3-
function (write_version)
4-
message(STATUS "xgboost VERSION: ${xgboost_VERSION}")
5-
configure_file(
6-
${xgboost_SOURCE_DIR}/include/config.h.in
7-
${xgboost_SOURCE_DIR}/include/config.h @ONLY)
4+
function(parse_version_from_file VERSION_FILE VERSION_MAJOR_VAR VERSION_MINOR_VAR VERSION_PATCH_VAR)
5+
if(EXISTS "${VERSION_FILE}")
6+
file(READ "${VERSION_FILE}" VERSION_STRING)
7+
string(STRIP "${VERSION_STRING}" VERSION_STRING)
8+
9+
# Parse MAJOR.MINOR.PATCH format
10+
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)" VERSION_MATCH "${VERSION_STRING}")
11+
if(VERSION_MATCH)
12+
set(${VERSION_MAJOR_VAR} ${CMAKE_MATCH_1} PARENT_SCOPE)
13+
set(${VERSION_MINOR_VAR} ${CMAKE_MATCH_2} PARENT_SCOPE)
14+
set(${VERSION_PATCH_VAR} ${CMAKE_MATCH_3} PARENT_SCOPE)
15+
message(STATUS "Version from ${VERSION_FILE}: ${VERSION_STRING}")
16+
else()
17+
message(FATAL_ERROR "Invalid version format in ${VERSION_FILE}: ${VERSION_STRING}. Expected format: MAJOR.MINOR.PATCH")
18+
endif()
19+
else()
20+
message(FATAL_ERROR "Version file not found: ${VERSION_FILE}")
21+
endif()
22+
endfunction()
23+
24+
function(setup_project_version PROJECT_NAME VERSION_FILE)
25+
if(EXISTS "${VERSION_FILE}")
26+
parse_version_from_file("${VERSION_FILE}" VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
27+
set(${PROJECT_NAME}_VERSION_MAJOR ${VERSION_MAJOR} PARENT_SCOPE)
28+
set(${PROJECT_NAME}_VERSION_MINOR ${VERSION_MINOR} PARENT_SCOPE)
29+
set(${PROJECT_NAME}_VERSION_PATCH ${VERSION_PATCH} PARENT_SCOPE)
30+
set(${PROJECT_NAME}_RELEASE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR} PARENT_SCOPE)
31+
set(${PROJECT_NAME}_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} PARENT_SCOPE)
32+
else()
33+
message(STATUS "${VERSION_FILE} not found, using default version")
34+
set(${PROJECT_NAME}_VERSION_MAJOR 0 PARENT_SCOPE)
35+
set(${PROJECT_NAME}_VERSION_MINOR 1 PARENT_SCOPE)
36+
set(${PROJECT_NAME}_VERSION_PATCH 0 PARENT_SCOPE)
37+
set(${PROJECT_NAME}_RELEASE_VERSION 0.1 PARENT_SCOPE)
38+
set(${PROJECT_NAME}_VERSION 0.1.0 PARENT_SCOPE)
39+
endif()
40+
endfunction()
41+
42+
# Legacy function for xgboost compatibility
43+
function(write_version)
44+
message(STATUS "xgboost VERSION: ${xgboost_VERSION}")
45+
configure_file(
46+
${xgboost_SOURCE_DIR}/include/config.h.in
47+
${xgboost_SOURCE_DIR}/include/config.h @ONLY)
848
# configure_file(
949
# ${xgboost_SOURCE_DIR}/cmake/Python_version.in
1050
# ${xgboost_SOURCE_DIR}/python-package/xgboost/VERSION @ONLY)
11-
endfunction (write_version)
51+
endfunction(write_version)

libCacheSim-node/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Node.js dependencies
2+
node_modules/
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Build outputs
8+
build/
9+
*.node
10+
11+
# Package locks (optional for libraries)
12+
package-lock.json
13+
14+
# OS files
15+
.DS_Store
16+
Thumbs.db
17+
18+
# IDE files
19+
.vscode/
20+
.idea/
21+
22+
# Temporary files
23+
*.tmp
24+
*.log

0 commit comments

Comments
 (0)