Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support v7 log format #122

Merged
merged 1 commit into from
Jan 15, 2025
Merged

Support v7 log format #122

merged 1 commit into from
Jan 15, 2025

Conversation

elliotgoodrich
Copy link
Owner

The future log format will be using rapidhash instead of murmurhash in order to calculate the hash of the build command. In order not to break in the future we add support now for when the next version of ninja is released.

Unfortunately this means that we need to save the whole build command when parsing instead of generating the hash and discarding the string. This is because we can only locate the .ninja_log file once we parse the entire ninja build file to look for any builddir variables. Then only once we have the directory can we attempt to load the .ninja_log file to figure out which hash function it uses.

However, after this change we now get a small performance benefit when there is no .ninja_log file or when it contains entries that don't now exist in the ninja build file because we only hash the current build command if necessary.

In order to try and reduce some of the extra work we do, this commit also changes the LogReader constructor to pass a bitfield on what fields we want to read. In our case this saves us having to decipher the start, end, and modification times of each entry, which we don't need. There are a lot of conditionals here, but they should be predicted by the branch predictor and so changing them to a template paramater isn't needed right now.

The future log format will be using rapidhash instead of murmurhash in
order to calculate the hash of the build command.  In order not to break
in the future we add support now for when the next version of ninja is
released.

Unfortunately this means that we need to save the whole build command
when parsing instead of generating the hash and discarding the string.
This is because we can only locate the `.ninja_log` file once we parse
the entire ninja build file to look for any `builddir` variables.  Then
only once we have the directory can we attempt to load the `.ninja_log`
file to figure out which hash function it uses.

However, after this change we now get a small performance benefit when
there is no `.ninja_log` file or when it contains entries that don't
now exist in the ninja build file because we only hash the current
build command if necessary.

In order to try and reduce some of the extra work we do, this commit
also changes the `LogReader` constructor to pass a bitfield on what
fields we want to read.  In our case this saves us having to decipher
the start, end, and modification times of each entry, which we don't
need.  There are a lot of conditionals here, but they should be
predicted by the branch predictor and so changing them to a template
paramater isn't needed right now.
@elliotgoodrich
Copy link
Owner Author

Add support after ninja-build/ninja#2519

@elliotgoodrich elliotgoodrich merged commit a4ab0df into main Jan 15, 2025
8 checks passed
@elliotgoodrich elliotgoodrich deleted the new-log-format-support branch January 15, 2025 20:05
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant