Skip to content

Commit

Permalink
Merge branch 'master' into box-recursive-type
Browse files Browse the repository at this point in the history
  • Loading branch information
arximboldi authored Aug 22, 2024
2 parents 359c3a4 + af857bd commit abf10a4
Show file tree
Hide file tree
Showing 140 changed files with 5,893 additions and 24,832 deletions.
9 changes: 9 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM mcr.microsoft.com/devcontainers/base:ubuntu

# cache /nix
VOLUME /nix

RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux \
--extra-conf "sandbox = false" \
--init none \
--no-confirm
36 changes: 36 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "Ubuntu",
"dockerFile": "Dockerfile",
"context": "${localWorkspaceFolder}",
"runArgs": [
"--security-opt",
"label=disable"
],
"mounts": [
"source=nix-ubuntu-container,target=/nix,type=volume"
],
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "mcr.microsoft.com/devcontainers/base:${templateOption:imageVariant}"
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"xaver.clang-format",
"arrterian.nix-env-selector",
"ms-vscode.cpptools",
"kamadorueda.alejandra"
]
}
},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// We need root because nix without systemd works only as root.
"remoteUser": "root"
}
2 changes: 2 additions & 0 deletions .gdbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Load pretty printers
source tools/gdb_pretty_printers/autoload.py
26 changes: 26 additions & 0 deletions .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CIFuzz
on: [pull_request]
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'immer'
dry-run: false
language: c++
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'immer'
fuzz-seconds: 300
dry-run: false
language: c++
- name: Upload Crash
uses: actions/upload-artifact@v3
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts
30 changes: 12 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,33 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # needed for fetchGit in default.nix
- uses: cachix/[email protected]
with:
nix_path: nixpkgs=channel:nixos-unstable
install_url: "https://releases.nixos.org/nix/nix-2.3.16/install"
- uses: cachix/cachix-action@v10
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
- uses: cachix/cachix-action@v14
with:
name: arximboldi
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- run: nix-build
- run: nix build
- run: nix flake check -L

build-spm:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- run: swift build

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
- uses: cachix/install-nix-action@v14.1
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
install_url: "https://releases.nixos.org/nix/nix-2.3.16/install"
- uses: cachix/cachix-action@v10
- uses: cachix/cachix-action@v14
with:
name: arximboldi
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
Expand Down Expand Up @@ -94,12 +89,11 @@ jobs:
opts: ['benchmark']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v14.1
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
install_url: "https://releases.nixos.org/nix/nix-2.3.16/install"
- uses: cachix/cachix-action@v10
- uses: cachix/cachix-action@v14
with:
name: arximboldi
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ tools/clojure/.lein*

.build
.swiftpm
.vscode
.pre-commit-config.yaml
27 changes: 19 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_policy(SET CMP0048 NEW) # enable project VERSION
cmake_policy(SET CMP0056 NEW) # honor link flags in try_compile()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

project(immer VERSION 0.7.0)
project(immer VERSION 0.8.0)

if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-extended-offsetof -Wno-c++17-extensions -Wno-c++1z-extensions -Wno-unknown-warning-option -Wno-type-limits")
Expand Down Expand Up @@ -39,6 +39,7 @@ option(immer_BUILD_TESTS "Build tests" ON)
option(immer_BUILD_EXAMPLES "Build examples" ON)
option(immer_BUILD_DOCS "Build docs" ON)
option(immer_BUILD_EXTRAS "Build extras" ON)
option(immer_INSTALL_FUZZERS "Install fuzzers" off)

set(CXX_STANDARD 14 CACHE STRING "c++ standard number")

