The sound distributed version control system

#804 Split Pijul CLI into multiple sub-crates

Opened by finchie on June 15, 2023
finchie on June 15, 2023

I have been making quite a bit of progress on reducing the time taken to run cargo build. The changes so far have been focused on 2 main areas:

  1. Removing unnecessary dependencies
    • Some crates have overlapping functionality
    • The default feature list can include unused features
  2. Splitting the pijul crate into smaller sub-crates
    • As the crate is Rust’s unit of compilation, this should help increase rate of iteration through faster build times
    • This also allows for functionality to be used by other crates in the ecosystem (eg @laumann ’s pijul-conflicts)

A future area to improve, as mentioned by @pmeunier on this Zulip thread, would be to feature-gate features such as ssh (similar to how git is already feature-gated). I would also like to investigate using a faster linker (preferably mold) and even cranelift as a codegen backed for debug builds.

For now my current plan is to keep writing patches that focus on splitting the project down into smaller crates where appropriate. If there is anything I can do to help make the review process easier, please let me know.

finchie added a change on June 15, 2023
6B5SYXGBWMM5GMSOHD6GZITBNUYICSI2TXSRACJU6Q72BEU7XFHQC
finchie added a change on June 15, 2023
Remove dependency on `once_cell` created on June 11, 2023
KT4WB6SS4BNVHP56L2DIEIP5CMIFCGXR7ASJFGWLMNOQE6UQFUIQC
finchie added a change on June 15, 2023
Remove dependency on `num_cpus` created on June 11, 2023
DAD6VPVMOCIO7MRJLYCBBV4W4YTBM2O3LLNMHWSZ65TBOY5QCXZAC
finchie added a change on June 15, 2023
Remove dependency on `edit` created on June 11, 2023
2MVT53CF3CC4FHPJWUNS3ZCCPRO26ROA5JAYCRGQQ4SH3SO2YGSAC
finchie added a change on June 15, 2023
Remove unused dependencies created on June 12, 2023
W4I475BAIGW773KXJYLIBDITAL2ZHBY272MFUM7FJ2VDVBCWEXGAC
finchie added a change on June 15, 2023
6V7TYLGFEMV6SKQQTLDAA54QD6ONHSIZR2I6USVWQL26PR5GKZ3QC
finchie added a change on June 15, 2023
Q45BC4OC3NSRLJANNOBHENZCFSF7SG2MMYMZR4247CPZXOJ5VSSAC
finchie added a change on June 15, 2023
EANS7ZO6FZUQWLOQIHTPBCT7AL2JRLKGVREGA3UKA6H62TKPLK7AC
finchie added a change on June 15, 2023
74AO75NC2QLA3CIKOSODATGAAKIXHOJ6Q4PTLMVA6UNMISOSKT4QC
finchie added a change on June 15, 2023
GIUFBB4JN5HJACG5QTNWRJJMOVLK5LFICCO24CTGF72ZOMYMX5HQC
finchie added a change on June 15, 2023
CRQRKNFZMUM3LJQU2CG63JYLFI7WGP6HWQTTBVSK6YQKBK37LLBAC
finchie added a change on June 15, 2023
MBPJKPWPR5JO6TZPGLFMNGHL3YJ33IYMJUGCU2XKVFEW2HNN6EAQC
laumann on June 15, 2023

Nice to get some unnecessary dependencies removed.

Do you have any numbers for the compilation time before and after these changes?

As for the crate splitting, the only thing pijul-conflicts would really need from the pijul crate is the Repository struct, and maybe a few other odds and ends. I wouldn’t necessarily explode the pijul crate into many small crates, instead I’d probably have a libpijul-cli (or something in that vein) that indicates it’s useful utilities for creating CLI extensions that hook into pijul and libpijul.

pmeunier on June 16, 2023

Excellent work! Thanks a lot @finchie.

loewenheim on June 16, 2023

As described in #807, this appears to have caused a bug in change recording.

pmeunier on June 16, 2023

Yes, and it also triggered two other bugs:

  • When unrecording them on my machine, I noticed a conflict had appeared. This was due to a bug in unrecord, now fixed by #XNY6VDZSCNHSAS53HRVBT5AO7HBMAWPOQX3ORCYPWVWRKA4EXMFQC. The bug was in a part that isn’t tested very often, which is when we un-delete a vertex. Currently only unrecord does this, and most projects obviously unrecord much less than they apply.

  • The Nest deleted the patches when I deleted them from main. This is a serious bug, but since I’m rewriting the Nest I don’t think I will fix it.

