Repository navigation
Conversation
Collaborator
Author
|
Status: draft, waiting for #42819 to land first. How to reproduce on main:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Behaviour change: none
Problem
bun_runtimeexports nothing, but 271 of its items are barepub.unreachable_pubreports none, anddead_codeskips what they reach.pubtype as exported when an impl of a foreign trait for a foreign type names it.strum::IntoStaticStremits one:impl From<T> for &'static str.body::Tag(src/runtime/webcore/Body.rs:588) and hides 172 items.Fix
#![deny(unnameable_types)]tosrc/runtime/lib.rs. It reports each such type: 97 on main, 0 here.pubitem topub(crate). Deletebody::Tagand theEnumTagderive onbody::Value.#[cfg]when one platform uses it. The Notes name each item.bun run rust:check-all, 12 of 12 targets. The Notes list the other checks and the tests.Background
unreachable_pubreports apubitem no other crate can reach.dead_codeskips an item that rustc counts as exported.pub(crate)type is never exported.body::Tagchain (55 of 97 types stay exported), or a source-lint test (an extra CI pass).Downsides
pubtype that an impl exports is now a hard error with no automatic fix.#[cfg]lines gate 9 enum variants and 2 enums to one platform.pubwritten inside another crate's macro, and the other workspace crates.Notes
Order. #42819 (Remove libuv on Windows) deletes
Writable::Pipe,SourceHandle::ShellWritableandMultiPartUpload.global_this. This PR must land after it. It stays a draft until then. After the rebase, the#[cfg(windows)]gates for those items go away. Related: #36895 constructsWritable::Pipeon POSIX again, #42266 is a dead-code sweep in the same files.Deleted (nothing reads them on any target).
webcore::body::Tag, andValue::tag()with the derive that emits it (0 callers).streams::IntoArray.valueand its 11 initializers inByteStream.rs,FileReader.rs,ByteBlobLoader.rs.MultiPartUpload.global_thisand its 2 initializers ins3/client.rs.shell::subproc::Writable::Fd(now a unit variant, likeReadable::Fd).shell::subproc::WritableInitError.Writable::initreturnsWritable.AsyncState::Done(shell/states/Async.rs).Error::eol,Error::fmt,Error::InvalidCharacterand theirname()arms. Onlycpus_impl_linuxbuilt them, andFrom<crate::Error> for OsErrordropped the variant. The helpers returnOsError::Anydirectly, and thatFromimpl is deleted with them.Gated (one platform uses them).
#[cfg(windows)]:Writable::PipewithWritable::on_close, the stdin wiring block, thefinalizearm and theFileSinkimport.SourceHandle::ShellWritablewith its 4 match arms.Error::FailedToInitPipe,Error::FailedToBindPipe.cron::TaskXmlError.#[cfg(target_os = "macos")]:Error::FailedToCreateCoreFoudationSourceLoop,Error::FailedToSpawnFSEventsThread,cron::CalendarError.#[cfg(not(windows))]:Error::WatchFailed,CreatePtyError::NotSupported,InitError::NotSupportedand their arms.Narrowed by hand (no rustc lint reports these). 34
pubtokens insidebitflags!,opaque_ffi!,jsc_host_abi!,jsc_promise_handler!,multi_array_columns!andimpl_field_parent!invocations, 2object_pool!aliases, and 4 items in theshell_builtins!macro body. The#[no_mangle]host functions among them keep their symbols: 11 host functions in this crate are already private.Executed code that changes, and why the result is the same.
ByteStream::on_data: twolet v = self.value();becomeself.pending_value.with_mut(|pv| pv.clear_without_deallocation()).value()did that clear as a side effect, and nothing readvafter it was stored.Writable::init:Writable::Fd(result.unwrap())becomesWritable::Fd. Theunwrap()cannot fail:Stdio::Fd(fd)maps toPosixStdio::Pipe(fd), andspawn_processalways sets the spawned stdin for it.Writable::init: whenstart_with_current_pipe()fails, the samepanic!("unexpected error while creating stdin")now runs ininit. Before,initreturned the one-variant error and its only caller panicked with that message.Not changed.
EnumTagderive still emitsimpl From<&Data> for Tag. It has 0 callers in the workspace. Once this crate is capped it hides nothing, so it is a separate cleanup.#[enum_tag(existing = ..)]sites. Each has real.tag()callers.strum::IntoStaticStrenums in the other crates. Many are real exports. The attribute is not in[workspace.lints]for that reason.Measurements.
--all-targets, clippy, and thebun_asan+bun_debug+socket_fault_injectionandbun_codegen_embedcfg sets (0 triples skipped).unnameable_typesreports inbun_runtime(linux x64 / windows x64 / darwin arm64): 97 / 98 / 98 on main, 0 / 0 / 0 here.pubitem declarations insrc/runtime: 271 lines + 2object_pool!aliases on main, 0 + 0 here.#[derive(strum::IntoStaticStr)] pub enumgives 1unnameable_typeserror and 0 others. Aspub(crate)it gives 0 and 1dead_code.#[cfg]lines under 3 predicates (15windows, 7not(windows), 5target_os = "macos").llvm-size): file 80,873,032 -> 80,868,936 bytes (-4,096),.text58,187,957 -> 58,185,141 bytes (-2,816), every other section equal. Debug binary:body::Tagsymbols 2 -> 0 (535 B -> 0 B).bun_runtimerlib global symbols: 12,417 -> 12,292. C-ABI (unmangled) names in the rlib: 2,513 -> 2,513, same list.-Zprint-type-sizes):IntoArray16 -> 8 bytes,MultiPartUpload344 -> 336 bytes,streams::Result48 -> 48 bytes.ByteStream::on_data3,420 -> 3,272 B,FileReader::on_read_chunk2,264 -> 2,127 B. CPU time of a fixed stream-read script, 15 interleaved runs: -0.75% median against an A/A spread of +0.71%.bun_runtimeunit with and without the attribute, 8 paired non-incremental runs: +1.4% median, inside the same-variant spread of 5.0%.perf,valgrindandbloaty. So there are no instruction counts, and sizes come fromllvm-sizeandllvm-nm.Tests (debug + ASAN build, linux x64).
test/js/web/streams/streams.test.js,test/js/web/fetch/body-stream.test.ts,body.test.ts,fetch.test.ts,test/js/bun/spawn/spawn.test.ts,test/js/bun/shell/bunshell.test.ts,file-io.test.ts,test/js/bun/s3/,test/js/bun/terminal/,test/js/bun/cron/,test/js/node/os/os.test.js,test/js/workerd/html-rewriter.test.js,test/js/bun/http/serve.test.ts,test/internal/source-lints/. Each failure also fails with a build of the merge-base on the same machine (5 s timeouts under load, root user, no IPv6).