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

jemalloc issue in ripgrep on aarch64-linux #179907

Closed
andreamah opened this issue Apr 13, 2023 · 24 comments · Fixed by #182769, #184625 or #186243
Closed

jemalloc issue in ripgrep on aarch64-linux #179907

andreamah opened this issue Apr 13, 2023 · 24 comments · Fixed by #182769, #184625 or #186243
Assignees
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders search Search widget and operation issues verified Verification succeeded
Milestone

Comments

@andreamah
Copy link
Contributor

andreamah commented Apr 13, 2023

From #179121 (comment)
@mycraftmw

2023-04-11 11:01:28.153 [debug] RipgrepSearchEH#search /home/tongyu/.vscode-server-insiders/bin/7f03ec6f7a48791d8027761b22773b454fc52478/node_modules/@vscode/ripgrep/bin/rg --hidden --ignore-case -g '!/.git' -g '!/.svn' -g '!/.hg' -g '!/CVS' -g '!/.DS_Store' -g '!/Thumbs.db' -g '!/node_modules' -g '!/bower_components' -g '!**/*.code-search' --no-ignore-parent --follow --crlf --fixed-strings --no-config --no-ignore-global --json -- 'hello' '.'

  • cwd: /home/tongyu/bitswiss
    2023-04-11 11:01:28.161 [debug] RipgrepSearchEH#search : Unsupported system page size
    : Unsupported system page size
    memory allocation of 5 bytes failed

2023-04-11 11:01:28.220 [debug] RipgrepSearchEH#search No data from stdout
2023-04-11 11:01:28.220 [debug] RipgrepSearchEH#search No result from parser
2023-04-11 11:01:28.220 [debug] RipgrepSearchEH#search

Probably a regression from making aarch64-linux ripgrep build statically compiled to fix microsoft/vscode-ripgrep#34. We might need to dynamically compile ripgrep instead of using musl, and find a container to compile it in.

related BurntSushi/ripgrep#2180

// cc @roblourens

@andreamah andreamah added bug Issue identified by VS Code Team member as probable bug search Search widget and operation issues labels Apr 13, 2023
@andreamah andreamah self-assigned this Apr 13, 2023
@andreamah andreamah added this to the On Deck milestone Apr 14, 2023
@teohhanhui
Copy link

Looks like jemalloc just needs to be configured with --with-lg-page to support 16K page size.

This can be achieved by setting the environment variable:

JEMALLOC_SYS_WITH_LG_PAGE=14 (16K page size)

Or to support 64K page size as well:

JEMALLOC_SYS_WITH_LG_PAGE=16 (64K page size)

In either case, it'd still work for 4K/16K(/64K) page sizes.

@mycraftmw
Copy link

@andreamah Do we have any good news on this? I found the similar thing happened before on other application like sharkdp/fd#1085, probably we can use the same approach to solve this one?

@erifan
Copy link

erifan commented May 4, 2023

Any update on this issue ?

@gene203
Copy link

gene203 commented May 12, 2023

Temporary Workaround:

To address the issue until it is fixed, follow these steps:

Install ripgrep and obtain its path. For Rocky Linux or any RHEL-based Linux distribution, run the following command with root privileges:
sudo dnf install -y ripgrep

For Ubuntu, use the following command:
sudo apt install ripgrep

Alternatively, you can install ripgrep using Cargo:
cargo install ripgrep

Verify the installation and retrieve the path by running:
which rg

Replace the broken rg with a symlink by executing the following script. Please note that you should remove the echo commands to commit the changes:
(RIPGREP=/usr/bin/rg; find ~/.vscode-server/bin -name rg | while read file _ ; do echo rm -f $file ; echo ln -sf $RIPGREP $file; done)

This workaround should help resolve the issue temporarily.

@andreamah
Copy link
Contributor Author

This should be fixed in tomorrow's VS Code Insiders. Please try it out and let me know if it works for you!

@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels May 17, 2023
@gene203
Copy link

gene203 commented May 20, 2023

I tried

Version: 1.79.0-insder (user setup)
Commit: 6d3febd
Date: 2023-05-19T20:39:14 (about 3 hours ago)
OS: Windows_NT x65 10.0.22621`

but it seems not fixed or not included the fix. execute from the remote server(aarch64)
$ find .vscode-server-insiders -name rg -exec {} \;
and got

: Unsupported system page size
: Unsupported system page size
memory allocation of 5 bytes failed
find: ‘.vscode-server-insiders/bin/6d3fedb7c2cf965915c785dc07701eb978947506/node_modules/@vscode/ripgrep/bin/rg’ terminated by signal 6

(after resetting the remote environment by deleting .vscode-server-insiders folder on the remote, and vscode reloaded. - 'Developer: Reload Window')

@andreamah
Copy link
Contributor Author

Are you running 16K page size or 64K?

@gene203
Copy link

gene203 commented May 20, 2023

I got

$ getconf PAGE_SIZE
65536

on the aarch64 remote (Rocky Linux 8, aws r7g instance/Graviton3 processors).

Meanwhile, executing the same command above on x86-64 remote, I got the normal rg help print out as like

$ find .vscode-server-insiders/bin -name rg -exec {} ;`
error: The following required arguments were not provided:

USAGE:

rg [OPTIONS] PATTERN [PATH ...]
rg [OPTIONS] -e PATTERN ... [PATH ...]
rg [OPTIONS] -f PATTERNFILE ... [PATH ...]
rg [OPTIONS] --files [PATH ...]
rg [OPTIONS] --type-list
command | rg [OPTIONS] PATTERN
rg [OPTIONS] --help
rg [OPTIONS] --version

For more information try --help

and correcting the hand typed typo above of vscode insider version info

