Skip to content

Conversation

@shermanjlim
Copy link

Description

Fixes #7

Sherman Jun Hong Lim added 2 commits October 24, 2025 21:08
@gemini-code-assist
Copy link

Summary of Changes

Hello @shermanjlim, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new C++ utility that facilitates the conversion of Meta Tectonic block storage traces into a libCacheSim-compatible object trace format. The script intelligently processes raw block traces, segmenting them into fixed-size cache objects (128 KiB chunks) and incorporating a sampling feature to manage trace size. This enhancement is crucial for enabling accurate simulations using libCacheSim with Meta's block storage data, and the documentation has been updated to reflect this new capability and provide necessary context.

Highlights

  • New Trace Conversion Script: A new C++ script, conv_meta_block.cpp, has been added to convert Meta Tectonic block storage traces into an object-based format compatible with libCacheSim.
  • Block to Object Conversion Logic: The conversion script processes storage blocks by breaking them down into fixed-size 128 KiB chunks, treating each chunk as a distinct cache object. It also includes a sampling mechanism to process a fraction of blocks.
  • Documentation Update: The README.md file has been updated to document the new trace conversion utility and clarify how block_id and rs_shard_id uniquely identify a storage node block within Meta Tectonic traces.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a C++ script to convert Meta Tectonic traces into a format compatible with libCacheSim, along with corresponding updates to the README. The script is a solid addition, but I've identified some critical robustness issues related to CSV parsing that could cause crashes on malformed input. My review includes suggestions to handle these errors gracefully. I've also provided feedback to improve code maintainability and adhere to standard C++ practices, such as using named constants and directing error output to stderr.

Comment on lines +70 to +74
op_time = std::stoull(cells[0]);
block_id = cells[1];
io_size = std::stoull(cells[3]);
io_offset = std::stoull(cells[4]);
rs_shard_id = cells[10];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The CSV parsing logic here is not robust and could cause the program to crash if it encounters malformed data.

  1. Out-of-bounds access: The code accesses cells[10] without checking if the line has at least 11 columns. This will lead to undefined behavior on shorter lines.
  2. Unhandled exceptions: std::stoull will throw an exception if a string is not a valid number, which will terminate the program.

You should add validation to handle these cases gracefully, for instance by wrapping the parsing in a try-catch block and checking cells.size().

if (cells.size() < 11) {
    std::cerr << "Skipping malformed line (not enough columns): " << line << std::endl;
    continue;
}
try {
    op_time = std::stoull(cells[0]);
    block_id = cells[1];
    io_size = std::stoull(cells[3]);
    io_offset = std::stoull(cells[4]);
    rs_shard_id = cells[10];
} catch (const std::exception& e) {
    std::cerr << "Skipping line due to conversion error: " << e.what() << " in line: " << line << std::endl;
    continue;
}

Comment on lines +20 to +21
std::cout << "Usage: " << argv[0]
<< " <output_csv> <input_csv1> [<input_csv2> ...]\n";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's standard practice to print usage information to std::cerr rather than std::cout. This allows users to redirect standard output (e.g., to a file) without capturing usage or error text.

Suggested change
std::cout << "Usage: " << argv[0]
<< " <output_csv> <input_csv1> [<input_csv2> ...]\n";
std::cerr << "Usage: " << argv[0]
<< " <output_csv> <input_csv1> [<input_csv2> ...]\n";

// open files
std::ofstream output_csv{argv[1]};
if (!output_csv) {
std::cout << "Error: Could not open file " << argv[1] << std::endl;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Error messages should be written to std::cerr instead of std::cout to separate diagnostic output from the program's primary output.

Suggested change
std::cout << "Error: Could not open file " << argv[1] << std::endl;
std::cerr << "Error: Could not open file " << argv[1] << std::endl;

Comment on lines +32 to +37
for (size_t i = 2; i < argc; ++i) {
input_csvs.emplace_back(argv[i]);
if (!input_csvs.back()) {
std::cout << "Error: Could not open file " << argv[i] << std::endl;
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current logic prints an error but continues if an input file fails to open. This could lead to an incomplete conversion without a clear failure signal. It's more robust to exit immediately upon failing to open a required file. Also, error messages should be directed to std::cerr.

Suggested change
for (size_t i = 2; i < argc; ++i) {
input_csvs.emplace_back(argv[i]);
if (!input_csvs.back()) {
std::cout << "Error: Could not open file " << argv[i] << std::endl;
}
}
for (size_t i = 2; i < argc; ++i) {
input_csvs.emplace_back(argv[i]);
if (!input_csvs.back()) {
std::cerr << "Error: Could not open file " << argv[i] << std::endl;
return EXIT_FAILURE;
}
}

Comment on lines +50 to +54
size_t op_time; // 0
std::string block_id; // 1
size_t io_size; // 3
size_t io_offset; // 4
std::string rs_shard_id; // 10

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using magic numbers for column indices, as indicated by the comments, makes the code harder to read and maintain. If the column order of the input trace changes, you'd have to find all occurrences of these numbers. It would be better to define these as named constants.

For example:

constexpr size_t kColOpTime = 0;
constexpr size_t kColBlockId = 1;
// ...etc.

// Then use them in the loop:
op_time = std::stoull(cells[kColOpTime]);

@shermanjlim shermanjlim marked this pull request as draft October 24, 2025 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potential issue with mapping of block_id to object in Meta Tectonic OracleGeneral format

1 participant