Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/install/PackageManager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,24 @@ pub struct PackageManager {
pub global_dir: Option<bun_sys::Dir>,
pub(crate) global_link_dir_path: Box<[u8]>,

/// Names of packages registered via `bun link`, read from
/// `<globalLinkDir>/` once per install. Populated on the main thread
/// before any install worker starts; after that it's read-only and can
/// be accessed lock-free from worker threads. Lookups return early
/// when the set is empty (no active links) — the common case on dev
/// machines without `bun link` configured, and unconditional on CI.
/// See `populate_linked_names_cache` / `linked_package_path`.
Comment thread
robobun marked this conversation as resolved.
pub linked_names: bun_collections::StringHashMap<()>,
pub linked_names_populated: bool,
/// Windows-only fast-path companion to `linked_names`: on Windows the
/// readdir entry is WTF-16 so we can't key it into the UTF-8 hashmap,
/// but we *can* record whether the global link dir is nonempty during
/// the same readdir pass. `linked_package_path` consults this to skip
/// the per-call `GetFileAttributesW` when no links exist — restoring
/// the "zero syscalls when no packages are linked" guarantee that the
/// POSIX fast path in `linked_names` provides.
Comment thread
robobun marked this conversation as resolved.
pub linked_names_any_on_windows: bool,

pub(crate) on_wake: WakeHandler,

pub(crate) peer_dependencies: LinearFifo<DependencyID, DynamicBuffer<DependencyID>>,
Expand Down Expand Up @@ -2102,6 +2120,12 @@ pub fn init(
wr!(global_link_dir, None);
wr!(global_dir, None);
wr!(global_link_dir_path, Box::default());
wr!(
linked_names,
bun_collections::StringHashMap::<()>::default()
);
wr!(linked_names_populated, false);
wr!(linked_names_any_on_windows, false);
wr!(on_wake, WakeHandler::default());
wr!(
peer_dependencies,
Expand Down Expand Up @@ -2546,6 +2570,12 @@ fn init_with_runtime_once(
wr!(global_link_dir, None);
wr!(global_dir, None);
wr!(global_link_dir_path, Box::default());
wr!(
linked_names,
bun_collections::StringHashMap::<()>::default()
);
wr!(linked_names_populated, false);
wr!(linked_names_any_on_windows, false);
wr!(on_wake, WakeHandler::default());
wr!(
peer_dependencies,
Expand Down
Loading
Loading