Skip to content
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

Inconsistent output between --lib and --bin #31

Open
panstromek opened this issue Sep 12, 2020 · 0 comments
Open

Inconsistent output between --lib and --bin #31

panstromek opened this issue Sep 12, 2020 · 0 comments

Comments

@panstromek
Copy link
Contributor

I am pretty confused by what llvm-lines is actually measuring. I think @nnethercote raised similar concern on internals some time ago, I just found another pretty confusing instance and I don't really understand what's going on.

I have a crate and it has two targets - one lib and one bin. bin target is simple - it doesn't actually do anything, it only calls main function from a lib.

use legacy_zebra::src::zebra::main as main_lib;

fn main () {
    main_lib();
}

And yet, when I run both targets through llvm-lines, I get completely different output.

cargo llvm-lines --lib 

Lines         Copies      Function name
  -----         ------      -------------
  54411 (100%)  468 (100%)  (TOTAL)
   2939 (5.4%)    1 (0.2%)  engine::src::end::end_tree_search
   2549 (4.7%)    1 (0.2%)  engine::src::midgame::tree_search
   2238 (4.1%)    1 (0.2%)  engine::src::getcoeff::unpack_coeffs
   1682 (3.1%)    1 (0.2%)  engine::src::thordb::database_search
   1622 (3.0%)    1 (0.2%)  legacy_zebra::src::zebra::main_0
   1594 (2.9%)    1 (0.2%)  legacy_zebra::src::zebra::analyze_game
   1581 (2.9%)    1 (0.2%)  engine::src::game::generic_compute_move
   1545 (2.8%)    1 (0.2%)  engine::src::end::end_game
   1512 (2.8%)    1 (0.2%)  engine::src::midgame::root_tree_search
   1276 (2.3%)    1 (0.2%)  legacy_zebra::src::osfbook::add_new_game
   1198 (2.2%)    1 (0.2%)  engine::src::zebra::engine_play_game
   1108 (2.0%)    1 (0.2%)  engine::src::osfbook::get_book_move
   1010 (1.9%)    1 (0.2%)  legacy_zebra::src::zebra::run_endgame_script
    982 (1.8%)    1 (0.2%)  legacy_zebra::src::osfbook::book_statistics
    927 (1.7%)    1 (0.2%)  legacy_zebra::src::osfbook::do_correct
    889 (1.6%)    1 (0.2%)  engine::src::midgame::middle_game
    852 (1.6%)    1 (0.2%)  legacy_zebra::src::display::display_board
    842 (1.5%)    1 (0.2%)  engine::src::getcoeff::load_set
    834 (1.5%)    1 (0.2%)  engine::src::midgame::fast_tree_search
    784 (1.4%)    1 (0.2%)  engine::src::thordb::choose_thor_opening_move
    722 (1.3%)    1 (0.2%)  engine::src::osfbook::fill_move_alternatives
    706 (1.3%)    1 (0.2%)  legacy_zebra::src::osfbook::convert_opening_list
    684 (1.3%)    1 (0.2%)  legacy_zebra::src::game::ponder_move
cargo llvm-lines --bin zebra 

Lines          Copies       Function name
  -----          ------       -------------
  163815 (100%)  1340 (100%)  (TOTAL)
   13340 (8.1%)     1 (0.1%)  engine::src::getcoeff::constant_and_parity_feature
    4630 (2.8%)     1 (0.1%)  std::backtrace_rs::symbolize::gimli::elf::<impl std::backtrace_rs::symbolize::gimli::Mapping>::new
    3767 (2.3%)     1 (0.1%)  engine::src::doflip::DoFlips_hash
    3123 (1.9%)     1 (0.1%)  engine::src::getcoeff::terminal_patterns
    2800 (1.7%)     1 (0.1%)  engine::src::end::end_tree_search
    2715 (1.7%)     1 (0.1%)  engine::src::doflip::DoFlips_no_hash
    2531 (1.5%)     1 (0.1%)  addr2line::ResUnit<R>::parse_lines
    2471 (1.5%)     1 (0.1%)  miniz_oxide::inflate::core::decompress
    2426 (1.5%)     1 (0.1%)  engine::src::midgame::tree_search
    2210 (1.3%)     1 (0.1%)  engine::src::getcoeff::unpack_coeffs
    2082 (1.3%)   107 (8.0%)  core::ptr::drop_in_place
    2056 (1.3%)     1 (0.1%)  std::backtrace_rs::symbolize::gimli::resolve
    1644 (1.0%)     1 (0.1%)  gimli::read::unit::parse_attribute
    1624 (1.0%)     1 (0.1%)  engine::src::thordb::database_search
    1490 (0.9%)     1 (0.1%)  legacy_zebra::src::zebra::analyze_game
    1464 (0.9%)     1 (0.1%)  gimli::read::unit::Attribute<R>::value
    1440 (0.9%)     1 (0.1%)  engine::src::game::generic_compute_move
    1440 (0.9%)     1 (0.1%)  engine::src::midgame::root_tree_search
    1424 (0.9%)     1 (0.1%)  engine::src::end::solve_parity_hash_high
    1374 (0.8%)     1 (0.1%)  engine::src::end::end_game
    1308 (0.8%)     1 (0.1%)  addr2line::ResUnit<R>::parse_functions
    1283 (0.8%)     1 (0.1%)  legacy_zebra::src::zebra::main_0
    1173 (0.7%)     1 (0.1%)  engine::src::zebra::engine_play_game
    1163 (0.7%)     1 (0.1%)  legacy_zebra::src::osfbook::add_new_game

I thought this could be because the main function calls some generic function in dependencies, so if you don't call it, then those dependencies are not codegened. But the main function is actually present in both outputs (as main_0) - and more than that, it has different line count.

    1283 (0.8%)     1 (0.1%)  legacy_zebra::src::zebra::main_0
    1622 (3.0%)     1 (0.2%)  legacy_zebra::src::zebra::main_0

This is really confusing to me, and I don't really understand how to interpret the results. There's no diference between these targets but the llvm-lines output is massively different and the functions that stand out seems to be all over the place. Some are generic, some are not. Some functions from dependencies are shown, some not (some are generic, some are not).

The project is not open source, yet, so it might be difficult to interpret now. I will open source it in following weeks/months, though.

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

No branches or pull requests

1 participant