Skip to content

Commit

Permalink
fix: cargo deny + lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuthor committed Dec 2, 2024
1 parent c2a24e2 commit 4615d20
Show file tree
Hide file tree
Showing 26 changed files with 381 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benches.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Benches

on: [workflow_dispatch, pull_request, push]
on: [workflow_dispatch]

jobs:
bench:
Expand Down
29 changes: 18 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: datasets|tests_data|documentation/Findex.pdf|tests/first_names.txt
exclude: datasets|tests_data|documentation/Findex.pdf|tests/first_names.txt|benches/data
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.1.1
Expand Down Expand Up @@ -118,20 +118,27 @@ repos:
args: [--skip-string-normalization]

- repo: https://github.com/Cosmian/git-hooks.git
rev: v1.0.16
rev: v1.0.32
hooks:
- id: stable-cargo-format
- id: cargo-upgrade
- id: cargo-update
- id: cargo-format
# - id: cargo-upgrade
# - id: cargo-update
- id: cargo-machete
- id: cargo-outdated
- id: cargo-udeps
- id: docker-compose-up
- id: cargo-tests-all
- id: cargo-test-doc
- id: clippy-autofix-all
- id: clippy-autofix-pedantic
- id: clippy-autofix-others
- id: clippy-autofix-unreachable-pub
- id: clippy-autofix-all-targets-all-features
- id: clippy-autofix-all-targets
- id: clippy-all-targets-all-features
- id: stable-cargo-format
- id: clippy-all-targets
- id: cargo-format
- id: cargo-dry-publish
args: [--allow-dirty]
- id: docker-compose-down

- repo: https://github.com/EmbarkStudios/cargo-deny
rev: 0.16.1 # choose your preferred tag
hooks:
- id: cargo-deny
args: [--all-features, check]
22 changes: 19 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
[package]
name = "findex"
version = "0.1.0"
name = "cosmian_findex"
version = "7.0.0"
authors = [
"Chloé Hébant <[email protected]>",
"Bruno Grieder <[email protected]>",
"Célia Corsin <[email protected]>",
"Emmanuel Coste <[email protected]>",
"Théophile Brézot <[email protected]>",
]
categories = ["cosmian::crypto"]
edition = "2021"
keywords = ["SSE"]
license = "BUSL-1.1"
repository = "https://github.com/Cosmian/findex/"
description = "Symmetric Searchable Encryption"

[lib]
name = "cosmian_findex"
path = "src/lib.rs"

[features]
bench = []
Expand All @@ -28,7 +44,7 @@ cosmian_crypto_core = "9.6.1"
[dev-dependencies]
criterion = "0.5.1"
serial_test = "3.2.0"
futures = "0.3.30"
futures = "0.3.31"
lazy_static = "1.5.0"
tokio = { version = "1.38.0", features = [
"rt",
Expand Down
23 changes: 9 additions & 14 deletions benches/benches.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::{collections::HashSet, time::Duration};

use cosmian_findex::{Findex, InMemory, IndexADT, MemoryADT, Op, Secret, WORD_LENGTH};
#[cfg(feature = "test-utils")]
use cosmian_findex::{dummy_decode, dummy_encode};
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use findex::{
Findex, InMemory, IndexADT, MemoryADT, Op, Secret, WORD_LENGTH, dummy_decode, dummy_encode,
};
use futures::{executor::block_on, future::join_all};
use lazy_static::lazy_static;
use rand_chacha::ChaChaRng;
Expand All @@ -17,7 +17,7 @@ fn make_scale(start: usize, stop: usize, n: usize) -> Vec<f32> {
let step = ((stop - start) as f32) / n as f32;
let mut points = Vec::with_capacity(n);
for i in 0..=n {
points.push(start as f32 + i as f32 * step);
points.push((i as f32).mul_add(step, start as f32));
}
points
}
Expand Down Expand Up @@ -58,16 +58,11 @@ fn bench_search_multiple_bindings(c: &mut Criterion) {
let seed = Secret::random(&mut rng);
let stm = InMemory::default();
let index = build_benchmarking_bindings_index(&mut rng);
let findex = Findex::new(
seed.clone(),
stm,
dummy_encode::<WORD_LENGTH, _>,
dummy_decode,
);
let findex = Findex::new(seed, stm, dummy_encode::<WORD_LENGTH, _>, dummy_decode);
block_on(findex.insert(index.clone().into_iter())).unwrap();

let mut group = c.benchmark_group("Multiple bindings search (1 keyword)");
for (kw, vals) in index.clone().into_iter() {
for (kw, vals) in index {
group.bench_function(BenchmarkId::from_parameter(vals.len()), |b| {
b.iter_batched(
|| {
Expand Down Expand Up @@ -129,7 +124,7 @@ fn bench_search_multiple_keywords(c: &mut Criterion) {
findex.clear();
// Using .cloned() instead of .clone() reduces the overhead (maybe because
// it only clones what is needed)
index.iter().map(|(kw, _)| kw).take(n).cloned()
index.iter().map(|(kw, _)| kw).take(n).copied()
},
|kws| {
block_on(findex.search(kws)).expect("search failed");
Expand All @@ -151,7 +146,7 @@ fn bench_insert_multiple_bindings(c: &mut Criterion) {
// Reference: write one word per value inserted.
{
let mut group = c.benchmark_group("write n words to memory");
for (_, vals) in index.clone().into_iter() {
for (_, vals) in index.clone() {
let stm = InMemory::with_capacity(n_max + 1);
group
.bench_function(BenchmarkId::from_parameter(vals.len()), |b| {
Expand Down Expand Up @@ -179,7 +174,7 @@ fn bench_insert_multiple_bindings(c: &mut Criterion) {
// Bench it
{
let mut group = c.benchmark_group("Multiple bindings insert (same keyword)");
for (kw, vals) in index.clone().into_iter() {
for (kw, vals) in index {
let stm = InMemory::with_capacity(n_max + 1);
let findex = Findex::new(
seed.clone(),
Expand Down
16 changes: 8 additions & 8 deletions benches/make_figures.tex
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
\addplot[color=red] table [y={create col/linear regression}] {./data/search.dat};
\addlegendentry{search-time(\#bindings)}
\addlegendentry{
$ y =
\pgfmathprintnumber{\pgfplotstableregressiona}
\cdot b
\pgfmathprintnumber[print sign]{\pgfplotstableregressionb}$
$ y =
\pgfmathprintnumber{\pgfplotstableregressiona}
\cdot b
\pgfmathprintnumber[print sign]{\pgfplotstableregressionb}$
}
\end{axis}
\end{tikzpicture}
Expand All @@ -36,10 +36,10 @@
\addplot[color=red] table [y={create col/linear regression}] {./data/insert.dat};
\addlegendentry{insertion-time(\#bindings)}
\addlegendentry{
$ y =
\pgfmathprintnumber{\pgfplotstableregressiona}
\cdot b
\pgfmathprintnumber[print sign]{\pgfplotstableregressionb}$
$ y =
\pgfmathprintnumber{\pgfplotstableregressiona}
\cdot b
\pgfmathprintnumber[print sign]{\pgfplotstableregressionb}$
}
\end{axis}
\end{tikzpicture}
Expand Down
Loading

0 comments on commit 4615d20

Please sign in to comment.