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

Build step is prohibitively expensive #58

Closed
jrwats opened this issue Jun 14, 2021 · 4 comments
Closed

Build step is prohibitively expensive #58

jrwats opened this issue Jun 14, 2021 · 4 comments

Comments

@jrwats
Copy link

jrwats commented Jun 14, 2021

cargo build takes ~2 minutes to run on my 2019 macbook. rust-analyzer (running in my editor — I believe on any given file-save) also wreaks havoc on my CPU when trying to edit files here. Worse yet, it appears to spin up multiple build-script async processes eagerly...

I'd love to contribute more to this project, but these costly build steps make it hard. (FWIW, I'm specifically interested in improving fn legal in board.rs)

Perhaps there's room to better separate the table generation from other source files into a core or table sub-crate?
(I was toying with Board and BoardBuilder at the time)

The experience pushed me to a composition model instead (preferable anyhow) wherein I consume the chess crate and hack up my own stuff (though there's still some code duplication), for Bughouse

@jordanbray
Copy link
Owner

jordanbray commented Jun 14, 2021 via email

@jordanbray
Copy link
Owner

jordanbray commented Jun 14, 2021 via email

@jrwats
Copy link
Author

jrwats commented Jun 14, 2021

I do think about the magic numbers as compiled objects, so I'd like them built at build-time (rather than a static file). Maybe, however, there is away to speed that up quite a bit.

✓. Yeah, I don't disagree

  1. In debug mode, a relatively huge quantity of time is spent making bit boards. These are just u64s, but the compiler isn't smart enough to see that in debug.

Sorry, do you mean that the compiler isn't smart enough to see the bit boards are just u64, and is doing somethign sub-optimal when building these or something else?

  1. There may be a large number of optimizations in the initial "sliding piece" implementations.

  1. There may be a implementation for the "guess and check" portion of the algorithm that copies less or something.
    I'll have to read more code to see what you mean

My biggest gripe with my experience was I slightly tweaked board.rs and board_builder.rs hacking around with various ideas, and every minor tweak was met with a 2 minute long whirring of my CPU (limiting coding while on battery to ~2hours).

I was under the impression that most of what was being generated were many many u64 bitboards, and in my mind, these should just be built "independent" of board.rs and board_builder.rs. There's no reason for a bunch of numbers to depend on board.rs etc, so perhaps there's some dependency refactoring that can be done to spell this out better for the compiler and build.rs?

In the very least, I could see organizing crates like:

  • chess_core with all your shared constants and such (which both chess-tables and chess would ingest.
  • chess_tables (where all this "built" stuff lives - build.rs goes here), and
  • chess, ingesting both of the above
chess ➡ chess_tables
     ⬊       ⬇
        chess_core

NOTE: I'm still very new to Rust, so I'm not sure whether all my terms or suggestions above make complete sense

@adri326
Copy link

adri326 commented Aug 5, 2023

I still find the build step quite slow, and I'm wondering what's stopping you from baking these numbers once for everyone upon a release?

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

3 participants