Skip to content

Very slow console.log on large sparse arrays compared to Node and Deno #29175

@kevgeoleo

Description

@kevgeoleo

What version of Bun is running?

1.3.11-canary.1+9e93bfa1b

What platform is your computer?

Linux 5.10.0-12-amd64 x86_64 x86_64

What steps can reproduce the bug?

Hi,

I would like to report a behavior in Bun that can be reproduced using the below snippet

console.time("long-empty-array");
console.log(new Array(167772160 * 10));
console.timeEnd("long-empty-array");

What is the expected behavior?

Node takes just 9ms

root@KContainer:~/14656# node long_empty_array_log.mjs
[ <1677721600 empty items> ]
long-empty-array: 9.408ms

Deno takes just 0.5ms

root@KContainer:~/14656# deno run -A long_empty_array_log.mjs
[ <1677721600 empty items> ]
long-empty-array: 0.578ms

What do you see instead?

Bun takes 16seconds which is abnormally slow

root@KContainer:~/14656# bun run long_empty_array_log.mjs
[
  1677721600 x empty items
]
[16.15s] long-empty-array

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions