Skip to content

Remove AsRef generics to reduce compilation time & binary size#336

Open
malcolmgreaves wants to merge 2 commits intomainfrom
mg/reduce_compile_times_binary_size_no_as_ref
Open

Remove AsRef generics to reduce compilation time & binary size#336
malcolmgreaves wants to merge 2 commits intomainfrom
mg/reduce_compile_times_binary_size_no_as_ref

Conversation

@malcolmgreaves
Copy link
Copy Markdown
Collaborator

Replaces all generic AsRef<X> uses with &X direct references.

Includes all instances of a generic parameter of the form Y: AsRef<X> and
impl AsRef<X>. Notably, this included many AsRef<str> and AsRef<Path>,
which are now replaced with &str and &Path, respectively.

This cuts down on compilation time and binary size considerably. Since
Rust monomorphizes generics: it must compile new variants of each function
for every different concrete type use. Unlike other traits, the codebase's
use of AsRef doesn't provide much utility as we nearly never swap-out
different things that could be turned into the reference type. The code is
not only smaller and faster to compile, it is clearer in what, exactly,
it requires and what it exactly operates on.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 13, 2026

Important

Review skipped

Too many files!

This PR contains 251 files, which is 101 over the limit of 150.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fd183f53-21ce-4a2c-ac67-f8d86d3897d3

📥 Commits

Reviewing files that changed from the base of the PR and between 37cedf0 and f75ef0f.

