Skip to content

Simplify globals (tech debt) #29703

@bartlomieju

Description

@bartlomieju

Currently Deno maintains two sets of globals - one set is “Web native”, available to user code, the other is “Node native” and available to npm dependencies.

This leads to several problems:

  • the setup is very complex and requires non-trivial solution at the V8 level
  • the performance is absolutely horrible - on each access of a global a stack trace gets collected (most often only a single frame) to determine which global should be used - this causes huge overhead, eg. using performance.now() in a tight loop causes lookup of the global to take more time then actually benchmarked code
  • it’s a mental overhead to figure out which global is gonna get used depending on the code location

Currently the list is as follows:

There are some easy solution here:

  • make Buffer, clearImmediate, global, setImmediate always available to all code
  • merge performance global to only use “Node” version (which has additional properties compared to the Web one)
  • make clearInterval and clearTimeout work with both Web (number) and Node (object) timeouts

And there are hard problems related to setTimeout and setInterval APIs that changing them will lead to a huge breaking change, while leaving them as is will maintain the complexity.

  • Priority: 4
  • Technical complexity: 5

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions