Skip to content

Replace Base with Stdlib and custom shims - #1655

Open
WardBrian wants to merge 12 commits into
stan-dev:masterfrom
WardBrian:drop-base
Open

Replace Base with Stdlib and custom shims#1655
WardBrian wants to merge 12 commits into
stan-dev:masterfrom
WardBrian:drop-base

Conversation

@WardBrian

@WardBrian WardBrian commented Aug 4, 2026

Copy link
Copy Markdown
Member

This PR is unfortunately quite large, but many of the changes are simple renames. Review should focus on the src/std/ folder and the few places where any non-trivial edits were made.


This is the ultimate conclusion of the patch sequence #1643 #1644 #1650 #1652.

After updating to 5.5, Base was providing us (up to renaming) essentially just:

  • Polymorphic sets
  • Hash sets
  • A few small quality of life functions

These are all easy to provide ourselves, which means we can remove the dependency entirely.

The binaries produced with dune build --profile release from this branch are 12mb, down from 15mb on master. Shockingly, they're also the same speed if not faster (especially when running optimizations):

Summary
  ./stanc-nobase ./test/integration/good/code-gen/mother.stan ran
    1.03 ± 0.07 times faster than ./stanc-master ./test/integration/good/code-gen/mother.stan
Summary
  ./stanc-nobase --O1 ./test/integration/good/compiler-optimizations/copy_fail.stan ran
    1.56 ± 0.10 times faster than ./stanc-master --O1 ./test/integration/good/compiler-optimizations/copy_fail.stan
Summary
  ./stanc-nobase --Oexperimental ./test/integration/good/compiler-optimizations/copy_fail.stan ran
    2.03 ± 0.16 times faster than ./stanc-master --Oexperimental ./test/integration/good/compiler-optimizations/copy_fail.stan

Javascript builds are down to 16mb from 19mb, with minified sizes roughly the same.

Submission Checklist

  • Run unit tests
  • Documentation
    • If a user-facing facing change was made, the documentation PR is here:
    • OR, no user-facing changes were made

Release notes

Decreased our reliance on third-party packages

Copyright and Licensing

By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.00426% with 75 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.28%. Comparing base (ac69570) to head (29e783f).

Files with missing lines Patch % Lines
src/analysis_and_optimization/Factor_graph.ml 78.26% 10 Missing ⚠️
src/std/std.ml 90.56% 10 Missing ⚠️
src/frontend/Typechecker.ml 91.02% 7 Missing ⚠️
src/std/Hash_set.ml 44.44% 5 Missing ⚠️
...analysis_and_optimization/Debug_data_generation.ml 86.20% 4 Missing ⚠️
src/analysis_and_optimization/Memory_patterns.ml 90.90% 4 Missing ⚠️
src/analysis_and_optimization/Mir_utils.ml 81.81% 4 Missing ⚠️
src/frontend/Ast_to_Mir.ml 85.18% 4 Missing ⚠️
...rc/analysis_and_optimization/Monotone_framework.ml 97.58% 3 Missing ⚠️
src/analysis_and_optimization/Optimize.ml 94.82% 3 Missing ⚠️
... and 15 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1655      +/-   ##
==========================================
- Coverage   92.33%   92.28%   -0.06%     
==========================================
  Files          67       69       +2     
  Lines        9953    10105     +152     
==========================================
+ Hits         9190     9325     +135     
- Misses        763      780      +17     
Files with missing lines Coverage Δ
src/analysis_and_optimization/Dataflow_types.ml 25.00% <100.00%> (+25.00%) ⬆️
src/analysis_and_optimization/Dataflow_utils.ml 100.00% <100.00%> (ø)
...c/analysis_and_optimization/Dependence_analysis.ml 100.00% <100.00%> (ø)
...nalysis_and_optimization/Pedantic_dist_warnings.ml 91.70% <100.00%> (ø)
src/common/Files.ml 100.00% <ø> (ø)
src/driver/Entry.ml 96.15% <100.00%> (-0.05%) ⬇️
src/driver/Flags.ml 100.00% <ø> (ø)
src/frontend/Canonicalize.ml 96.36% <100.00%> (ø)
src/frontend/Environment.ml 89.18% <100.00%> (+0.30%) ⬆️
src/frontend/Input_warnings.ml 100.00% <ø> (ø)
... and 52 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@WardBrian
WardBrian marked this pull request as ready for review August 6, 2026 16:08
@WardBrian

Copy link
Copy Markdown
Member Author

This PR is unfortunately quite large -- if it would be easier to review module-by-module I can try out the new stacked PRs feature, but there's also no real benefit to the project until the last commit actually removing Base from the linking set is in.

Luckily almost all the changes are trivial, things like List.fold being renamed to List.fold_left, so it can also be reviewed piece by piece without keeping the whole thing in short term memory.

Let me know whichever would make your lives easier @nhuurre @SteveBronder

@WardBrian
WardBrian requested review from SteveBronder and nhuurre and removed request for nhuurre August 6, 2026 16:11
@WardBrian
WardBrian force-pushed the drop-base branch 2 times, most recently from 53b59a6 to 29e783f Compare August 6, 2026 21:57
@WardBrian

Copy link
Copy Markdown
Member Author

Ok, I don't intend to do any more history-rewriting on this branch pre-review at this point

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.

1 participant