Skip to content

Commit

Permalink
use parallel-hashmap
Browse files Browse the repository at this point in the history
  • Loading branch information
atetubou committed Jun 13, 2024
1 parent 0b4b43a commit ef2fc83
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 15 deletions.
34 changes: 22 additions & 12 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ jobs:
container:
image: fedora:40
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: dnf install -y ninja-build cmake gtest-devel re2c clang util-linux
run: dnf install -y ninja-build cmake gtest-devel re2c clang util-linux git
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Linting
run: misc/ci.py
- name: Configure with CMake
Expand All @@ -41,16 +43,18 @@ jobs:
container:
image: rockylinux:8
steps:
- uses: actions/checkout@v4
- uses: codespell-project/actions-codespell@master
with:
ignore_words_list: fo,wee,addin,notin
- name: Install dependencies
run: |
dnf install -y make gcc-c++ libasan clang-analyzer cmake dnf-plugins-core epel-release
dnf config-manager --set-enabled powertools
dnf install -y gtest-devel p7zip p7zip-plugins
dnf install -y gtest-devel p7zip p7zip-plugins git
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: codespell-project/actions-codespell@master
with:
ignore_words_list: fo,wee,addin,notin
skip: ./parallel-hashmap
- name: Build debug ninja
shell: bash
env:
Expand Down Expand Up @@ -103,12 +107,14 @@ jobs:
container:
image: ubuntu:20.04
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
apt update
apt install -y python3-pytest ninja-build clang-tidy python3-pip clang libgtest-dev
apt install -y python3-pytest ninja-build clang-tidy python3-pip clang libgtest-dev git
pip3 install cmake==3.17.*
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Configure (GCC)
run: cmake -Bbuild-gcc -DCMAKE_BUILD_TYPE=Debug -G'Ninja Multi-Config'

Expand Down Expand Up @@ -159,11 +165,13 @@ jobs:
matrix:
image: ['ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:24.04']
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
apt update
apt install -y g++ python3
apt install -y g++ python3 git
- uses: actions/checkout@v4
with:
submodules: recursive
- name: ${{ matrix.image }}
run: |
python3 configure.py --bootstrap
Expand All @@ -176,6 +184,8 @@ jobs:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Build
uses: uraimo/run-on-arch-action@v2
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: brew install re2c p7zip cmake
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: choco install re2c
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "parallel-hashmap"]
path = parallel-hashmap
url = https://github.com/greg7mdp/parallel-hashmap.git
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ else()
endif()
endif()

include_directories(parallel-hashmap)

# --- optional re2c
set(RE2C_MAJOR_VERSION 0)
find_program(RE2C re2c)
Expand Down
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ environment:
- MSYSTEM: MINGW64
- MSYSTEM: LINUX

install:
- git submodule update --init --recursive

matrix:
exclude:
- image: Visual Studio 2017
Expand Down
2 changes: 2 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def search_system_path(file_name: str) -> Optional[str]: # type: ignore # Missi
# Disable size_t -> int truncation warning.
# We never have strings or arrays larger than 2**31.
'/wd4267',
'/Iparallel-hashmap',
'/DNOMINMAX', '/D_CRT_SECURE_NO_WARNINGS',
'/D_HAS_EXCEPTIONS=0',
'/DNINJA_PYTHON="%s"' % options.with_python]
Expand All @@ -363,6 +364,7 @@ def search_system_path(file_name: str) -> Optional[str]: # type: ignore # Missi
'-fno-exceptions',
'-std=c++11',
'-fvisibility=hidden', '-pipe',
'-Iparallel-hashmap',
'-DNINJA_PYTHON="%s"' % options.with_python]
if options.debug:
cflags += ['-D_GLIBCXX_DEBUG', '-D_GLIBCXX_DEBUG_PEDANTIC']
Expand Down
1 change: 1 addition & 0 deletions misc/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'misc/afl-fuzz-tokens/',
'src/depfile_parser.cc',
'src/lexer.cc',
'parallel-hashmap/',
]

error_count = 0
Expand Down
1 change: 1 addition & 0 deletions parallel-hashmap
Submodule parallel-hashmap added at d88c5e
6 changes: 3 additions & 3 deletions src/hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include <algorithm>
#include <string.h>
#include "parallel_hashmap/phmap.h"
#include "parallel_hashmap/phmap_utils.h"
#include "string_piece.h"
#include "util.h"

Expand Down Expand Up @@ -53,8 +55,6 @@ unsigned int MurmurHash2(const void* key, size_t len) {
return h;
}

#include <unordered_map>

namespace std {
template<>
struct hash<StringPiece> {
Expand All @@ -73,7 +73,7 @@ struct hash<StringPiece> {
/// mapping StringPiece => Foo*.
template<typename V>
struct ExternalStringHashMap {
typedef std::unordered_map<StringPiece, V> Type;
typedef phmap::flat_hash_map<StringPiece, V> Type;
};

#endif // NINJA_MAP_H_

0 comments on commit ef2fc83

Please sign in to comment.