Version: 1.79.0-insider (user setup)
Commit: 6d3fedb
Date: 2023-05-19T20:39:14.598Z
Electron: 22.5.2
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.22621

@andreamah
Copy link
Contributor Author

Hmm ok. I tried setting the env variable to increase max page size for jemalloc, but it seems to not be working. I'll try another approach.

@andreamah andreamah reopened this May 23, 2023
@VSCodeTriageBot VSCodeTriageBot removed the insiders-released Patch has been released in VS Code Insiders label May 23, 2023
@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jun 8, 2023
@RuinanSun
Copy link

Is this fixed in the latest release version of VScode?
I just check on my arm64 container but it seems not working.

VScode Version: 1.79.0 (Universal)

@bashimao
Copy link

bashimao commented Jun 9, 2023

Same with @RuinanSun

Switched to newest insider build. 1.80.0. Problem not solved.

Went to server, killed .vscode server and deleted $HOME/.vscode-server-insiders. Tried again to bootstrap. Problem is still NOT resolved. Search is still limited to open files.

@bashimao
Copy link

bashimao commented Jun 9, 2023

image

@bashimao
Copy link

bashimao commented Jun 9, 2023

Here is some useful link detailing what I think is the problem. Not sure if it is resolved by now. But if info from the discussion is current, I think you will have to either compile on the target system, or ship different precompiled versions of binary and select the correct one depending on the system specs (see jemalloc/jemalloc#467 ).

@andreamah
Copy link
Contributor Author

We do cross-compile for different systems for ripgrep https://github.com/microsoft/ripgrep-prebuilt. I'll have to take another look.

@andreamah andreamah reopened this Jun 9, 2023
@VSCodeTriageBot VSCodeTriageBot removed the insiders-released Patch has been released in VS Code Insiders label Jun 9, 2023
@bashimao
Copy link

bashimao commented Jun 12, 2023

So, my interpretation is, that the page-size is hard-coded into jemalloc. When the system page size at runtime differs from the one it is compiled for, it will fail.

In other words, the one shipped right now fails out of the box:

mlanger@localhost:~/.vscode-server-insiders/bin/db6bcdf309cc1565c502a54b73c33a63bdabfbd8/node_modules/@vscode/ripgrep/bin$ ./rg
<jemalloc>: Unsupported system page size
<jemalloc>: Unsupported system page size
memory allocation of 5 bytes failed
Aborted (core dumped)

From your linked repo, I understand that you now focus on 16k page size. That would also not help me (if my suspicion is right), as my system's page size is: 64k

$ getconf PAGESIZE
65536

@bashimao
Copy link

@andreamah @RuinanSun : Temporary fix.

  1. Bootstrap vscode-server on target ARM system.
    You should have a directory called ~/.vscode-server-insiders now. That is where the vscode server lives.

  2. Download and compile ripgrep:

    sudo apt-get install cargo
    git clone https://github.com/BurntSushi/ripgrep.git
    cd ripgrep
    cargo build --release
    
  3. Replace binary deployed by vscode-server with custom compiled version.
    VSCODE_RG=`find ~/.vscode-server-insiders -name rg`; rm $VSCODE_RG; ln -s $PWD/target/release/rg $VSCODE_RG

Now search should work as expected.

@deepak1556
Copy link
Contributor

@bashimao can you check if the following ripgrep build runs fine on your aarch64 setup ? The build is generated from microsoft/ripgrep-prebuilt#30 to use 64k for jemalloc.

@RuinanSun
Copy link

Thanks @bashimao. ripgrep built from source works for me!

@andreamah
Copy link
Contributor Author

@RuinanSun @gene203 @bashimao can any of you verify this:

can you check if the following ripgrep build runs fine on your aarch64 setup ? The build is generated from microsoft/ripgrep-prebuilt#30 to use 64k for jemalloc.

@gene203
Copy link

gene203 commented Jun 24, 2023

I untar-ed the file and the binary 'rg' is working good with remote search. (I sym-linked it with vscode 1.79)

$ tar zxvf ripgrep--aarch64-unknown-linux-musl.tar.gz
rg
$ ls -l rg
-rwxr-xr-x 1 sysadmin sysadmin 4111744 Jun 12 21:34 rg
$ find ~/.vscode-server/bin -name rg -exec ln -sfn ~/rg {} ;

@VSCodeTriageBot VSCodeTriageBot added the unreleased Patch has not yet been released in VS Code Insiders label Jun 27, 2023
@andreamah andreamah added the author-verification-requested Issues potentially verifiable by issue author label Jun 27, 2023
@VSCodeTriageBot VSCodeTriageBot added insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jun 27, 2023
@VSCodeTriageBot
Copy link
Collaborator

This bug has been fixed in the latest release of VS Code Insiders!

@andreamah, you can help us out by commenting /verified if things are now working as expected.

If things still don't seem right, please ensure you're on version 45b31e9 of Insiders (today's or later - you can use Help: About in the command palette to check), and leave a comment letting us know what isn't working as expected.

Happy Coding!

@gene203
Copy link

gene203 commented Jun 27, 2023

I can confirm it is fixed with the vscode insider downloaded a minute ago of

Version: 1.80.0-insider (user setup)
Commit: da7f05a
Date: 2023-06-27T15:13:35.848Z
Electron: 22.3.14
ElectronBuildId: 21893604
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.22621

(assume the commit hash changed since)

❯ find ~/.vscode-server-insiders -name rg -exec {} -V \;
ripgrep 13.0.0

@andreamah andreamah added the verified Verification succeeded label Jun 27, 2023
@andreamah
Copy link
Contributor Author

thanks so much for checking! @gene203

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders search Search widget and operation issues verified Verification succeeded
Projects
None yet
9 participants