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

perf: Add low-level memory ops benchmark #3551

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
57 changes: 56 additions & 1 deletion Cargo.Bazel.Fuzzing.json.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "e2f0c9fb8047d4200e8e14e235a3d28792aef48b70952cf21a1f849ff9ea495d",
"checksum": "ab1d07a321f087269a6c0ac490adea079290b5f94cb3e3e6d82864eeda646a73",
"crates": {
"abnf 0.12.0": {
"name": "abnf",
Expand Down Expand Up @@ -18985,6 +18985,10 @@
"id": "maxminddb 0.24.0",
"target": "maxminddb"
},
{
"id": "memmap2 0.9.5",
"target": "memmap2"
},
{
"id": "metrics-proxy 0.1.0",
"target": "metrics_proxy"
Expand Down Expand Up @@ -40887,6 +40891,56 @@
],
"license_file": "LICENSE-APACHE"
},
"memmap2 0.9.5": {
"name": "memmap2",
"version": "0.9.5",
"package_url": "https://github.com/RazrFalcon/memmap2-rs",
"repository": {
"Http": {
"url": "https://static.crates.io/crates/memmap2/0.9.5/download",
"sha256": "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f"
}
},
"targets": [
{
"Library": {
"crate_name": "memmap2",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": true,
"include": [
"**/*.rs"
]
}
}
}
],
"library_target_name": "memmap2",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [],
"selects": {
"cfg(unix)": [
{
"id": "libc 0.2.158",
"target": "libc"
}
]
}
},
"edition": "2018",
"version": "0.9.5"
},
"license": "MIT OR Apache-2.0",
"license_ids": [
"Apache-2.0",
"MIT"
],
"license_file": "LICENSE-APACHE"
},
"memoffset 0.6.5": {
"name": "memoffset",
"version": "0.6.5",
Expand Down Expand Up @@ -87537,6 +87591,7 @@
"mach2 0.4.2",
"maplit 1.0.2",
"maxminddb 0.24.0",
"memmap2 0.9.5",
"metrics-proxy 0.1.0",
"minicbor 0.19.1",
"minicbor-derive 0.13.0",
Expand Down
14 changes: 12 additions & 2 deletions Cargo.Bazel.Fuzzing.toml.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4

[[package]]
name = "abnf"
Expand Down Expand Up @@ -3133,6 +3133,7 @@ dependencies = [
"mach2",
"maplit",
"maxminddb",
"memmap2 0.9.5",
"metrics-proxy",
"minicbor",
"minicbor-derive",
Expand Down Expand Up @@ -6770,6 +6771,15 @@ dependencies = [
"libc",
]

[[package]]
name = "memmap2"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f"
dependencies = [
"libc",
]

[[package]]
name = "memoffset"
version = "0.6.5"
Expand Down Expand Up @@ -10831,7 +10841,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fac08504d60cf5bdffeb8a6a028f1a4868a5da1098bb19eb46239440039163fb"
dependencies = [
"debugid",
"memmap2",
"memmap2 0.5.10",
"stable_deref_trait",
"uuid",
]
Expand Down
57 changes: 56 additions & 1 deletion Cargo.Bazel.json.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "c940ed0c71e779f38de47e366662d71cd883022d89016936e1952a55719fe089",
"checksum": "9ba433e319b09a7df3aa9a95c2bf4483f6f955fac52a0c8f3d0db6ad8618263c",
"crates": {
"abnf 0.12.0": {
"name": "abnf",
Expand Down Expand Up @@ -18813,6 +18813,10 @@
"id": "maxminddb 0.24.0",
"target": "maxminddb"
},
{
"id": "memmap2 0.9.5",
"target": "memmap2"
},
{
"id": "metrics-proxy 0.1.0",
"target": "metrics_proxy"
Expand Down Expand Up @@ -40727,6 +40731,56 @@
],
"license_file": "LICENSE-APACHE"
},
"memmap2 0.9.5": {
"name": "memmap2",
"version": "0.9.5",
"package_url": "https://github.com/RazrFalcon/memmap2-rs",
"repository": {
"Http": {
"url": "https://static.crates.io/crates/memmap2/0.9.5/download",
"sha256": "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f"
}
},
"targets": [
{
"Library": {
"crate_name": "memmap2",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": true,
"include": [
"**/*.rs"
]
}
}
}
],
"library_target_name": "memmap2",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [],
"selects": {
"cfg(unix)": [
{
"id": "libc 0.2.158",
"target": "libc"
}
]
}
},
"edition": "2018",
"version": "0.9.5"
},
"license": "MIT OR Apache-2.0",
"license_ids": [
"Apache-2.0",
"MIT"
],
"license_file": "LICENSE-APACHE"
},
"memoffset 0.6.5": {
"name": "memoffset",
"version": "0.6.5",
Expand Down Expand Up @@ -87417,6 +87471,7 @@
"mach2 0.4.2",
"maplit 1.0.2",
"maxminddb 0.24.0",
"memmap2 0.9.5",
"metrics-proxy 0.1.0",
"minicbor 0.19.1",
"minicbor-derive 0.13.0",
Expand Down
14 changes: 12 additions & 2 deletions Cargo.Bazel.toml.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4

[[package]]
name = "abnf"
Expand Down Expand Up @@ -3122,6 +3122,7 @@ dependencies = [
"mach2",
"maplit",
"maxminddb",
"memmap2 0.9.5",
"metrics-proxy",
"minicbor",
"minicbor-derive",
Expand Down Expand Up @@ -6761,6 +6762,15 @@ dependencies = [
"libc",
]

[[package]]
name = "memmap2"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f"
dependencies = [
"libc",
]

[[package]]
name = "memoffset"
version = "0.6.5"
Expand Down Expand Up @@ -10827,7 +10837,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e0e9bc48b3852f36a84f8d0da275d50cb3c2b88b59b9ec35fdd8b7fa239e37d"
dependencies = [
"debugid",
"memmap2",
"memmap2 0.5.10",
"stable_deref_trait",
"uuid",
]
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ libflate = "2.1.0"
libnss = "0.5.0"
local-ip-address = "0.5.6"
macaddr = "1.0"
memmap2 = "0.9.5"
minicbor = { version = "0.19.1", features = ["alloc", "derive"] }
minicbor-derive = "0.13.0"
mockall = "0.13.0"
Expand Down
3 changes: 3 additions & 0 deletions bazel/external_crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,9 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable
"macaddr": crate.spec(
version = "^1.0",
),
"memmap2": crate.spec(
version = "^0.9.5",
),
"mach2": crate.spec(
# Wasmtime depends on 0.4.2 but specifies 0.4.1.
# Enforce 0.4.2 using a dummy dependency until
Expand Down
13 changes: 13 additions & 0 deletions rs/memory_tracker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,16 @@ rust_bench(
"@crate_index//:criterion",
] + DEPENDENCIES,
)

rust_bench(
name = "memory_ops_bench",
testonly = True,
srcs = ["benches/memory_ops.rs"],
data = ["benches/test-data/64KiB.txt"],
deps = [
# Keep sorted.
"@crate_index//:criterion",
"@crate_index//:memmap2",
"@crate_index//:rayon",
] + DEPENDENCIES,
)
12 changes: 9 additions & 3 deletions rs/memory_tracker/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "memory_tracker"
version.workspace = true
authors.workspace = true
edition.workspace = true
description.workspace = true
documentation.workspace = true
edition.workspace = true
name = "memory_tracker"
version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -25,9 +25,15 @@ sigsegv_handler_checksum = []
[dev-dependencies]
criterion = { workspace = true }
ic-types = { path = "../types/types" }
memmap2 = { workspace = true }
proptest = { workspace = true }
rayon = { workspace = true }
tempfile = { workspace = true }

[[bench]]
harness = false
name = "traps"

[[bench]]
harness = false
name = "memory_ops"
Loading
Loading