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 46ee7de
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 14 deletions.
32 changes: 21 additions & 11 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,15 +43,17 @@ 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

- name: Build debug ninja
shell: bash
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
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 46ee7de

Please sign in to comment.