Expand Down Expand Up @@ -76,8 +77,8 @@ find_package(Boost 1.56 COMPONENTS ${immer_boost_components})
find_program(CCACHE ccache)
if (CCACHE)
message(STATUS "Using ccache: ${CCACHE}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
set(CMAKE_CXX_LINKER_LAUNCHER ${CCACHE})
else()
message(STATUS "Could not find ccache")
endif()
Expand All @@ -99,6 +100,14 @@ install(TARGETS immer EXPORT ImmerConfig)
install(EXPORT ImmerConfig DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Immer")
install(DIRECTORY immer DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/ImmerConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion )

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ImmerConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Immer" )

# development target to be used in tests, examples, benchmarks...
immer_canonicalize_cmake_booleans(
DISABLE_FREE_LIST
Expand Down Expand Up @@ -128,14 +137,16 @@ endif()
# Testing
# =======

if (immer_BUILD_TESTS OR immer_BUILD_EXAMPLES OR immer_BUILD_EXTRAS)
add_custom_target(check
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Build and run all the tests and examples.")
endif()

if (immer_BUILD_TESTS)
enable_testing()

add_custom_target(check
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Build and run all the tests and examples.")

add_subdirectory(test)
add_subdirectory(benchmark)
endif()
Expand Down
22 changes: 19 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. image:: https://github.com/arximboldi/immer/workflows/test/badge.svg
:target: https://github.com/arximboldi/immer/actions?query=workflow%3Atest+branch%3Amaster
:alt: Github Actions Badge
:alt: GitHub Actions Badge

.. image:: https://codecov.io/gh/arximboldi/immer/branch/master/graph/badge.svg
:target: https://codecov.io/gh/arximboldi/immer
Expand All @@ -13,7 +13,10 @@

.. raw:: html

<img width="100%" src="https://cdn.rawgit.com/arximboldi/immer/3888170d247359cc0905eed548cd46897caef0f4/doc/_static/logo-front.svg" alt="Logotype"/>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.rawgit.com/arximboldi/immer/3888170d247359cc0905eed548cd46897caef0f4/doc/_static/logo-black.svg">
<img width="100%" src="https://cdn.rawgit.com/arximboldi/immer/3888170d247359cc0905eed548cd46897caef0f4/doc/_static/logo-front.svg" alt="Logotype">
</picture>

.. include:introduction/start
Expand Down Expand Up @@ -74,7 +77,7 @@ Example
For a **complete example** check `Ewig, a simple didactic
text-editor <https://github.com/arximboldi/ewig>`_ built with this
library. You may also wanna check `Lager, a Redux-like library
<https://github.com/arximboldi/lager>`_ for writting interactive
<https://github.com/arximboldi/lager>`_ for writing interactive
software in C++ using a value-oriented design.


Expand Down Expand Up @@ -181,6 +184,19 @@ system once you have manually cloned the repository::
.. _nix package manager: https://nixos.org/nix
.. _cmake: https://cmake.org/

Installing immer using vcpkg
-----------------------------

You can download and install immer using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager::

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install immer

The immer port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.

Development
-----------

Expand Down
9 changes: 2 additions & 7 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,10 @@ foreach(_file IN LISTS immer_benchmarks)
endif()
endforeach()

set(immer_ssh_method
ssh -p 5488
-o StrictHostKeyChecking=no)

add_custom_target(upload-benchmark-reports
COMMAND
rsync -av -e \"${immer_ssh_method}\"
${immer_benchmark_report_base_dir}
[email protected]:public/misc/immer/)
rsync -av ${immer_benchmark_report_base_dir}
[email protected]:/var/lib/syncthing/public/misc/immer/)

add_custom_target(copy-benchmark-reports
COMMAND
Expand Down
85 changes: 85 additions & 0 deletions benchmark/set/erase.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// immer: immutable data structures for C++
// Copyright (C) 2016, 2017, 2018 Juan Pedro Bolivar Puente
//
// This software is distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt
//

#pragma once

#include "benchmark/config.hpp"

#include <boost/container/flat_set.hpp>
#include <hash_trie.hpp> // Phil Nash
#include <immer/set.hpp>
#include <immer/set_transient.hpp>
#include <set>
#include <unordered_set>

namespace {

template <typename Generator, typename Set>
auto benchmark_erase_mut_std()
{
return [](nonius::chronometer meter) {
auto n = meter.param<N>();
auto g = Generator{}(n);
auto v_ = [&] {
auto v = Set{};
for (auto i = 0u; i < n; ++i)
v.insert(g[i]);
return v;
}();
measure(meter, [&] {
auto v = v_;
for (auto i = 0u; i < n; ++i)
v.erase(g[i]);
return v;
});
};
}

template <typename Generator, typename Set>
auto benchmark_erase()
{
return [](nonius::chronometer meter) {
auto n = meter.param<N>();
auto g = Generator{}(n);
auto v_ = [&] {
auto v = Set{}.transient();
for (auto i = 0u; i < n; ++i)
v.insert(g[i]);
return v.persistent();
}();
measure(meter, [&] {
auto v = v_;
for (auto i = 0u; i < n; ++i)
v = v.erase(g[i]);
return v;
});
};
}

template <typename Generator, typename Set>
auto benchmark_erase_move()
{
return [](nonius::chronometer meter) {
auto n = meter.param<N>();
auto g = Generator{}(n);
auto v_ = [&] {
auto v = Set{}.transient();
for (auto i = 0u; i < n; ++i)
v.insert(g[i]);
return v.persistent();
}();
measure(meter, [&] {
auto v = v_;
for (auto i = 0u; i < n; ++i)
v = std::move(v).erase(g[i]);
return v;
});
};
}

} // namespace
Loading

0 comments on commit abf10a4

Please sign in to comment.