News for hackers. Stuff that matters.
Re:Initial preview of GUI app support for the Windows Subsys... by siproprio on Wednesday April 21, 2021 @02:41PM (#26893771)
If you thought electron apps used a lot of memory, this thing will surprise you [0]:

With WSL2, apps will now use either 50% or 8GB of your available memory.

Happy coding!

[0]: https://github.com/microsoft/WSL/issues/4166

Re:Initial preview of GUI app support for the Windows Subsys... by 2ion on Wednesday April 21, 2021 @04:00PM (#26894668)

    PS C:\Users\2ion> cat .\.wslconfig
    [wsl2]
    memory=6G
    processors=4
These settings are being respected, as far as I can tell. Since when is it not common sense to assign a reasonable amount to a VM? The only thing that does not seem to work well at the moment is a "memory balloon" RAM allocation scheme. WSL2 is a VM, not a shared memory container. They could do better, but RAM is pretty cheap nowadays and WSLg is IMO the much more productive feature.

See https://docs.microsoft.com/en-us/windows/wsl/wsl-config#conf....

Re:Initial preview of GUI app support for the Windows Subsys... by HideousKojima on Wednesday April 21, 2021 @04:53PM (#26895306)
A single (idle) SQL Server Docker container shouldn't be using 5 GB of ram
Re:Initial preview of GUI app support for the Windows Subsys... by piaste on Wednesday April 21, 2021 @05:22PM (#26895603)
SQL Server by design grabs as much RAM as it can, as aggressively and preemptively as it can, because it assumes it's the most important process running on the machine. Which is almost always the case in production environments, and a reasonable default behaviour as a result. If that's not the case, you can easily set resource limits at the application, container, and/or VM level.

(This comment coming from someone who used to have to support running small backup MSSQL instances on Windows 8 tablets.)

Re:Initial preview of GUI app support for the Windows Subsys... by skeletonjelly on Wednesday April 21, 2021 @08:37PM (#26897246)
Yep this. SQL Server using RAM is by design. If it's using too much because you're using it for dev work then you can simply limit the amount it can access. RAM is there to be used!
Re:Initial preview of GUI app support for the Windows Subsys... by MereInterest on Wednesday April 21, 2021 @11:27PM (#26898391)
It's a perfectly fine design so long as there's one, and only one, program that is maximizing its RAM usage. When you have many programs (e.g. the browser, Teams, slack, every single electron app), then you get loads of contention.
Re:Initial preview of GUI app support for the Windows Subsys... by easton on Wednesday April 21, 2021 @11:31PM (#26898414)
> (This comment coming from someone who used to have to support running small backup MSSQL instances on Windows 8 tablets.)

Can I ask what the use case was? Was it just in case the primary DB server died and they wanted a battery powered backup?

Re:Initial preview of GUI app support for the Windows Subsys... by ryanjshaw on Thursday April 22, 2021 @01:59AM (#26899241)
Can't speak for OP but here in Africa I've worked on a two unrelated projects where poor internet connectivity meant it made sense to have a local SQL Express running on a users device, which a service would then try to regularly synchronize with the central server. Makes sense when you are capturing documentation and can make all the decisions in disconnected operation.
Re:Initial preview of GUI app support for the Windows Subsys... by voxic11 on Wednesday April 21, 2021 @08:18PM (#26897095)
WSL2 runs in a vm which is integrated with windows, so it actually dynamically requests memory from windows as required. It also can release memory back to windows and is basically is represented on the windows side as a windows process.

Unfortunately like a process there is no way for windows to request memory back from linux (besides killing the entire thing). So its up to the linux kernel to decide what to release back.

What that configuration does is limit the maximum amount of memory it can request (what the linux kernel sees as the total system memory). The reason you need to set a limit right now is that the linux kernel will pretty quickly request most of your windows memory to use as page cache if you don't limit it.

Microsoft is working to allow the linux kernel to use the windows page cache instead of maintaining a separate one.

https://github.com/microsoft/WSL/issues/4166#issuecomment-64...

Re:Initial preview of GUI app support for the Windows Subsys... by siproprio on Wednesday April 21, 2021 @09:19PM (#26897526)
> Microsoft is working to integrate the linux disk cache with the windows disk cache to avoid this issue

... since july 2019, a locked discussion, a lot of dupes, and no progress to report thus far.

Re:Initial preview of GUI app support for the Windows Subsys... by 2ion on Thursday April 22, 2021 @07:02AM (#26901333)
It sounds like a very complicated topic, it's crossing multiple isolation boundaries, and pretty risky to implement, too. A bug can be maximally critical.
Re:Initial preview of GUI app support for the Windows Subsys... by account42 on Thursday April 22, 2021 @04:26AM (#26900246)
> Unfortunately like a process there is no way for windows to request memory back from linux (besides killing the entire thing).

I have long thought it would make sense to add a way for the OS to ask processes to relinquish memory that they can do without. A lot of processes have memory that they use for caching which can safely be dropped but doing so when the memory is not needed elsewhere unnecessarily limits performance.

Re:Initial preview of GUI app support for the Windows Subsys... by psd1 on Sunday April 25, 2021 @07:00AM (#26931834)
That would require the application to support it. Like, "got anything you can dealloc?" "Oh shoot, now you mention it..."

What exists already in the Windows VMM, and I assume other OSes VMMs, is a distinction between allocated and committed. That's likely to be the best that's realistically achievable. The win VMM also has a last-accessed strategy for paging to disk, and de-duplication of shared pages.

Re:Initial preview of GUI app support for the Windows Subsys... by ROARosen on Wednesday April 21, 2021 @04:04PM (#26894715)
Did you try setting a RAM limit in .wslconfig ?

https://docs.microsoft.com/en-us/windows/wsl/wsl-config#conf...

Re:Initial preview of GUI app support for the Windows Subsys... by siproprio on Wednesday April 21, 2021 @02:50PM (#26893896)
Also, looking forward for that new gvim 8GB memory footprint new feature!
Re:Initial preview of GUI app support for the Windows Subsys... by gfiorav on Wednesday April 21, 2021 @02:52PM (#26893936)
Are you sure? I watched the conference and this uses the RDP framework behind the scenes, integrating with Wayland. Why would it consume much more than running natively?
Re:Initial preview of GUI app support for the Windows Subsys... by TingPing on Wednesday April 21, 2021 @07:54PM (#26896912)
Its not the gui part, its just a full VM.
Re:Initial preview of GUI app support for the Windows Subsys... by gfiorav on Wednesday April 21, 2021 @08:36PM (#26897239)
Oh, I use WSL2 every day and that's not true. I uses dynamic memory and shares with the host. No blocked off 8GB or RAM or anything like that.
Re:Initial preview of GUI app support for the Windows Subsys... by donkarma on Wednesday April 21, 2021 @03:51PM (#26894545)
wsl2 is such a downgrade from wsl1
Re:Initial preview of GUI app support for the Windows Subsys... by kuroguro on Wednesday April 21, 2021 @04:38PM (#26895131)
+1 If I wanted a VM, I would run a VM. Looks like this is WSL2 only :/
Re:Initial preview of GUI app support for the Windows Subsys... by bitwize on Wednesday April 21, 2021 @05:26PM (#26895643)
If you want a GUI in WSL1, VcXsrv still works.
Re:Initial preview of GUI app support for the Windows Subsys... by dxxvi on Wednesday April 21, 2021 @07:16PM (#26896579)
It's not perfect: I run IntelliJ in Arch WSL1 and 1) it crashes every time it opens a .md file athough I have (LIBGL_ALWAYS_INDIRECT=1). I have to put -Dsun.java2d.opengl=false -Dsun.java2d.d3d=false in idea64.vmoptions and disable the markdown plugin (maybe only 1 of them is enough) 2) In Windows, IntelliJ automatically saves files when it loses focus. I have to remember to Ctrl-S all the times with IntelliJ in WSL1 3) IntelliJ can't detect where there's a change in the file system. I have to Reload All from Disk all the times.
Re:Initial preview of GUI app support for the Windows Subsys... by xbar on Wednesday April 21, 2021 @06:21PM (#26896168)
First I've heard this. I've used neither. What is the major harm of WSL2?
Re:Initial preview of GUI app support for the Windows Subsys... by josalhor on Wednesday April 21, 2021 @07:46PM (#26896836)
At least for me, WSL1 had pretty good performance on the Windows file system. On WSL2 accessing the Windows file system is pretty slow.

You can read about it here: https://github.com/microsoft/WSL/issues/4197

Re:Initial preview of GUI app support for the Windows Subsys... by TingPing on Wednesday April 21, 2021 @07:55PM (#26896922)
But compute in general performs better and all non-windows io is way faster.
Re:Initial preview of GUI app support for the Windows Subsys... by tadfisher on Wednesday April 21, 2021 @11:55PM (#26898564)
WSL2 essentially invalidates one of the primary design criteria of the NT kernel, which is that the kernel itself should be able to service any number of "personalities" to provide userspace compatibility with other operating systems.

In practice, this turns out to have meant DOS, OS/2, and a barebones POSIX workalike. Modern Linux is too huge and provides useful APIs that go against the grain of modern NT, so applications are slow in WSL1 and there are too many impedance mismatches to paper over to make the investment worth the effort.

Re:Initial preview of GUI app support for the Windows Subsys... by josalhor on Wednesday April 21, 2021 @08:06PM (#26896999)
Sure, but I upload my experiments to a Linux cluster and only use my machine for development. Windows IO performance is more important to me than compute.
Re:Initial preview of GUI app support for the Windows Subsys... by HideousKojima on Wednesday April 21, 2021 @04:52PM (#26895292)
That's been going on for a few months already, I have a single Docker image running in WSL2 running SQL Server and it's using 5 GB of memory while idle.
Re:Initial preview of GUI app support for the Windows Subsys... by lunfard00 on Wednesday April 21, 2021 @07:19PM (#26896599)
Maybe unrelated but I think it is a Hyper-v (w10) issue, not a WSL one. At least same thing happened to me some days ago on one VM running on Hyper-v, it went crazy and consume all my 32gb of ram. It seems to be fixed after reducing the number of cores available to it.
Re:Initial preview of GUI app support for the Windows Subsys... by whywhywhywhy on Wednesday April 21, 2021 @03:04PM (#26894053)
Maybe it's what it's doing for me but I run it for days at a time and it's only taking 2GB.
Re:Initial preview of GUI app support for the Windows Subsys... by segmondy on Wednesday April 21, 2021 @06:12PM (#26896090)
I'm curious why the parent comment doesn't have an upvote or downvote button.
Re:Initial preview of GUI app support for the Windows Subsys... by sangnoir on Thursday April 22, 2021 @01:19AM (#26899030)
It was probably in a cool-off period. HN has a bunch of anti-flamewar features that temporarily discourage voting under specific circumstances.
Re:Initial preview of GUI app support for the Windows Subsys... by dleslie on Thursday April 22, 2021 @12:15AM (#26898663)
At least the WSL apps share resources.
Re:Initial preview of GUI app support for the Windows Subsys... by 1_player on Wednesday April 21, 2021 @06:26PM (#26896230)

    PS C:\Users\1_player> cat .\.wslconfig
    [wsl2]
    memory=32GB
Eh, who cares.
Re:Initial preview of GUI app support for the Windows Subsys... by siproprio on Wednesday April 21, 2021 @09:23PM (#26897563)
I'll gladly accept your machine as a gift to me!

Btw, notebooks have soldiered ram.

Re:Initial preview of GUI app support for the Windows Subsys... by danieldk on Thursday April 22, 2021 @03:24AM (#26899794)
Not all notebooks. I updated my ThinkPad from 16GB to 32GB RAM.
Re:Initial preview of GUI app support for the Windows Subsys... by NicoJuicy on Wednesday April 21, 2021 @02:53PM (#26893940)
It's not exactly wsl is it? Linux considers free memory useless and uses it as cache.

https://www.linuxatemyram.com/

Weird that i didn't knew this. Couple of years ago i wasted some time to get more "free" memory on my server. Lol

Re:Initial preview of GUI app support for the Windows Subsys... by Ajedi32 on Wednesday April 21, 2021 @04:25PM (#26894981)
That's not really an issue under normal usage; unused memory _is_ useless. The problem is that in this case Linux has to share memory with another OS.
Re:Initial preview of GUI app support for the Windows Subsys... by Dylan16807 on Wednesday April 21, 2021 @03:32PM (#26894358)
Except that the cache needs to be intelligently shared or split between operating systems, and it's not. Or at least not well, as of 20H2.