340 Commits

Author SHA1 Message Date
Jarred Sumner
da298635ef Bump 2023-07-20 21:22:49 -07:00
Jarred Sumner
1c6e464a68 bump 2023-07-20 21:08:42 -07:00
Jarred Sumner
0b365781a8 Bump version to Bun v0.7.0 2023-07-19 23:57:41 -07:00
dave caruso
9b6dc49575 Implement AsyncLocalStorage (#3089)
* work to get async local storage working.

* a

* a

* everything but queueMicrotask

* sdfghj

* .

* finish

* tests

* test

* ok

* done

* im so stupid

* Upgrade WebKit

* refactor

* refactor

* changes requested

* oops

* cool

* fix runInAsyncScope
2023-07-19 17:20:00 -07:00
Dylan Conway
661355546a zig upgrade (#3667)
* upgrade

* more fixes

* Bump Zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-18 01:20:20 -07:00
Jarred Sumner
36a25c3580 Fix memory leak in await new Response(latin1String).arrayBuffer() and await Response.json(obj).json() (#3656)
❯ mem bun --smol response-arrayBuffer.mjs
cpu: Apple M1 Max
runtime: bun 0.6.15 (arm64-darwin)

benchmark                                                        time (avg)             (min … max)       p75       p99      p995
--------------------------------------------------------------------------------------------------- -----------------------------
new Response().arrayBuffer() (new string each call, latin1)    12.9 µs/iter      (625 ns … 4.18 ms)      1 µs 567.17 µs 711.79 µs
new Response().arrayBuffer() (new string each call, utf16)    12.85 µs/iter     (1.67 µs … 1.56 ms)   2.17 µs 462.75 µs 621.13 µs
new Response().arrayBuffer() (existing string, latin1)         6.53 µs/iter     (6.21 µs … 7.07 µs)   6.64 µs   7.07 µs   7.07 µs

Peak memory usage: 49 MB

bun on  jarred/memory-leak-fix took 2s
❯ mem bun response-arrayBuffer.mjs
cpu: Apple M1 Max
runtime: bun 0.6.15 (arm64-darwin)

benchmark                                                        time (avg)             (min … max)       p75       p99      p995
--------------------------------------------------------------------------------------------------- -----------------------------
new Response().arrayBuffer() (new string each call, latin1)     1.2 µs/iter     (1.04 µs … 1.42 µs)   1.22 µs   1.42 µs   1.42 µs
new Response().arrayBuffer() (new string each call, utf16)     2.74 µs/iter     (2.42 µs … 6.37 µs)   2.68 µs   6.37 µs   6.37 µs
new Response().arrayBuffer() (existing string, latin1)       746.37 ns/iter   (643.82 ns … 1.04 µs) 776.11 ns   1.04 µs   1.04 µs

Peak memory usage: 104 MB

bun on  jarred/memory-leak-fix took 2s
❯ mem ~/.bun/bin/bun response-arrayBuffer.mjs
cpu: Apple M1 Max
runtime: bun 0.6.15 (arm64-darwin)

benchmark                                                        time (avg)             (min … max)       p75       p99      p995
--------------------------------------------------------------------------------------------------- -----------------------------
new Response().arrayBuffer() (new string each call, latin1)    1.69 µs/iter      (1.56 µs … 2.1 µs)   1.73 µs    2.1 µs    2.1 µs
new Response().arrayBuffer() (new string each call, utf16)     2.65 µs/iter     (2.47 µs … 3.17 µs)   2.69 µs   3.17 µs   3.17 µs
new Response().arrayBuffer() (existing string, latin1)       667.67 ns/iter   (547.67 ns … 1.28 µs) 694.21 ns   1.28 µs   1.28 µs

Peak memory usage: 2735 MB

bun on  jarred/memory-leak-fix took 2s
❯ mem ~/.bun/bin/bun --smol response-arrayBuffer.mjs
cpu: Apple M1 Max
runtime: bun 0.6.15 (arm64-darwin)

benchmark                                                        time (avg)             (min … max)       p75       p99      p995
--------------------------------------------------------------------------------------------------- -----------------------------
new Response().arrayBuffer() (new string each call, latin1)   13.51 µs/iter       (541 ns … 3.2 ms)   1.92 µs 553.42 µs 709.92 µs
new Response().arrayBuffer() (new string each call, utf16)    13.07 µs/iter     (1.71 µs … 3.43 ms)   2.13 µs 451.21 µs 651.67 µs
new Response().arrayBuffer() (existing string, latin1)         6.25 µs/iter     (5.79 µs … 6.81 µs)    6.4 µs   6.81 µs   6.81 µs

Peak memory usage: 292 MB

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-17 04:15:13 -07:00
Jarred Sumner
13b5d9d4de 20% faster deserialize (#3655)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-17 02:22:00 -07:00
Jarred Sumner
5856639833 Add serialize snippet 2023-07-16 23:16:38 -07:00
Jarred Sumner
6a234e6fce Add structuredClone microbenchmark 2023-07-16 21:17:55 -07:00
Jarred Sumner
b566573977 Fix another crash in Error.captureStackTrace (#3611)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-11 21:01:35 -07:00
Jarred Sumner
2f5e4fffe9 Implement process.memoryUsage() and process.cpuUsage() (#3586)
* Implement process.memoryUsage() and process.cpuUsage()

* Avoid mi_process_info

* Update bench

* Update Process.cpp

* fixup

* More tests + linux fixup

* Skip it for now since it seems less accurate

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-09 21:50:19 -07:00
Jarred Sumner
f49a308d2c Create readfile-not-found.mjs 2023-07-04 03:48:10 -07:00
Jarred Sumner
6cae6ebafe Make buffer.toString("base64") 4x faster (#3486)
* Add libbase64

* Add bench

* Update licensing.md

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-01 20:02:50 -07:00
Jarred Sumner
f839cf1ce3 Update crypto.mjs 2023-06-26 19:07:54 -07:00
Silas Rech
16598555f1 .randomInt() support (#3357)
* Add initial .randomInt() fallback

* Add basic .randomInt() test

* Attempt creating a native implementation

* Switch to JSC.wrapWithHasContainer

* Switch to .jsNumberFromUint64(), it seems like using just .jsNumber() causes the number to overflow in some cases

* Regenerate out folder after rebasing
2023-06-26 15:35:48 -07:00
Jarred Sumner
ff63555143 Rewrite Bun's runtime CommonJS loader (#3379)
* wip changes for CommonJS

* this rewrite is almost complete

* even more code

* wip

* Remove usages of `import.meta.require` from builtins

* Remove usages of require

* Regenerate

* ✂️ builtin rewrite commonjs in printer

* Use lazy custom getters for import.meta

* fixups

* Remove depd

* ugh

* still crashing

* fixup undici

* comment out import.meta.require.resolve temporarily

not a real solution but it stops the crashes

* Redo import.meta.primordials

* Builtins now have a `builtin://` protocol in source origin

* Seems to work?

* Finsih getting rid of primordials

* switcharoo

* No more function

* just one more bug

* Update launch.json

* Implement `require.main`

* ✂️

* Bump WebKit

* Fixup import cycles

* Fixup improt cycles

* export more things

* Implement `createCommonJSModule` builtin

* More exports

* regenerate

* i broke some stuff

* some of these tests work now

* We lost the encoding

* Sort of fix zlib

* Sort of fix util

* Update events.js

* bump

* bump

* bump

* Fix missing export in fs

* fix some bugs with builtin esm modules (stream, worker_threads, events). its not perfect yet.

* fix some other internal module bugs

* oops

* fix some extra require default stuff

* uncomment this file but it crsahes on my machine

* tidy code here

* fixup tls exports

* make simdutf happier

* Add hasPrefix binding

* Add test for `require.main`

* Fix CommonJS evaluation order race condition

* Make node:http load faster

* Add missing exports to tls.js

* Use the getter

* Regenerate builtins

* Fix assertion failure in Bun.write()

* revamp dotEnv parser (#3347)

- fixes `strings.indexOfAny()`
- fixes OOB array access

fixes #411
fixes #2823
fixes #3042

* fix tests for `expect()` (#3384)

- extend test job time-out for `darwin-aarch64`

* `expect().resolves` and `expect().rejects` (#3318)

* Move expect and snapshots to their own files

* expect().resolves and expect().rejects

* Fix promise being added to unhandled rejection list

* Handle timeouts in expect(<promise>)

* wip merge

* Fix merge issue

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>

* fixup min/memcopy (#3388)

* Fix crash in builtins

* Don't attempt to evaluate modules with no source code

* Update WebCoreJSBuiltins.cpp

* Update WebCoreJSBuiltins.cpp

* Update WebCoreJSBuiltins.cpp

* Fix crash

* cleanup

* Fix test

cc @paperdave

* Fixup Undici

* Fix issue in node:http

* Create util-deprecate.mjs

* Fix several bugs

* Use the identifier

* Support error.code in `util.deprecate`

* make the CJs loader slightly more resilient

* Update WebCoreJSBuiltins.cpp

* Fix macros

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: Alex Lam S.L <alexlamsl@gmail.com>
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>
2023-06-24 06:02:16 -07:00
Dylan Conway
5fa13625a1 upgrade zig to v0.11.0-dev.3737+9eb008717 (#3374)
* progress

* finish `@memset/@memcpy` update

* Update build.zig

* change `@enumToInt` to `@intFromEnum` and friends

* update zig versions

* it was 1

* add link to issue

* add `compileError` reminder

* fix merge

* format

* upgrade to llvm 16

* Revert "upgrade to llvm 16"

This reverts commit cc930ceb1c.

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-21 23:38:18 -07:00
Jarred Sumner
fdb7940c4e Fix a bunch of bugs (#3352)
* Fix a bunch of bugs

* undo that one

* Fix crash in readdir()

* woops

* woops

* Add comment

* ✂️

* Make `readlink()` and `realpath` use much less memory

* Update BunString.cpp

* woopsie

* Unnecessary

* Don't commit these

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-18 10:47:42 -07:00
Alex Lam S.L
873f615358 minor build diffs (#3349) 2023-06-18 03:45:41 -07:00
Luigi Pinca
68c092aef2 Set the publishToSelf option to true (#3343)
All messages sent by the clients are expected to be received by all
clients. Without the `publishToSelf` option a message is not sent back
to the sender and the benchmark hangs.
2023-06-17 14:05:11 -07:00
Jarred Sumner
dc06caccaa Tweak CommonJS output (#3320)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-15 01:18:23 -07:00
Luigi Pinca
04cd6a82b8 Fix benchmark (#3276) 2023-06-10 11:39:26 -07:00
Jarred Sumner
59d7c47e3f Fix crash with path parse in win32 (#3187)
* Update CommonJSModuleRecord.cpp

* smaller

* [node:path] Fix crash, mark TODO

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-03 00:14:27 -07:00
dave caruso
2c1694f63b Fix streams breaking on reverted EventEmitter / Make Discord.js work (#2913)
* Revert "Revert "use a lazyily initialized stream for `node:crypto` `createHash` (#2652)""

This reverts commit 613bb4822e.

* Revert "Revert "implement `node:events` in javascript (#2604)""

This reverts commit a4d0a1961a.

* oops

* fix entrypoints stuff

* fix hash copy

* use native events for node streams and crypto

* requested changes

* oops

* make discord.js work

* fix webkit hash

* headers tojson
2023-06-01 14:31:36 -07:00
Jarred Sumner
4c01454376 Make uploading files with fetch()fast (#3125)
* Make file uploads fast

* Add benchmark

* Update README.md

* defaults

* print

* prettier

* smaller

* fix(path) fix parse behavior (#3134)

* Add macro docs (#3139)

* Add macro doc

* Updates

* Tweaks

* Update doc

* Update macro serialization doc

* Update macro doc

* `--no-macros` flag, disable macros in node_modules

* invert base/filename internally (#3141)

* always false

* Fix broken test

* Add a test sendfile() test with large file

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-05-31 17:20:30 -07:00
Jarred Sumner
9b28d2009d Add snippet for node:vm 2023-05-19 12:12:13 -07:00
Zbyszek Tenerowicz
d6223c7f73 Fix typo (#2959) 2023-05-19 12:53:00 -04:00
Jarred Sumner
67f543daa7 Update json-parse-stringify.mjs 2023-05-17 12:25:19 -07:00
Jarred Sumner
6c847f638f microbenchmark for json.parse / stringify 2023-05-17 12:12:42 -07:00
Dylan Conway
1ad8c54c90 fix asset naming output paths (#2904)
* rename to `src_path` and `dest_path`, use `dest_path` for output

* format

* option for compile
2023-05-16 17:07:40 -07:00
Colin McDonnell
366eba78f0 Tweaks to bundler docs (#2867)
* WIP

* Fix typo

* Updates

* Document --compile

* Add bundler benchmark

* Remove esbuild

* Add bench to docs

* Add buttons

* Updates
2023-05-16 10:47:00 -07:00
Jarred Sumner
60bc804c58 Bump 2023-05-16 09:31:04 -07:00
Ciro Spaciari
fe74c948cd feat(WebSocketServer) WebSocketServer wrapper + socket.io initial support (#2880)
* WebSocketServer wrapper + socket.io initial support

* fix up backpressure

* fix up backpressure

* fix http address

* add socket.io tests

* add closing tests

* add connection state recovery tests for socket.io

* add handshake test

* add middeware tests for socket.io

* added socket.io socket middleware tests

* add more socket.io test comment/skip  hang tests

* add pending package for tests

* add server attachment servers for socket.io

* add utility-methods tests for socket.io

* rename

* rename

* add messaging-many socket.io tests

* add namespaces tests to socket.io

* skip some tests

* fmt

* add packages to general package.json
2023-05-16 08:48:17 -07:00
Jarred Sumner
a008e49a40 forgot to commit this 2023-05-11 15:14:43 -07:00
dave caruso
6a163cf933 bundler tests and improve Bun.build return type (#2833)
* importstar_ts

* tests

* run acorn test suite

* bench tweaks

* test

* bun.build tests very incomplete

* remove dataurl and base64 loaders from tests since they dont work yet

* tests

* stuff

* stuff

* add errors and array of blobs

* work so far

* docs

* requested changes

* fix overwrite docs

* remove this file
2023-05-11 14:42:54 -07:00
Jarred Sumner
0e5f0940ee serialize 2023-05-10 23:30:30 -07:00
Jarred Sumner
9d3a95ed96 Add version 2023-05-10 23:03:37 -07:00
Jarred Sumner
2abfa84db7 Implement the benchmark snippet runner minus the sqlite serialization step 2023-05-10 22:50:56 -07:00
Jarred Sumner
e1c6adc737 Prepare to run these automatically 2023-05-10 21:37:08 -07:00
Jarred Sumner
9383333799 Add microbenchmark 2023-04-27 03:44:23 -07:00
Jarred Sumner
613bb4822e Revert "use a lazyily initialized stream for node:crypto createHash (#2652)"
This reverts commit 3a2fd65f20.
2023-04-21 07:18:32 -07:00
Jarred Sumner
a4d0a1961a Revert "implement node:events in javascript (#2604)"
This reverts commit 96a2ed1040.
2023-04-21 07:16:23 -07:00
dave caruso
96a2ed1040 implement node:events in javascript (#2604)
* initial event emitter reimplementation

* implement most of node:events. tests passing

* work on emitter

* fix importing node:events

* work on event emitter tests

* event work

* event work

* event stuff and experimenting with a lazy createHash

* cleanup crypto stuff i had on this branch

* finish event stuff up

* fix error monitor

* validate listeners are functions

* changes requested
2023-04-18 14:59:51 -07:00
dave caruso
3a2fd65f20 use a lazyily initialized stream for node:crypto createHash (#2652)
* lazy hash

* finish up crypto stuff

* remove lockfiles

* ok

* add pipe test

* update this lockfile

* remove unrelated crypto benchmark from this file
2023-04-13 21:55:01 -07:00
Colin McDonnell
76adc5be8a Add npm benchmark (#2555)
* Add install bench

* Update scripts and readme

* remove lockfiles

* Format bench

* Add dev instructions
2023-04-04 16:26:40 -07:00
Colin McDonnell
9bf4d9b8a2 Improve Benchmarking page, small fixes (#2339)
* Improve benchmarking page

* WIP

* Add typescript instructions to hot

* Document preload in Plugins. Fix loader in plugin types.
2023-03-07 17:44:05 -08:00
Jarred Sumner
838b37eed0 Update react-dom-render.bun.js 2023-03-03 04:45:33 -08:00
Jarred Sumner
1f10e25bd9 react-dom/server@next 2023-03-03 04:26:30 -08:00
Jarred Sumner
9388b3f825 Add a zig fmt action (#2277)
* Add a zig fmt action

* add failing file

* Setup prettier better

* Update prettier-fmt.yml

* Fail on error

* Update prettier-fmt.yml

* boop

* boop2

* tar.gz

* Update zig-fmt.yml

* Update zig-fmt.yml

* Update zig-fmt.yml

* Update zig-fmt.yml

* Update zig-fmt.yml

* boop

* Update prettier-fmt.yml

* tag

* newlines

* multiline

* fixup

* Update zig-fmt.yml

* update it

* fixup

* both

* w

* Update prettier-fmt.yml

* prettier all the things

* Update package.json

* zig fmt

*  

* bump

* .

* quotes

* fix prettier ignore

* once more

* Update prettier-fmt.yml

* Update fallback.ts

* consistentcy

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-03-02 19:02:10 -08:00
Jarred Sumner
1ba007831d Ensure prettier knows where to look 2023-03-02 15:12:00 -08:00