diff --git a/day1/TODO.md b/day1/TODO.md new file mode 100644 index 0000000..a14d6aa --- /dev/null +++ b/day1/TODO.md @@ -0,0 +1,2 @@ +# Rework a more efficient one usinc `memchr2()` +We can `memchr2('\n','\n', mapped_file_memory)` on a `mmap()`'d input file to find the grouping seperators, and process each group in parallel diff --git a/day14/Cargo.lock b/day14/Cargo.lock index 906d2fc..449976e 100644 --- a/day14/Cargo.lock +++ b/day14/Cargo.lock @@ -62,6 +62,7 @@ name = "day14" version = "0.1.0" dependencies = [ "color-eyre", + "jemallocator", "linebuffer", ] @@ -75,6 +76,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "fs_extra" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" + [[package]] name = "gimli" version = "0.27.0" @@ -87,6 +94,27 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "jemalloc-sys" +version = "0.5.2+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134163979b6eed9564c98637b710b40979939ba351f59952708234ea11b5f3f8" +dependencies = [ + "cc", + "fs_extra", + "libc", +] + +[[package]] +name = "jemallocator" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16c2514137880c52b0b4822b563fadd38257c1f380858addb74a400889696ea6" +dependencies = [ + "jemalloc-sys", + "libc", +] + [[package]] name = "libc" version = "0.2.138" diff --git a/day14/Cargo.toml b/day14/Cargo.toml index 4c81545..9472b52 100644 --- a/day14/Cargo.toml +++ b/day14/Cargo.toml @@ -16,6 +16,12 @@ inherits="release" #incremental=true strip=false +[features] +default= [ "jemallocator" ] + +status = ["jemallocator/profiling"] + [dependencies] color-eyre = { version = "0.6.2", default-features = false } +jemallocator = { version = "0.5.0", optional = true } linebuffer = { path = "/home/avril/work/linebuffer" } diff --git a/day14/src/main.rs b/day14/src/main.rs index ee6e8c8..a1ebe54 100644 --- a/day14/src/main.rs +++ b/day14/src/main.rs @@ -24,6 +24,14 @@ use linebuffer::{ buf::forward, }; +#[cfg(feature="jemallocator")] +const _:() = { + use jemallocator::Jemalloc; + + #[global_allocator] + static GLOBAL: Jemalloc = Jemalloc; +}; + mod ext { use super::iter::{ self, @@ -239,7 +247,7 @@ fn main() -> eyre::Result<()> { .wrap_err("Failed to parse input")?; //TODO: Deconstruct each `Line` into the horizontal and vertical movements - //eprintln!("{input:#?}"); + eprintln!("{input:#?}"); println!("{}", input.zipped_len()); //TODO: Draw lines into grid before starting simulation of sand from `ORIGIN_POINT`.