📒 Files selected for processing (251)
  • crates/cli/src/cmd/branch.rs
  • crates/cli/src/cmd/checkout.rs
  • crates/cli/src/cmd/clone.rs
  • crates/cli/src/cmd/commit.rs
  • crates/cli/src/cmd/db/count.rs
  • crates/cli/src/cmd/db/get.rs
  • crates/cli/src/cmd/db/list.rs
  • crates/cli/src/cmd/delete_remote.rs
  • crates/cli/src/cmd/df.rs
  • crates/cli/src/cmd/diff.rs
  • crates/cli/src/cmd/download.rs
  • crates/cli/src/cmd/embeddings/index.rs
  • crates/cli/src/cmd/embeddings/query.rs
  • crates/cli/src/cmd/fetch.rs
  • crates/cli/src/cmd/init.rs
  • crates/cli/src/cmd/log.rs
  • crates/cli/src/cmd/ls.rs
  • crates/cli/src/cmd/migrate.rs
  • crates/cli/src/cmd/pull.rs
  • crates/cli/src/cmd/push.rs
  • crates/cli/src/cmd/remote_mode/status.rs
  • crates/cli/src/cmd/schemas.rs
  • crates/cli/src/cmd/schemas/add.rs
  • crates/cli/src/cmd/schemas/rm.rs
  • crates/cli/src/cmd/schemas/show.rs
  • crates/cli/src/cmd/tree.rs
  • crates/cli/src/cmd/upload.rs
  • crates/cli/src/cmd/workspace/clear.rs
  • crates/cli/src/cmd/workspace/delete.rs
  • crates/cli/src/cmd/workspace/df/get.rs
  • crates/cli/src/cmd/workspace/df/index.rs
  • crates/cli/src/cmd/workspace/download.rs
  • crates/cli/src/cmd/workspace/status.rs
  • crates/cli/src/helpers.rs
  • crates/lib/benches/add.rs
  • crates/lib/benches/download.rs
  • crates/lib/benches/fetch.rs
  • crates/lib/benches/push.rs
  • crates/lib/benches/workspace_add.rs
  • crates/lib/src/api/client.rs
  • crates/lib/src/api/client/branches.rs
  • crates/lib/src/api/client/commits.rs
  • crates/lib/src/api/client/compare.rs
  • crates/lib/src/api/client/data_frames.rs
  • crates/lib/src/api/client/diff.rs
  • crates/lib/src/api/client/dir.rs
  • crates/lib/src/api/client/entries.rs
  • crates/lib/src/api/client/export.rs
  • crates/lib/src/api/client/file.rs
  • crates/lib/src/api/client/import.rs
  • crates/lib/src/api/client/metadata.rs
  • crates/lib/src/api/client/prune.rs
  • crates/lib/src/api/client/repositories.rs
  • crates/lib/src/api/client/revisions.rs
  • crates/lib/src/api/client/schemas.rs
  • crates/lib/src/api/client/stats.rs
  • crates/lib/src/api/client/tree.rs
  • crates/lib/src/api/client/versions.rs
  • crates/lib/src/api/client/workspaces.rs
  • crates/lib/src/api/client/workspaces/changes.rs
  • crates/lib/src/api/client/workspaces/commits.rs
  • crates/lib/src/api/client/workspaces/data_frames.rs
  • crates/lib/src/api/client/workspaces/data_frames/columns.rs
  • crates/lib/src/api/client/workspaces/data_frames/embeddings.rs
  • crates/lib/src/api/client/workspaces/data_frames/rows.rs
  • crates/lib/src/api/client/workspaces/files.rs
  • crates/lib/src/api/endpoint.rs
  • crates/lib/src/command/db.rs
  • crates/lib/src/command/df.rs
  • crates/lib/src/command/migrate/m20250111083535_add_child_counts_to_nodes.rs
  • crates/lib/src/config/auth_config.rs
  • crates/lib/src/config/repository_config.rs
  • crates/lib/src/config/user_config.rs
  • crates/lib/src/core/commit_sync_status.rs
  • crates/lib/src/core/db/data_frames/columns.rs
  • crates/lib/src/core/db/data_frames/df_db.rs
  • crates/lib/src/core/db/data_frames/rows.rs
  • crates/lib/src/core/db/data_frames/workspace_df_db.rs
  • crates/lib/src/core/db/dir_hashes/dir_hashes_db.rs
  • crates/lib/src/core/db/key_val/index_db.rs
  • crates/lib/src/core/db/key_val/kv_db.rs
  • crates/lib/src/core/db/key_val/path_db.rs
  • crates/lib/src/core/db/key_val/str_json_db.rs
  • crates/lib/src/core/db/key_val/str_val_db.rs
  • crates/lib/src/core/db/key_val/u128_kv_db.rs
  • crates/lib/src/core/db/merkle_node/merkle_node_db.rs
  • crates/lib/src/core/df/filter.rs
  • crates/lib/src/core/df/sql.rs
  • crates/lib/src/core/df/tabular.rs
  • crates/lib/src/core/index/schema_reader/duckdb_schema_reader.rs
  • crates/lib/src/core/index/schema_reader/objects_schema_reader.rs
  • crates/lib/src/core/merge/entry_merge_conflict_db_reader.rs
  • crates/lib/src/core/merge/entry_merge_conflict_reader.rs
  • crates/lib/src/core/merge/entry_merge_conflict_writer.rs
  • crates/lib/src/core/merge/node_merge_conflict_db_reader.rs
  • crates/lib/src/core/merge/node_merge_conflict_reader.rs
  • crates/lib/src/core/merge/node_merge_conflict_writer.rs
  • crates/lib/src/core/node_sync_status.rs
  • crates/lib/src/core/refs/ref_manager.rs
  • crates/lib/src/core/staged/staged_db_manager.rs
  • crates/lib/src/core/v_latest/add.rs
  • crates/lib/src/core/v_latest/branches.rs
  • crates/lib/src/core/v_latest/clone.rs
  • crates/lib/src/core/v_latest/commits.rs
  • crates/lib/src/core/v_latest/data_frames.rs
  • crates/lib/src/core/v_latest/data_frames/schemas.rs
  • crates/lib/src/core/v_latest/diff.rs
  • crates/lib/src/core/v_latest/download.rs
  • crates/lib/src/core/v_latest/entries.rs
  • crates/lib/src/core/v_latest/fetch.rs
  • crates/lib/src/core/v_latest/index/commit_merkle_tree.rs
  • crates/lib/src/core/v_latest/index/restore.rs
  • crates/lib/src/core/v_latest/init.rs
  • crates/lib/src/core/v_latest/merge.rs
  • crates/lib/src/core/v_latest/metadata.rs
  • crates/lib/src/core/v_latest/pull.rs
  • crates/lib/src/core/v_latest/push.rs
  • crates/lib/src/core/v_latest/revisions.rs
  • crates/lib/src/core/v_latest/rm.rs
  • crates/lib/src/core/v_latest/status.rs
  • crates/lib/src/core/v_latest/workspaces.rs
  • crates/lib/src/core/v_latest/workspaces/commit.rs
  • crates/lib/src/core/v_latest/workspaces/data_frames.rs
  • crates/lib/src/core/v_latest/workspaces/data_frames/columns.rs
  • crates/lib/src/core/v_latest/workspaces/data_frames/rows.rs
  • crates/lib/src/core/v_latest/workspaces/data_frames/schemas.rs
  • crates/lib/src/core/v_latest/workspaces/diff.rs
  • crates/lib/src/core/v_latest/workspaces/files.rs
  • crates/lib/src/core/v_latest/workspaces/status.rs
  • crates/lib/src/core/v_old/v0_19_0/entries.rs
  • crates/lib/src/core/v_old/v0_19_0/index/commit_merkle_tree.rs
  • crates/lib/src/core/versions.rs
  • crates/lib/src/error.rs
  • crates/lib/src/model/content_type.rs
  • crates/lib/src/model/data_frame/schema.rs
  • crates/lib/src/model/data_frame/schema/custom_data_type.rs
  • crates/lib/src/model/data_frame/schema/data_type.rs
  • crates/lib/src/model/data_frame/schema/field.rs
  • crates/lib/src/model/diff/diff_entry.rs
  • crates/lib/src/model/diff/tabular_diff_summary.rs
  • crates/lib/src/model/entry/commit_entry.rs
  • crates/lib/src/model/file.rs
  • crates/lib/src/model/merkle_tree/node/dir_node.rs
  • crates/lib/src/model/merkle_tree/node/file_chunk_node.rs
  • crates/lib/src/model/merkle_tree/node/merkle_tree_node.rs
  • crates/lib/src/model/merkle_tree/node/merkle_tree_node_cache.rs
  • crates/lib/src/model/repository/local_repository.rs
  • crates/lib/src/model/repository/repo_new.rs
  • crates/lib/src/model/staged_dir_stats.rs
  • crates/lib/src/model/workspace.rs
  • crates/lib/src/opts/clone_opts.rs
  • crates/lib/src/opts/fetch_opts.rs
  • crates/lib/src/opts/restore_opts.rs
  • crates/lib/src/opts/rm_opts.rs
  • crates/lib/src/opts/storage_opts.rs
  • crates/lib/src/repositories.rs
  • crates/lib/src/repositories/add.rs
  • crates/lib/src/repositories/branches.rs
  • crates/lib/src/repositories/checkout.rs
  • crates/lib/src/repositories/clone.rs
  • crates/lib/src/repositories/commits.rs
  • crates/lib/src/repositories/commits/commit_writer.rs
  • crates/lib/src/repositories/data_frames.rs
  • crates/lib/src/repositories/data_frames/schemas.rs
  • crates/lib/src/repositories/diffs.rs
  • crates/lib/src/repositories/diffs/join_diff.rs
  • crates/lib/src/repositories/download.rs
  • crates/lib/src/repositories/entries.rs
  • crates/lib/src/repositories/fetch.rs
  • crates/lib/src/repositories/fork.rs
  • crates/lib/src/repositories/init.rs
  • crates/lib/src/repositories/load.rs
  • crates/lib/src/repositories/merge.rs
  • crates/lib/src/repositories/metadata.rs
  • crates/lib/src/repositories/metadata/audio.rs
  • crates/lib/src/repositories/metadata/image.rs
  • crates/lib/src/repositories/metadata/tabular.rs
  • crates/lib/src/repositories/metadata/text.rs
  • crates/lib/src/repositories/metadata/video.rs
  • crates/lib/src/repositories/pull.rs
  • crates/lib/src/repositories/push.rs
  • crates/lib/src/repositories/remote_mode.rs
  • crates/lib/src/repositories/remote_mode/add.rs
  • crates/lib/src/repositories/remote_mode/checkout.rs
  • crates/lib/src/repositories/remote_mode/commit.rs
  • crates/lib/src/repositories/remote_mode/restore.rs
  • crates/lib/src/repositories/remote_mode/rm.rs
  • crates/lib/src/repositories/remote_mode/status.rs
  • crates/lib/src/repositories/restore.rs
  • crates/lib/src/repositories/revisions.rs
  • crates/lib/src/repositories/rm.rs
  • crates/lib/src/repositories/size.rs
  • crates/lib/src/repositories/status.rs
  • crates/lib/src/repositories/tree.rs
  • crates/lib/src/repositories/workspaces.rs
  • crates/lib/src/repositories/workspaces/data_frames.rs
  • crates/lib/src/repositories/workspaces/data_frames/columns.rs
  • crates/lib/src/repositories/workspaces/data_frames/embeddings.rs
  • crates/lib/src/repositories/workspaces/data_frames/rows.rs
  • crates/lib/src/repositories/workspaces/data_frames/schemas.rs
  • crates/lib/src/repositories/workspaces/df.rs
  • crates/lib/src/repositories/workspaces/diff.rs
  • crates/lib/src/repositories/workspaces/files.rs
  • crates/lib/src/repositories/workspaces/status.rs
  • crates/lib/src/repositories/workspaces/upload.rs
  • crates/lib/src/resource.rs
  • crates/lib/src/storage/local.rs
  • crates/lib/src/storage/s3.rs
  • crates/lib/src/storage/version_store.rs
  • crates/lib/src/test.rs
  • crates/lib/src/util/fs.rs
  • crates/lib/src/util/glob.rs
  • crates/lib/src/util/hasher.rs
  • crates/lib/src/util/image.rs
  • crates/lib/src/util/oxen_version.rs
  • crates/lib/src/util/progress_bar.rs
  • crates/lib/src/view/sql_parse_error.rs
  • crates/lib/src/view/status_message.rs
  • crates/oxen-py/src/py_remote_data_frame.rs
  • crates/oxen-py/src/py_remote_repo.rs
  • crates/oxen-py/src/py_repo.rs
  • crates/oxen-py/src/py_workspace_data_frame.rs
  • crates/oxen-py/src/remote.rs
  • crates/server/src/auth/access_keys.rs
  • crates/server/src/controllers/branches.rs
  • crates/server/src/controllers/commits.rs
  • crates/server/src/controllers/data_frames.rs
  • crates/server/src/controllers/diff.rs
  • crates/server/src/controllers/dir.rs
  • crates/server/src/controllers/entries.rs
  • crates/server/src/controllers/import.rs
  • crates/server/src/controllers/merger.rs
  • crates/server/src/controllers/metadata.rs
  • crates/server/src/controllers/repositories.rs
  • crates/server/src/controllers/revisions.rs
  • crates/server/src/controllers/schemas.rs
  • crates/server/src/controllers/tree.rs
  • crates/server/src/controllers/versions.rs
  • crates/server/src/controllers/versions/chunks.rs
  • crates/server/src/controllers/workspaces.rs
  • crates/server/src/controllers/workspaces/changes.rs
  • crates/server/src/controllers/workspaces/data_frames.rs
  • crates/server/src/controllers/workspaces/data_frames/columns.rs
  • crates/server/src/controllers/workspaces/data_frames/embeddings.rs
  • crates/server/src/controllers/workspaces/data_frames/rows.rs
  • crates/server/src/controllers/workspaces/files.rs
  • crates/server/src/errors.rs
  • crates/server/src/helpers.rs
  • crates/server/src/params.rs
  • deleteme
  • log_compile_times

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mg/reduce_compile_times_binary_size_no_as_ref

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@malcolmgreaves malcolmgreaves marked this pull request as draft March 13, 2026 09:46
@malcolmgreaves malcolmgreaves marked this pull request as ready for review March 13, 2026 09:48
@malcolmgreaves malcolmgreaves force-pushed the mg/reduce_compile_times_binary_size_no_as_ref branch from c816ff3 to 3d69698 Compare March 13, 2026 12:02
@malcolmgreaves malcolmgreaves force-pushed the mg/reduce_compile_times_binary_size_no_as_ref branch 2 times, most recently from a573668 to b30f14e Compare March 28, 2026 00:18
Replaces all generic `AsRef<X>` uses with `&X` direct references.

Includes all instances of a generic parameter of the form `Y: AsRef<X>` and
`impl AsRef<X>`. Notably, this included many `AsRef<str>` and `AsRef<Path>`,
which are now replaced with `&str` and `&Path`, respectively.

This cuts down on compilation time and binary size considerably. Since
Rust monomorphizes generics: it must compile new variants of each function
for every different concrete type use. Unlike other traits, the codebase's
use of `AsRef` doesn't provide much utility as we nearly never swap-out
different things that could be turned into the reference type. The code is
not only smaller and faster to compile, it is clearer in what, exactly,
it requires and what it exactly operates on.
@malcolmgreaves malcolmgreaves force-pushed the mg/reduce_compile_times_binary_size_no_as_ref branch from b30f14e to f75ef0f Compare March 28, 2026 00:22
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