Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import third party collections and use internal Allocator API #631

Merged
merged 3 commits into from
Sep 24, 2023
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
17 changes: 14 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
- run: cargo build --workspace

miri:
miri_rune:
runs-on: ubuntu-latest
needs: basics
steps:
Expand All @@ -71,7 +71,18 @@ jobs:
with:
components: miri
- uses: Swatinem/rust-cache@v2
- run: cargo +nightly miri test -p rune --all-features -- runtime hir::arena
- run: cargo miri test -p rune --all-features -- runtime hir::arena

miri_rune_alloc:
runs-on: ubuntu-latest
needs: basics
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: miri
- uses: Swatinem/rust-cache@v2
- run: cargo miri test -p rune-alloc --all-features

no_default_features:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -108,7 +119,7 @@ jobs:

test:
runs-on: ubuntu-latest
needs: [no_default_features, build_feature, docs, msrv, miri, wasm]
needs: [no_default_features, build_feature, docs, msrv, miri_rune, miri_rune_alloc, wasm]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
Expand Down
9 changes: 7 additions & 2 deletions benches/benches/benchmarks/aoc_2020_19b.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use criterion::Criterion;

use rune::alloc::TryClone;

criterion::criterion_group!(benches, aoc_2020_19b);

const INPUT: &str = include_str!("data/aoc_2020_19b.txt");
Expand All @@ -8,7 +10,7 @@ fn aoc_2020_19b(b: &mut Criterion) {
let mut data = rune::runtime::Vec::new();

for line in INPUT.split('\n').filter(|s| !s.is_empty()) {
data.push(line.to_owned().into());
data.push(rune::to_value(line.to_owned()).unwrap()).unwrap();
}

let mut vm = rune_vm! {
Expand Down Expand Up @@ -234,6 +236,9 @@ fn aoc_2020_19b(b: &mut Criterion) {
let entry = rune::Hash::type_hash(["main"]);

b.bench_function("aoc_2020_19b", |b| {
b.iter(|| vm.call(entry, (data.clone(),)).expect("failed call"));
b.iter(|| {
vm.call(entry, (data.try_clone().unwrap(),))
.expect("failed call")
});
});
}
6 changes: 5 additions & 1 deletion benches/benches/benchmarks/aoc_2020_1a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use anyhow::Context;
use criterion::Criterion;
use rune::alloc::TryClone;

criterion::criterion_group!(benches, aoc_2020_1a);

Expand Down Expand Up @@ -86,6 +87,9 @@ fn aoc_2020_1a(b: &mut Criterion) {
let entry = rune::Hash::type_hash(["main"]);

b.bench_function("aoc_2020_1a", |b| {
b.iter(|| vm.call(entry, (data.clone(),)).expect("failed call"));
b.iter(|| {
vm.call(entry, (data.try_clone().unwrap(),))
.expect("failed call")
});
});
}
7 changes: 6 additions & 1 deletion benches/benches/benchmarks/aoc_2020_1b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
use criterion::Criterion;

use rune::alloc::TryClone;

criterion::criterion_group!(benches, aoc_2020_1b);

const INPUT: &str = include_str!("data/aoc_2020_1.txt");
Expand Down Expand Up @@ -60,6 +62,9 @@ fn aoc_2020_1b(b: &mut Criterion) {
let entry = rune::Hash::type_hash(["main"]);

b.bench_function("aoc_2020_1b", |b| {
b.iter(|| vm.call(entry, (data.clone(),)).expect("failed call"));
b.iter(|| {
vm.call(entry, (data.try_clone().unwrap(),))
.expect("failed call")
});
});
}
1 change: 1 addition & 0 deletions crates/rune-alloc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/patches/
26 changes: 26 additions & 0 deletions crates/rune-alloc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "rune-alloc"
version = "0.12.3"
authors = ["John-John Tedro <[email protected]>"]
edition = "2021"
rust-version = "1.70"
description = "The Rune Language, an embeddable dynamic programming language for Rust."
documentation = "https://docs.rs/rune"
readme = "README.md"
homepage = "https://github.com/rune-rs/rune"
repository = "https://github.com/rune-rs/rune"
license = "MIT OR Apache-2.0"
keywords = ["language", "scripting", "scripting-language"]
categories = ["parser-implementations"]

[features]
default = ["std", "serde"]
std = ["alloc", "ahash/std"]
alloc = []

[dependencies]
serde = { version = "1.0", optional = true }
ahash = { version = "0.8.3", default-features = false }

[dev-dependencies]
rand = { version = "0.8.5", features = ["small_rng"] }
Loading
Loading