1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-14 16:33:45 -05:00
Commit graph

77 commits

Author SHA1 Message Date
Ryan Dahl
2a5138a516
Remove Config struct from core (#2502)
It's unnecessary indirection and is preventing the ability to easily
pass isolate references into the dispatch and dyn_import closures.

Note: this changes how StartupData::Script is executed. It's no longer done
during Isolate::new() but rather lazily on first poll or execution.
2019-06-12 10:53:24 -07:00
Ryan Dahl
e043697521
Expose dynamic import in core (#2472) 2019-06-10 15:27:34 -04:00
Bert Belder
8999517421
core,cli: fix clippy warnings 2019-05-03 03:29:42 +02:00
Ryan Dahl
c171813e89
core: express op as enum (#2255) 2019-05-01 18:22:32 -04:00
Bert Belder
41c7e96f1a
Refactor zero-copy buffers for performance and to prevent memory leaks
* In order to prevent ArrayBuffers from getting garbage collected by V8,
  we used to store a v8::Persistent<ArrayBuffer> in a map. This patch
  introduces a custom ArrayBuffer allocator which doesn't use Persistent
  handles, but instead stores a pointer to the actual ArrayBuffer data
  alongside with a reference count. Since creating Persistent handles
  has quite a bit of overhead, this change significantly increases
  performance. Various HTTP server benchmarks report about 5-10% more
  requests per second than before.

* Previously the Persistent handle that prevented garbage collection had
  to be released manually, and this wasn't always done, which was
  causing memory leaks. This has been resolved by introducing a new
  `PinnedBuf` type in both Rust and C++ that automatically re-enables
  garbage collection when it goes out of scope.

* Zero-copy buffers are now correctly wrapped in an Option if there is a
  possibility that they're not present. This clears up a correctness
  issue where we were creating zero-length slices from a null pointer,
  which is against the rules.
2019-05-01 21:11:09 +02:00
Ryan Dahl
7fc9d7d62a
core: Add test for snapshotting from Rust (#2197) 2019-04-24 21:43:06 -04:00
Ryan Dahl
d68b44b6b2
core: make Isolate concrete, remove Dispatch trait (#2183)
Op dispatch is now dynamically dispatched, so slightly less efficient.
The immeasurable perf hit is a reasonable trade for the API simplicity
that is gained here.
2019-04-23 18:58:00 -04:00
Bert Belder
7807afa972
core: make Isolate use FuturesUnordered to track ops
Additionally, instead of polling ops in a loop until none of them are
ready, the isolate will now yield to the task system after delivering
the first batch of completed ops to the javascript side.

Although this makes performance a bit worse (about 15% fewer
requests/second on the 'deno_core_http_bench' benchmark), we feel that
the advantages are worth it:

* It resolves the extremely high worst-case latency that we were seeing
  on deno_core_http_bench, in particular when using the multi-threaded
  Tokio runtime, which would sometimes exceed a full second.

* Before this patch, the implementation of Isolate::poll() had to loop
  through all sub-futures and poll each one of them, which doesn't scale
  well as the number of futures managed by the isolate goes up. This
  could lead to poor performance when e.g. a server is servicing
  thousands of connected clients.
2019-04-16 22:54:33 +02:00
Bert Belder
dd595220ab
core: run isolate tests within a task
This change is made in preparation for using FuturesUnordered to track
futures that are spawned by the isolate. FuturesUnordered sets up
notififications for every future that it finds to be not ready when
polled, which causes a crash if attempted outside of a task context.
2019-04-16 22:26:33 +02:00
Ryan Dahl
d2579f4564
core: Rename Behavior to Dispatch (#2082)
And rename IsolateState to ThreadSafeState.

Also make ThreadSafeState directly implement Dispatch. This is simpler.
2019-04-09 13:11:25 -04:00
Bert Belder
e43da28b28
core: poll ops round robin
Also use a VecDeque to store pending ops to avoid exponential time complexity
when removing completed ops from the list.
2019-04-08 23:10:21 +02:00
Ryan Dahl
f7fdb90fd5
core: snapshot improvements (#2052)
* Moves how snapshots are supplied to the Isolate. Previously they were
  given by Behavior::startup_data() but it was only called once at
  startup. It makes more sense (and simplifies Behavior) to pass it to the
  constructor of Isolate.
* Adds new libdeno type deno_snapshot instead of overloading
  deno_buf.
* Adds new libdeno method to delete snapshot deno_snapshot_delete().
* Renames deno_get_snapshot() to deno_snapshot_new().
* Makes StartupData hold references to snapshots. This was implicit when
  it previously held a deno_buf but is made explicit now. Note that
  include_bytes!() returns a &'static [u8] and we want to avoid
  copying that.
2019-04-08 10:12:43 -04:00
Ryan Dahl
0a26230a87
Improve docs in core (#2049) 2019-04-04 09:35:52 -04:00
Bert Belder
917e68f30f
Refactor deno_core::RecursiveLoad to be more idiomatic (#2034) 2019-04-02 20:10:16 +02:00
Ryan Dahl
2b0f553e2e
Add deno_core::RecursiveLoad for async module loading (#2034) 2019-04-02 20:10:08 +02:00
Ryan Dahl
c9614d86c1
Move //libdeno to //core/libdeno (#2015)
Fixes some sed errors introduced in c43cfe.

Unfortunately moving libdeno required splitting build.rs into two parts,
one for cli and one for core.

I've also removed the arm64 build - it's complicating things at this
re-org and we're not even testing it. I need to swing back to it and get
tools/test.py running for it.
2019-03-30 14:45:36 -04:00
Bert Belder
da1b98b690 Clippy fixes (#2009) 2019-03-28 08:09:19 -04:00
Kitson Kelly
c43cfedeba namespace reorg: libdeno and DenoCore to Deno.core (#1998) 2019-03-26 08:22:07 -04:00
Ryan Dahl
d8714281b4
Resolve callback moved from Behavior to mod_instantiate() (#1999)
This simplifies the Behavior trait and makes it more explicit where the
resolve callback is being made.

Also s/StartupScript/Script
2019-03-25 17:43:31 -04:00
Bartek Iwańczuk
129eae0265 Handle overflown shared queue (#1992)
Fixes #1988
2019-03-24 11:07:10 -04:00
Simon Menke
93793dc455 core: Allow terminating an Isolate from another thread (#1982) 2019-03-21 09:48:19 -04:00
andy finch
cdfd32dd74 Re-implement init scripts in core (#1958)
Re-enables arm64 CI test
2019-03-18 20:03:37 -04:00
Ryan Dahl
44773c9b0f Integrate //core into existing code base
This disables a few tests which are broken still:
- tests/error_004_missing_module.test
- tests/error_005_missing_dynamic_import.test
- tests/error_006_import_ext_failure.test
- repl_test test_set_timeout
- repl_test test_async_op
- repl_test test_set_timeout_interlaced
- all of permission_prompt_test
2019-03-18 17:17:08 -04:00
Bert Belder
62761a4e3a
core: remove reset() from SharedQueue API 2019-03-15 21:57:22 +01:00
Ryan Dahl
1811318097 core: Behavior shouldn't be generic
We always pass around Box<[u8]>, and adding this generic is an
unnecessary complication.

Add deno_core_http_bench_test to test.py

sharedQueue works on deno_core_http_bench
2019-03-15 10:58:18 -04:00
Ryan Dahl
6b07ed189c
Small cleanups for //core (#1914)
* Privatize a few deno_core::Isolate methods
* Add deno_core::Isolate docs
2019-03-12 18:47:54 -04:00
Ryan Dahl
72f9a2e20d
core: Abstract out Behavior from Isolate (#1904)
Move v8_set_flags and v8_version to core. (The idea is that src/ should
not depend on libdeno.rs anymore. This is a step towards that.)
2019-03-11 17:57:36 -04:00