0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-31 09:14:20 -04:00
Commit graph

8789 commits

Author SHA1 Message Date
Divy Srivastava
99da8a69e7
fix(ext/webstorage): check size of inputs before insert (#18087) 2023-03-09 12:28:51 +00:00
Bartek Iwańczuk
c3cba7f22c
refactor(core): Extension::builder_with_deps (#18093)
Prerequisite for https://github.com/denoland/deno/pull/18080
2023-03-09 12:10:54 +00:00
Kenta Moriuchi
521cb4ca9b
fix(rumtime): Add Deno. prefix for registered symbols (#18086) 2023-03-09 04:09:40 +00:00
Bartek Iwańczuk
4e8edafb39
perf(core): over-allocate in ModuleMap when running from snapshot (#18083)
This commit changes "ModuleMap" initialization to over-allocate by 16
for vectors storing module information and module V8 handles. In 99%
cases there's gonna be at least one additional module loaded, so it's
very wasteful to have to reallocate when the module is executed (IIRC
Rust will double the size of the vector) and move all of the elements.
2023-03-09 09:12:46 +05:30
Bartek Iwańczuk
0f9df73349
perf: don't add unload event listener (#18082)
This commit changes how "unload" event is handled - before
this commit an event listener was added unconditionally in
the runtime bootstrapping function, which for some reason was
very expensive (0.3ms). Instead of adding an event listener,
a check was added to "dispatchEvent" function that performs
the same action (so it's only called if there's an event dispatched).
2023-03-09 01:08:54 +00:00
David Sherret
25d98ca289
refactor(lsp): improve test client initialization (#18015) 2023-03-08 23:15:20 +00:00
Roy Ivy III
f2e5e01832
fix(runtime/windows): ensure Deno.stdin.setRaw(false) properly disables raw mode (#17983) 2023-03-08 19:56:49 +00:00
David Sherret
23e1ba7e2d
fix(npm): improve peer dependency resolution with circular dependencies (#18069)
This improves peer dependency resolution yet again. We did not handle
scenarios like the following:

```
// a -> b -> c -> d -> c -> b (peer)
```

...which would maybe work ok the first time its run in some cases, but
then lead to a lockfile that would error on load.

This now keeps track of circular dependencies and updates nodes
accordingly. That said, there is still a lurking bug in this code
somewhere that I've added a comment for (there is a mitigation on the
tail end that seems to work well). The current state is much better than
before and I can look into it later. I think it's something small that's
incorrect.
2023-03-08 12:22:08 -05:00
Divy Srivastava
0cce9c2bcc
feat(core): prevent isolate drop for CLI main worker (#18059)
```
Benchmark 1: deno run -A ../empty.js
  Time (mean ± σ):      20.5 ms ±   0.5 ms    [User: 13.4 ms, System: 5.1 ms]
  Range (min … max):    19.8 ms …  24.0 ms    119 runs

Benchmark 2: target/release/deno run -A ../empty.js
  Time (mean ± σ):      18.8 ms ±   0.3 ms    [User: 13.0 ms, System: 4.9 ms]
  Range (min … max):    18.3 ms …  19.9 ms    129 runs
  ```

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-03-08 22:21:14 +05:30
Bartek Iwańczuk
06a12341c6
chore: update tempfile dependency (#18077) 2023-03-08 16:46:27 +00:00
Miroslav Bajtoš
b21129173a
deps: bump once_cell to ^1.17.1 (#18075) 2023-03-08 15:49:13 +00:00
Bartek Iwańczuk
0e8fc4dc6c
Revert "perf: disable snapshot compression (#18061)" (#18074)
This reverts commit d12b039e1a.

It was landed as an experiment and it confirms much faster startup
if not compression is applied.
2023-03-08 21:14:04 +05:30
David Sherret
88b5fd9088
fix: attempt to only allow one deno process to update the node_modules folder at a time (#18058)
This is implemented in such a way that it should still allow processes
to go through when a file lock wasn't properly cleaned up and the OS
hasn't released it yet (but with a 200ms-ish delay).

Closes #18039
2023-03-08 15:13:13 +00:00
Bartek Iwańczuk
72fe9bb470
refactor: rename InternalModuleLoader to ExtModuleLoader, use ext: scheme for snapshotted modules (#18041)
This commit renames "deno_core::InternalModuleLoader" to
"ExtModuleLoader" and changes the specifiers used by the 
modules loaded from this loader to "ext:".

"internal:" scheme was really ambiguous and it's more characters than
"ext:", which should result in slightly smaller snapshot size.

Closes https://github.com/denoland/deno/issues/18020
2023-03-08 12:44:54 +01:00
Bartek Iwańczuk
d24c6ea27f
refactor(runtime): conditionally register Extension with source files (#18068)
Since we are snapshotting extension source at build time, there's no
need to define list of sources for the extension at runtime.

This commit changes "deno_node" extension by removing "init_polyfill"
function in favor of "init_polyfill_ops_and_esm()" and "init_polyfill_ops()".

The former is used during snapshot and when "deno_runtime" is compiled
with "dont_create_runtime_snapshot" cargo feature flag. The latter is used
when running a worker from an existing snapshot.

This is a start of a bigger refactor to all extensions - thanks to this
change, we don't have to iterate over all defined source files for extension at
runtime, and because of that we don't have to create a filepath for each of the
source files. It's not a big deal, but we are iterating over 300 files on each start,
and concatenating 3 strings before creating a "PathBuf" for ~200 of them.
This is already visible on the startup flamegraphs and should be avoided.
2023-03-08 12:43:26 +01:00
Bartek Iwańczuk
9eb987e46c
perf: move setting up Deno namespace to snapshot time (#18067)
No need to do it on startup every time.
2023-03-08 09:50:54 +05:30
Bartek Iwańczuk
b32a6f8ad2
refactor(core): don't use Result in ExtensionBuilder::state (#18066)
There's no point for this API to expect result. If something fails it should
result in a panic during build time to signal to embedder that setup is
wrong.
2023-03-07 22:37:37 +01:00
Caleb Cox
0e3affcd5b
fix(cli): add space after period in --v8-flags (#18063)
Add space between period and "Any" in `--v8-flags` help text.
2023-03-07 17:07:28 +01:00
Bartek Iwańczuk
76d085ff6a
perf: move runtime bootstrap code to snapshot time (#18062)
This commit moves some of the code from "99_main.js" to
be executed during the snapshot time instead of on each
worker bootstrap. These should minimally help with startup
time benchmark.
2023-03-07 16:11:54 +01:00
ayame113
08591d052a
chore(docs): Fixed manual link (#18060) 2023-03-07 08:01:56 -05:00
Bartek Iwańczuk
d12b039e1a
perf: disable snapshot compression (#18061)
This commit disables snapshot compression for the CLI snapshot.]

Decompressing the snapshot on startup takes ~2.5ms.
2023-03-07 13:57:58 +01:00
Bartek Iwańczuk
fe368b72c1
refactor: Add "deno_fs" extension crate (#18040)
This commit factors out APIs related to file system from "runtime/"
to a separate "deno_fs" extension crate.
2023-03-07 18:13:44 +09:00
Nick Hanley
64354f4112
chore(tests): use temp dir in test missing_deno_dir (#18057)
Fixes #18056
2023-03-07 00:00:51 -05:00
Tristan F
805e8b39ce
chore: remove duplicate copyright disclaimer (#18055)
Removes duplicate copyright disclaimer from `/lockfile/lib.rs`
2023-03-06 22:56:53 -05:00
Bartek Iwańczuk
489cafd5ba
refactor: use v8::String::new_external_onebyte_static where appropriate (#18051) 2023-03-06 16:37:46 +00:00
David Sherret
ff4b03f233
chore(tests): ability to capture stdout and stderr separately (#18035)
This is to allow making assertions on stdout and stderr separately.
2023-03-06 09:16:50 -05:00
Divy Srivastava
eea742ec6a
fix(ext/node): remove unused _hex module (#18045) 2023-03-06 09:57:32 +05:30
Divy Srivastava
4451fa857b
perf(ext/node): improve createHash performance (#18033)
```
> deno run -A ../test.mjs
cpu: unknown
runtime: deno 1.31.1 (aarch64-apple-darwin)

benchmark      time (avg)             (min … max)       p75       p99      p995
------------------------------------------------- -----------------------------
             2.22 µs/iter      (2.2 µs … 2.28 µs)   2.22 µs   2.28 µs   2.28 µs

> target/release/deno run -A test.mjs
cpu: unknown
runtime: deno 1.31.1 (aarch64-apple-darwin)

benchmark      time (avg)             (min … max)       p75       p99      p995
------------------------------------------------- -----------------------------
            864.9 ns/iter   (825.05 ns … 1.22 µs) 864.93 ns   1.22 µs   1.22 µs
```
2023-03-06 08:58:04 +05:30
Bartek Iwańczuk
76b173b60c
refactor: move "pathFromURL" to deno_web extension (#18037)
This API is required by several extensions like "ext/node", "ext/ffi"
and also FS APIs that we want to move to a separate crate. Because 
of that "pathFromURL" API was moved to "deno_web" extension so
other extension crates can rely on it.
2023-03-05 22:46:37 +00:00
Bartek Iwańczuk
1ab16e2426
refactor(core): InternalModuleLoader checks if all files were used (#18005)
This commit changes "InternalModuleLoader" from "deno_core" to 
store a list of used modules during snapshotting. If a module was not
used during snapshotting "InternalModuleLoader" will panic in its "Drop"
handler signaling to the embedder that they made a mistake somewhere.
2023-03-05 22:42:52 +00:00
Bartek Iwańczuk
5f34c9be91
refactor: move definition of Deno.build from "runtime" to "core" (#18036)
We use information about build in several extension crates like
"ext/node" or "runtime/". In an effort to move "fs" APIs to a separate 
crate it is a prerequisite to have this information available outside 
of the "runtime/" crate.

This commit moves definition of "build" object to "Deno.core" that is 
later forwarded to "Deno.build".
2023-03-05 22:18:13 +00:00
Nayeem Rahman
273777f7d9
fix(check): include dts files in tsc roots (#18026) 2023-03-05 12:47:04 -05:00
Divy Srivastava
c9c782940e
chore(ext/node): cleanup empty internal_bindings (#18032) 2023-03-05 10:53:42 -04:00
Filip Skokan
7d13d65468
fix(ext/crypto): correctly limit ECDSA and hash algorithms (#18030)
Closes #18029
2023-03-05 12:34:07 +00:00
Bartek Iwańczuk
de0d148d93
refactor(runtime): merge "spawn" into "process" (#18022)
This commit merges "runtime/js/40_spawn.js" into
"runtime/js/40_process.js", and "runtime::ops::spawn" 
into "runtime::ops::process".

It makes little sense to have them separated given that we want to
factor out these APIs into a separate extension crate.
2023-03-05 12:19:34 +00:00
Divy Srivastava
d4807f458e
chore(core): remove argc field from OpDecl (#18024)
https://github.com/denoland/deno/pull/18023#discussion_r1125611859
2023-03-05 11:16:43 +00:00
Aapo Alasuutari
da201d9ea5
feat(ext/ffi): Make External pointers keep reference to V8 buffer (#17955) 2023-03-05 08:01:23 +00:00
Divy Srivastava
0910be4d64
feat(ops): relational ops (#18023)
Join two independent ops into one. A fast impl of one + a slow callback
of another. Here's an example showing optimized paths for latin-1 via
fast call and the next-best fallback using V8 apis.

```rust
#[op(v8)]
fn op_encoding_encode_into_fallback(
  scope: &mut v8::HandleScope,
  input: serde_v8::Value,
// ...

#[op(fast, slow = op_encoding_encode_into_fallback)]
fn op_encoding_encode_into(
  input: Cow<'_, str>,
// ...
```

Benchmark results of the fallback path:
```
time target/release/deno run -A --unstable ./cli/tests/testdata/benches/text_encoder_into_perf.js
________________________________________________________
Executed in   70.90 millis    fish           external
   usr time   57.76 millis    0.23 millis   57.53 millis
   sys time   17.02 millis    1.28 millis   15.74 millis

target/release/deno_main run -A --unstable ./cli/tests/testdata/benches/text_encoder_into_perf.js
________________________________________________________
Executed in  154.00 millis    fish           external
   usr time   67.14 millis    0.26 millis   66.88 millis
   sys time   38.82 millis    1.47 millis   37.35 millis
```
2023-03-05 13:30:22 +05:30
Bartek Iwańczuk
888ceac7fd
refactor(runtime): remove 40_files.js, 40_write_file.js and 40_read_file.js (#18018)
JavaScript APIs from "runtime/js/40_files.js" combined abstractions
for stdio streams ("Stdout", "Stderr", "Stdin") and file system file
("File", "FsFile"). APIs from "runtime/js/40_read_file.js" and 
"runtime/js/40_write_file.js" were implemented using ops from 
"runtime/ops/fs.rs".

This file was removed and relevant APIs were moved to "deno_io/12_io.js"
and "runtime/js/30_fs.js".

This work is meant to enable factoring out "deno_fs" crate.
2023-03-05 03:37:37 +00:00
Bartek Iwańczuk
17574f1ef7
refactor: remove unused 40_diagnostics.js file (#18021)
This file was not used anywhere - even though it exposed an unstable
"Deno.DiagnosticCategory" API. Seems like a left over from when we
had "Deno.emit" API.
2023-03-05 03:04:08 +00:00
Bartek Iwańczuk
b40086fd7d
refactor(core): include_js_files! 'dir' option doesn't change specifiers (#18019)
This commit changes "include_js_files!" macro from "deno_core"
in a way that "dir" option doesn't cause specifiers to be rewritten 
to include it.

Example:
```
include_js_files! {
  dir "js",
  "hello.js",
}
```

The above definition required embedders to use:
`import ... from "internal:<ext_name>/js/hello.js"`. 
But with this change, the "js" directory in which the files are stored
is an implementation detail, which for embedders results in: 
`import ... from "internal:<ext_name>/hello.js"`.

The directory the files are stored in, is an implementation detail and 
in some cases might result in a significant size difference for the 
snapshot. As an example, in "deno_node" extension, we store the 
source code in "polyfills" directory; which resulted in each specifier 
to look like "internal:deno_node/polyfills/<module_name>", but with 
this change it's "internal:deno_node/<module_name>". 

Given that "deno_node" has over 100 files, many of them having 
several import specifiers to the same extension, this change removes
10 characters from each import specifier.
2023-03-05 02:31:38 +00:00
Andreu Botella
01028fcdf4
test(compile): Add a test for dynamic imports in deno compile (#18017)
denoland/eszip#115 added support for statically-analyzed dynamic imports
in eszip, which made `deno compile` support dynamic imports starting
from #17858. This PR adds a test for it.

----

This test is adapted from PR #17663.

Closes #17908
2023-03-05 01:37:54 +00:00
David Sherret
2f7222da8a
refactor: remove Semaphore::new(1) and use TaskQueue (#18014) 2023-03-04 20:07:11 -05:00
Bartek Iwańczuk
7afa3aceb0
refactor(runtime): factor out deno_io extension crate (#18001)
This is a prerequisite to factor out FS ops to a separate crate.
2023-03-05 00:39:48 +00:00
Bartek Iwańczuk
4894e500cf
refactor: move TaskQueue from deno_runtime to deno_core (#18016)
This utility is useful in several contexts so it seems reasonable to
have it in `deno_core`.
2023-03-05 00:10:31 +00:00
Bartek Iwańczuk
19bb23b60a
refactor(runtime): factor out FsPermissions for fs ops (#18012)
This will help us with moving fs ops to a separate extension crate.
2023-03-05 00:44:59 +01:00
Geert-Jan Zwiers
58ec963bf1
refactor: simplify to string calls (#18011) 2023-03-04 08:05:07 -04:00
Geert-Jan Zwiers
399a22db88
chore(docs): add note about loadavg returning 0 on windows (#18006) 2023-03-04 05:31:55 -04:00
David Sherret
84bafd11d5
fix: lazily surface errors in package.json deps parsing (#17974)
Closes #17941
2023-03-03 18:27:05 -04:00
Bartek Iwańczuk
5c43e2a665
chore: update deno_std submodule to 0.178.0 (#18003) 2023-03-03 19:11:10 +00:00