-
Notifications
You must be signed in to change notification settings - Fork 58
create Rust bindings #125
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
Comments
I would like to work on this issue. Is it okay to assign it to me? Thank you so much! |
I generated rust bindings using
Or is using the raw bindings just fine (but we will need to handle
Besides, I have |
Awesome!
|
Sorry for the delay. I run into some problems with What I have now:
In the use libcachesim_rs::bindings::*;
use libcachesim_rs::wrapper::*;
fn main() {
// Open the trace file
println!("Rust equivalent of test.c");
let mut init_params_csv = Reader::default_reader_init_params();
init_params_csv.delimiter = ',' as i8; // b',' as std::os::raw::c_char,
init_params_csv.time_field = 2;
init_params_csv.obj_id_field = 6;
init_params_csv.obj_size_field = 4;
init_params_csv.has_header = false;
let mut reader = match Reader::open_trace("../data/trace.csv", trace_type_e_CSV_TRACE, &init_params_csv) {
Some(r) => r,
None => {
eprintln!("Failed to open trace.");
return;
}
};
// Create a request container
let req = match Request::new_request() {
Some(r) => r,
None => {
eprintln!("Failed to create request.");
return;
}
};
// Define cache parameters and create the cache
let cache_params = common_cache_params_t {
cache_size: 1024 * 1024,
..Default::default()
};
let cache = match Cache::LRU_init(cache_params, "") {
Some(c) => c,
None => {
eprintln!("Failed to initialize cache.");
return;
}
};
// Counters
let mut n_req = 0;
let mut n_miss = 0;
// Loop through the trace
while reader.read_one_req(&req) == 0 {
if !cache.get(&req) {
n_miss += 1;
}
n_req += 1;
}
// Print the miss ratio
if n_req > 0 {
println!("miss ratio: {:.4}", n_miss as f64 / n_req as f64);
} else {
println!("No requests were processed.");
}
// Clean up happens automatically due to Drop implementations
} But I have some questions when testing things out.
[WARN] 03-23-2025 19:34:11 csv.c:61 (tid=8633382976): in_buf_size 1024 is smaller than the first line size 18446744073709551615, the first line will be truncatedAssertion failed: (buf_size < 1024), function csv_detect_header, file csv.c, line 125.
zsh: abort ../test.out When running [WARN] 03-23-2025 19:56:08 csv.c:61 (tid=8633382976): in_buf_size 1024 is smaller than the first line size 18446744073709551615, the first line will be truncatedAssertion failed: (buf_size < 1024), function csv_detect_header, file csv.c, line 125.
zsh: abort cargo run So I guess I am not as familiar with the code base, but I cannot seem to figure out why for now. Next step, I will write more Rust wrappers. I only wrote the basic ones for testing purposes. |
No description provided.
The text was updated successfully, but these errors were encountered: