{"id":13672082,"url":"https://github.com/cppcoffee/hugepage-rs","last_synced_at":"2025-04-12T23:53:07.130Z","repository":{"id":101423589,"uuid":"388637858","full_name":"cppcoffee/hugepage-rs","owner":"cppcoffee","description":"hugepage allocator implement with rust","archived":false,"fork":false,"pushed_at":"2024-02-16T03:22:20.000Z","size":9,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T23:52:49.921Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cppcoffee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-07-23T00:52:16.000Z","updated_at":"2024-09-30T09:24:41.000Z","dependencies_parsed_at":"2024-02-16T04:23:05.076Z","dependency_job_id":"588cc647-da26-4728-ba84-8b161395b5cc","html_url":"https://github.com/cppcoffee/hugepage-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cppcoffee%2Fhugepage-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cppcoffee%2Fhugepage-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cppcoffee%2Fhugepage-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cppcoffee%2Fhugepage-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cppcoffee","download_url":"https://codeload.github.com/cppcoffee/hugepage-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647240,"owners_count":21139082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T09:01:26.172Z","updated_at":"2025-04-12T23:53:07.094Z","avatar_url":"https://github.com/cppcoffee.png","language":"Rust","readme":"## hugepage-rs\n\nhugepage-rs wrapped allocator for linux hugepage.\n\n### Usage\n\n#### HugePage Allocator\n\nHugepage allocator provides two interfaces for operation, **hugepage_rs::alloc** and **hugepage_rs::dealloc**, allocate and free hugepage memory.\n\nThe **hugepage_rs::alloc()** function allocates size bytes and returns a pointer to the allocated memory. *The memory is not initialized*. returns **std::ptr::null_mut()** if allocation fails, otherwise returns a pointer.\n\n```rust\nuse hugepage_rs;\n\nuse std::alloc::Layout;\nuse std::{mem, ptr};\n\nfn main() {\n    let layout = Layout::array::\u003cchar\u003e(2048).unwrap();\n    let dst = hugepage_rs::alloc(layout);\n\n    let src = String::from(\"hello\");\n    let len = src.len();\n    unsafe {\n        ptr::copy_nonoverlapping(src.as_ptr(), dst, len);\n        let s = String::from_raw_parts(dst, len, len);\n        assert_eq!(s, src);\n        mem::forget(s);\n    }\n\n    hugepage_rs::dealloc(dst, layout);\n}\n```\n\n#### HugePage Boxed\n\nSimple Box\u003cT\u003e implementation with ownership, data on hugepage allocated memory, released directly after going out of scope, memory allocator using hugepage allocator.\n\n```\nuse hugepage_rs;\n\nfn main() {\n    let mut v = hugepage_rs::Box::new(5);\n    *v += 42;\n    assert_eq!(*v, 47);\n}\n```\n\n\n### Notes\n\n- System need to enable hugepage.\n\n\n### Reference\n\n[Huge pages part 1 (Introduction)](https://lwn.net/Articles/374424/)\n\n[Huge pages part 2: Interfaces](https://lwn.net/Articles/375096/)\n\n[Huge pages part 3: Administration](https://lwn.net/Articles/376606/)\n\n[Huge pages part 4: benchmarking with huge pages](https://lwn.net/Articles/378641/)\n\n[Huge pages part 5: A deeper look at TLBs and costs](https://lwn.net/Articles/379748/)\n\n[https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt](https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt)\n\n[https://man7.org/linux/man-pages/man2/mmap.2.html](https://man7.org/linux/man-pages/man2/mmap.2.html)\n\n\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcppcoffee%2Fhugepage-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcppcoffee%2Fhugepage-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcppcoffee%2Fhugepage-rs/lists"}