Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with large source maps #1911

Closed
segevfiner opened this issue Dec 26, 2023 · 4 comments
Closed

Crash with large source maps #1911

segevfiner opened this issue Dec 26, 2023 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@segevfiner
Copy link
Contributor

Describe the bug
On trying to debug using the "JavaScript Debug Terminal", a project that has quite a bunch of very large source maps, the debugger, debug adapter & extension host crash with: "Debug adapter process has terminated unexpectedly (Extension host shut down)".

To Reproduce
Steps to reproduce the behavior:

  1. Debug a project with very large source maps using the "JavaScript Debug Terminal".

My project is proprietary, so I can't provide it directly as a repro, but I will see if I can mock something similar that exhibits the same behavior if you can't figure out what's going on from logs alone.

Log File

vscode-debugadapter-28a26b60.json.gz

It also sometimes produces a cpuprofile in the "Window" log of VS Code:
image
exthost-d35bd5.cpuprofile

VS Code Version: 1.85.1

Additional context
Wasn't able to figure out exactly why it crashes. As in, if it hangs the extension host, and gets terminated by something, OOM, or something else... Any ideas how to figure this out?

@segevfiner segevfiner added the bug Issue identified by VS Code Team member as probable bug label Dec 26, 2023
@connor4312
Copy link
Member

connor4312 commented Jan 5, 2024

That appears to be in this function https://github.com/TooTallNate/proxy-agents/blob/b133295fd16f6475578b6b15bd9b4e33ecb0d0b7/packages/data-uri-to-buffer/src/index.ts#L8-L39

While that's not super fast (the base64 decoder I wrote for vscode itself is 3x faster) I don't see it being that slow. Parsing 100MB of data through that takes about 3.5 seconds, but it's not a crash and that would be "very big" as far as sourcemaps go...

How big are your sourcemaps?

connor4312 added a commit to connor4312/proxy-agents that referenced this issue Jan 5, 2024
I saw in microsoft/vscode-js-debug#1911 that
base64 decoding of a data URI was taking a bit of time.

This PR feature-detects the presence of a global `Buffer` to use native
decoding when running in Node.js, which is about 25x faster on a 10MB
data URI than the JS implementation in the library.

I have a bit of a hack in order to test both paths when running tests,
happy to change it if desired :)
@segevfiner
Copy link
Contributor Author

There are many, a lot of them are small, but there are also a few big ones, with the largest being around 50MiB, though it's not really used in the source of the script I was trying to debug.

@connor4312
Copy link
Member

Once my linked PR goes in, decoding should be much faster (25x or so).

You may also see improvement in the latest nightly with #1916, which fixes some cases where sourcemap memory was leaked (the previous implementation was wasm-based and required manual deallocation of memory, which didn't always happen.)

TooTallNate added a commit to TooTallNate/proxy-agents that referenced this issue Jan 8, 2024
* Make decoding of base64 data URIs faster

I saw in microsoft/vscode-js-debug#1911 that
base64 decoding of a data URI was taking a bit of time.

This PR feature-detects the presence of a global `Buffer` to use native
decoding when running in Node.js, which is about 25x faster on a 10MB
data URI than the JS implementation in the library.

I have a bit of a hack in order to test both paths when running tests,
happy to change it if desired :)

* use conditional exports

* fix test import

* fix node test import, and set stringToBuffer encoding

* Create few-adults-rhyme.md

---------

Co-authored-by: Nathan Rajlich <[email protected]>
rowaxl pushed a commit to yumemi-makiyama/proxy-agents that referenced this issue Jan 24, 2024
* Make decoding of base64 data URIs faster

I saw in microsoft/vscode-js-debug#1911 that
base64 decoding of a data URI was taking a bit of time.

This PR feature-detects the presence of a global `Buffer` to use native
decoding when running in Node.js, which is about 25x faster on a 10MB
data URI than the JS implementation in the library.

I have a bit of a hack in order to test both paths when running tests,
happy to change it if desired :)

* use conditional exports

* fix test import

* fix node test import, and set stringToBuffer encoding

* Create few-adults-rhyme.md

---------

Co-authored-by: Nathan Rajlich <[email protected]>
@connor4312
Copy link
Member

Please let me know if you see this again on the nightly build or VS Code >1.86. Thanks!

SmartAlex1995 added a commit to SmartAlex1995/proxy-agents that referenced this issue Mar 20, 2024
* Make decoding of base64 data URIs faster

I saw in microsoft/vscode-js-debug#1911 that
base64 decoding of a data URI was taking a bit of time.

This PR feature-detects the presence of a global `Buffer` to use native
decoding when running in Node.js, which is about 25x faster on a 10MB
data URI than the JS implementation in the library.

I have a bit of a hack in order to test both paths when running tests,
happy to change it if desired :)

* use conditional exports

* fix test import

* fix node test import, and set stringToBuffer encoding

* Create few-adults-rhyme.md

---------

Co-authored-by: Nathan Rajlich <[email protected]>
adrianchu0120 added a commit to adrianchu0120/proxy-agents that referenced this issue Aug 25, 2024
* Make decoding of base64 data URIs faster

I saw in microsoft/vscode-js-debug#1911 that
base64 decoding of a data URI was taking a bit of time.

This PR feature-detects the presence of a global `Buffer` to use native
decoding when running in Node.js, which is about 25x faster on a 10MB
data URI than the JS implementation in the library.

I have a bit of a hack in order to test both paths when running tests,
happy to change it if desired :)

* use conditional exports

* fix test import

* fix node test import, and set stringToBuffer encoding

* Create few-adults-rhyme.md

---------

Co-authored-by: Nathan Rajlich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

2 participants