finchie on June 16, 2023

I am very sorry to have caused these issues, looking at this with a fresh pair of eyes I realized that it was not at all obvious that I didn’t intend for these patches to be merged so soon. I’ll get back to you once this is resolved.

finchie on August 17, 2023

These patches have been completely re-written, with a more direct focus on splitting the repository into logical parts instead of improving compile times. That being said, these changes will probably help with such a goal. I’ve listed all the crates that these new patches add to the workspace below, and of course if there’s anything I can do to help or improve these patches please let me know.

pijul-interaction

This is a completely new crate, with a focus on centralizing methods of interacting with the user. This includes functionality such as:

  • Indicators:
    • Progress bars
    • Spinners
  • Prompts
    • Selection
    • Password
    • Text
    • Confirmation

The crate currently supports 2 contexts for interactivity, InteractiveContext::NotInteractive and InteractiveContext::Terminal. Terminal interactivity is handled by indicatif and dialoguer, and the non-interactive side stores all interaction state and returns an erorr if user input is required. In the future this crate could be extended to handle other contexts (such as web browsers or IDEs), and include proper localization support. It should also be possible to add a testing backend that makes it possible to write expressive tests for how we interact with the user.

I suspect that the NotInteractive context will need a little fine-tuning before it is production-ready, but I think the best way to solve this would be comprehensive testing of the command-line interface. I think Rust’s CLI testing ecosystem still needs some maturation and perhaps this will motivate me to drive it slightly forward :)

pijul-config

This is the old pijul::config module refactored into its own crate. Not much has changed here, but it probably needs a design review at some point as it seems to have grown mostly organically over time.

pijul-repository

To me, this is the most important crate to come out of this refactoring. Most people looking to use pijul programmatically will probably want this level of abstraction, rather than libpijul itself. As mentioned by @stellarpower on Zulip, this would probably need a lot of documentation and polish so users can interact with the library without knowing too much of the internals.

pijul-identity

Not much to say here, there are definitely known areas for improvement, mostly around syncing identities. Mostly unchanged.

pijul-remote

Same here, it has inherited the prove functionality that previously was in pijul::identity, as this created a circular dependency.

finchie added a change on August 17, 2023
Bump lockfile created on July 12, 2023
RH7NSV7FYXWA54NVOUGMFOINLY5OFTWK5AMR6IDBBEU3LWQ2HL3QC
main
finchie added a change on August 17, 2023
Remove dependency on `num_cpus` created on July 12, 2023
DDJO7X2P2BAJSXPOE6ODKAJM7GRWKPT36WWTUZ373ZWQRYU4CFIAC
main
finchie added a change on August 17, 2023
Remove dependency on `once_cell` created on July 12, 2023
BV4PLHOVPSA5UKF43TL6EC57I7XHYWKZWV6LXI7YTGS2K3SQMY2AC
main
finchie added a change on August 17, 2023
Remove unused dependencies created on July 12, 2023
RZ75BZCIWI2LYV5ZHTHV5ZPAQ25D537PNGPOQM7MW6CU77KROB7QC
main
finchie added a change on August 17, 2023
DVBSW7SICQMTYIC4NOLA3CBRU5OWPAWX3MYEOZ7UWXF3IJLLJDYQC
main
finchie added a change on August 17, 2023
Bump flake.nix & flake.lock created on July 13, 2023
2RUJ4J7MBRP3N3FRDPS4CSSAXK6T6UWZAMS7RRDQSRNATERMPY4QC
main
finchie added a change on August 17, 2023
Bump edition to 2021 created on July 13, 2023
JMOHVR5EL27IRLXO66W52DA4K33L467O5J5DRX2ARZTFM6JRHDVQC
main
finchie added a change on August 17, 2023
Create `pijul-interaction` crate created on July 13, 2023
ABPFWGKH24JK7TLAGDVENTA5VSVRANPBVRD555WCQMNW56BL7SZQC
main
finchie added a change on August 17, 2023
JUYSZJSHULJFR4HUJF72TEKKFMBPG4ZOGAGOJ2BX6P3D4DRZAU5QC
main
finchie added a change on August 17, 2023
7UU3TV5W23QA7LLRBSBXEYPRMIVXPW4FNENEEE7ZEJYXDLXHVX4AC
main
finchie added a change on August 17, 2023
Automatically format `pijul` crate created on July 13, 2023
Y6TBQN7MFWX4SKJM2UGDGR4UMMDEO4TPNNJZKZWHEBTW7MPX4WWQC
main
finchie added a change on August 17, 2023
4RV7T4SRYIQLBW3EZFWBO5G65QAVG2GHPI4KMDDZERCX65KQWSPQC
main
finchie added a change on August 17, 2023
GYGLQPVXZHCXO62KMR62GBKBGB5EXIC2GYPM53LJFXRKPGBJAARQC
main
finchie added a change on August 17, 2023
Create `pijul-repository` crate created on July 14, 2023
WCA7X6W633OI72GFB4QPQKAF3POVTBB5HO2NRSVBJRO5BUJL2ORQC
main
finchie added a change on August 17, 2023
ABQDWHNGSBF2REQDCGXSBFAU4RUMXYAF2KHJ5O3D32M7Z3A3FEDAC
main
finchie added a change on August 17, 2023
Y2Y4OOIECVVLL5KIUVHIWJTGPADACCZZHUFGHTLSWHXS5UJ5FD4QC
main
finchie added a change on August 17, 2023
JTELS6L36GEOOST2SUNCJIK5TBJDNLQWCF4IRF7QSHMMVCXSSESAC
main
finchie added a change on August 17, 2023
DGHQ46S3S2RQ27CXF4OES5GDXUI63VTSYYQFLXHG7PRKSVWB3SZAC
main
finchie added a change on August 17, 2023
G7HJHNFDZCGOPGVETNYK7BDDPJXHEIPGZJEJXBGBXSWPWEX3BIQQC
main
finchie added a change on August 17, 2023
XX6GKS5DCDFNIEEAPY2ACYYIWMHA4BGHYUQYQIZBR6IV2OYGNDIAC
main
finchie added a change on August 17, 2023
32G3GOK752NTSULBH6KYGD3ZC2YC4B2X7O73G7BT3AJVMIUIFHXQC
main
finchie added a change on August 17, 2023
O2U2JAFVBHJYU4IDC7S5L4TCLE326CYWYF2OPHKTAMDTKPLISUNQC
main
finchie added a change on August 17, 2023
5Z2Y7VGVHJ7A6UPSEAPFVMIB5J7YHSI6WWHUUUYVLDJ56XSNCXKQC
main
finchie added a change on August 17, 2023
5RSZPNQRUWZFLQIV64CAP4D47BHY4UCBY2R57NB2VCZ5VZF5SBGQC
main
finchie added a change on August 17, 2023
WTPFQPO5C3OWNOEIZQSIMAR7O6URYJJNUJSWDZUTWFDDAMNFMTLQC
main
finchie added a change on August 17, 2023
SU3JX6SEW6MLREX6CCM4V3353YC3IQD4JOZW2KEIHYTHOI2AJKPQC
main
finchie added a change on August 17, 2023
EVDH2ECTA45JYYLA2UKTDSXCUJYMPT6R3IBKX7LIXW252BELCUAAC
main
finchie added a change on August 17, 2023
OYN2YVPAN6L3X6HZXJI6B2GYGL2W5AXRK6CVDJRWALS5OENNB5UAC
main
finchie added a change on August 17, 2023
3OPNBBAUOQ4AAENJ7YI7TCAQ5ZUVNMDPD2AN2KTL3KTOW5A2V6BAC
main
finchie on December 12, 2023

I’ve updated the title once again, from “[DRAFT]: Improve compile times” to “Split Pijul CLI into multiple sub-crates”. Not much has changed from the user’s perspective but should make things a bit cleaner under the hood. I am not aware of any regressions introduced but there probably are some, please ping me on Zulip if there’s anything I can fix!

pmeunier on February 7, 2024

I finally found the time to apply these, sorry for the delay. One minor issue: I like how the time of pijul pull for example is shown, however they wrap to the next line on my terminal, is this intended?

pmeunier closed this discussion on February 8, 2024
pmeunier reopened this discussion on February 8, 2024