Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/cpp_clang_tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Clang Tidy Check

on:
workflow_run:
workflows: ["Velox Backend (x86)"]
types:
- completed

env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

concurrency:
group: clang-tidy-${{ github.event.workflow_run.id }}
cancel-in-progress: true

jobs:
clang-tidy-check:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
container: apache/gluten:centos-8-jdk8
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
- name: Detect CPP file changes
id: filter
run: |
BASE_SHA=$(python3 -c "
import json, os
with open(os.environ['GITHUB_EVENT_PATH']) as f:
event = json.load(f)
wr = event.get('workflow_run', {})
prs = wr.get('pull_requests', [])
if prs:
print(prs[0]['base']['sha'])
else:
print(wr.get('before', ''))
")
HEAD_SHA="${{ github.event.workflow_run.head_sha }}"
if git diff --name-only $BASE_SHA $HEAD_SHA | grep -E '^cpp/.*\.(cc|h)$'; then
echo "cpp_changed=true" >> $GITHUB_OUTPUT
else
echo "cpp_changed=false" >> $GITHUB_OUTPUT
fi
- name: Download artifact from in-progress workflow
if: steps.filter.outputs.cpp_changed == 'true'
uses: dawidd6/action-download-artifact@v3
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: .github/workflows/velox_backend_x86.yml
name: velox-native-lib-centos-7-${{ github.event.workflow_run.head_sha }}
commit: ${{ github.event.workflow_run.head_sha }}
workflow_conclusion: ""
check_artifacts: true
search_artifacts: true
if_no_artifact_found: fail
- name: Check Clang Tidy
run: |
pip3 install regex
yum install glibc-devel glibc-headers
cd $GITHUB_WORKSPACE/
yum install clang llvm llvm-devel -y
dnf install clang-tools-extra -y
clang-tidy --version
sed -i "s|/work|$(pwd)|g" cpp/build/compile_commands.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if cpp/build/compile_commands.json is required could we add this to some existing job?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean all jobs in CI/CD generates 'cpp/build/compile_commands.json'?

python3 dev/check.py tidy commit --fix

46 changes: 23 additions & 23 deletions .github/workflows/velox_backend_x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases/
path: ./cpp/build/
if-no-files-found: error
- uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases/
path: ./cpp/build/
- name: Download All Arrow Jar Artifacts
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -216,7 +216,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases/
path: ./cpp/build/
- name: Download All Arrow Jar Artifacts
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -291,7 +291,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases/
path: ./cpp/build/
- name: Download All Arrow Jar Artifacts
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -359,7 +359,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases/
path: ./cpp/build/
- name: Download All Arrow Jar Artifacts
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -474,7 +474,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases/
path: ./cpp/build/
- name: Download All Arrow Jar Artifacts
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -517,7 +517,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases/
path: ./cpp/build/
- name: Download All Arrow Jar Artifacts
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -568,7 +568,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases/
path: ./cpp/build/
- name: Download All Arrow Jar Artifacts
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -640,7 +640,7 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- uses: actions/download-artifact@v4
with:
name: arrow-jars-centos-7-${{github.sha}}
Expand Down Expand Up @@ -691,7 +691,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -728,7 +728,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -784,7 +784,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -827,7 +827,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -885,7 +885,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -929,7 +929,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -985,7 +985,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1035,7 +1035,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1077,7 +1077,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1126,7 +1126,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1167,7 +1167,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1216,7 +1216,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1342,7 +1342,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1397,7 +1397,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: velox-native-lib-centos-7-${{github.sha}}
path: ./cpp/build/releases
path: ./cpp/build/
- name: Download Arrow Jars
uses: actions/download-artifact@v4
with:
Expand Down
17 changes: 14 additions & 3 deletions cpp/core/memory/ArrowMemoryPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,33 @@

#pragma once

#include "arrow/memory_pool.h"
#include "arrow/memory_pool.h" // IWYU pragma: keep

#include "MemoryAllocator.h"
#include "MemoryAllocator.h" // IWYU pragma: keep

// NOLINTNEXTLINE(cert-dcl58-cpp)
namespace gluten {

using ArrowMemoryPoolReleaser = std::function<void(arrow::MemoryPool*)>;

/// This pool was not tracked by Spark, should only used in test.
class ArrowMemoryPool final : public arrow::MemoryPool {
public:
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init, hicpp-member-init)
explicit ArrowMemoryPool(AllocationListener* listener, ArrowMemoryPoolReleaser releaser = nullptr)
: allocator_(std::make_unique<ListenableMemoryAllocator>(defaultMemoryAllocator().get(), listener)),
releaser_(std::move(releaser)) {}

~ArrowMemoryPool() override;

ArrowMemoryPool(const ArrowMemoryPool&) = delete;

ArrowMemoryPool& operator=(const ArrowMemoryPool&) = delete;

ArrowMemoryPool(ArrowMemoryPool&&) = delete;

ArrowMemoryPool& operator=(ArrowMemoryPool&&) = delete;

arrow::Status Allocate(int64_t size, int64_t alignment, uint8_t** out) override;

arrow::Status Reallocate(int64_t oldSize, int64_t newSize, int64_t alignment, uint8_t** ptr) override;
Expand All @@ -53,7 +63,8 @@ class ArrowMemoryPool final : public arrow::MemoryPool {
MemoryAllocator* allocator() const;

private:
std::unique_ptr<MemoryAllocator> allocator_;
std::unique_ptr<MemoryAllocator> allocator_ = nullptr;

ArrowMemoryPoolReleaser releaser_;
};

Expand Down
1 change: 1 addition & 0 deletions dev/builddeps-veloxbe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ function build_gluten_cpp {
-DENABLE_HDFS=$ENABLE_HDFS \
-DENABLE_ABFS=$ENABLE_ABFS \
-DENABLE_GPU=$ENABLE_GPU \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DENABLE_ENHANCED_FEATURES=$ENABLE_ENHANCED_FEATURES"

if [ $OS == 'Darwin' ]; then
Expand Down
4 changes: 2 additions & 2 deletions dev/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def header_command(commit, files, fix):


def tidy_command(commit, files, fix):
files = [file for file in files if regex.match(r".*\.cpp$", file)]
files = [file for file in files if regex.match(r".*\.(cc|cpp|h)$", file)]

if not files:
return 0
Expand All @@ -177,7 +177,7 @@ def tidy_command(commit, files, fix):
fix = "--fix" if fix == "fix" else ""

status, stdout, stderr = util.run(
f"{SCRIPTS}/run-clang-tidy.py {commit} {fix} -", input=files
f"{SCRIPTS}/run-clang-tidy.py {commit} {fix} ", input=files
)

if stdout != "":
Expand Down
Loading