# VS Code: choosing tasks and cores on cluster

**URL:** <https://discourse.openondemand.org/t/vs-code-choosing-tasks-and-cores-on-cluster/2619>\
**Category:** General Discussion\
**Tags:** question\
**Created:** [April 11, 2023, 7:29pm UTC](https://discourse.openondemand.org/t/vs-code-choosing-tasks-and-cores-on-cluster/2619 "2023-04-11T19:29:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RonRahaman](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ronrahaman/32/1031_2.png) [@RonRahaman](https://discourse.openondemand.org/u/RonRahaman)\
**Post date:** [April 11, 2023, 7:29pm UTC](https://discourse.openondemand.org/t/vs-code-choosing-tasks-and-cores-on-cluster/2619/1 "2023-04-11T19:29:31Z")

</div>

We’ve setup a VS Code (code-server) app on our OOD instance (big thanks to NMSU for sharing their code). When code-server is in a Slurm job, what’s a reasonable number of tasks and/or CPUs/task?

I’m aware that VS Code can spawn a lot of subprocesses, so I’m wondering if users can see some benefits with \> 1 task and/or CPU/task.

Thanks,  
Ron

---

<div class="post-metadata">

**Author:** ![travert](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/travert/32/3074_2.png) [@travert](https://discourse.openondemand.org/u/travert)\
**Post date:** [April 11, 2023, 9:18pm UTC](https://discourse.openondemand.org/t/vs-code-choosing-tasks-and-cores-on-cluster/2619/2 "2023-04-11T21:18:50Z")

</div>

Thanks for posting the question. I am not sure what you mean by “task”, but maybe that’s a Slurm thing.

Here’s the configuration we use at OSC:

> **[GitHub - OSC/bc\_osc\_codeserver: BETA - Batch Connect - OSC Code Server](https://github.com/OSC/bc_osc_codeserver)**
>
> BETA - Batch Connect - OSC Code Server. Contribute to OSC/bc\_osc\_codeserver development by creating an account on GitHub.

Ultimately, this is really going to be site dependent in my view though. Some sites will have far more users running Code server than another, and what those users are doing in code server can also effect resource usage as well. So getting a feel for you own site is probably the best advice you could get.

I would say that using 1 CPU for codeserver seems like a bad idea given how resource intense it can be. If the workload is relatively light and the cluster has many available resources, then using 2 CPUs per task would be sufficient. But, if the workload is heavier or the cluster is more limited in terms of resources, then using 4 CPUs per task might be more appropriate.

---

<div class="post-metadata">

**Author:** ![RonRahaman](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ronrahaman/32/1031_2.png) [@RonRahaman](https://discourse.openondemand.org/u/RonRahaman)\
**Post date:** [April 13, 2023, 3:58pm UTC](https://discourse.openondemand.org/t/vs-code-choosing-tasks-and-cores-on-cluster/2619/3 "2023-04-13T15:58:07Z")

</div>

In a slurm job, a task is a process. Slurm has the separate concept of CPUs/task. That’s used for a multi-threaded apps. So here’s what you would request for different kinds of program:

- Multi-process, single-threaded: m tasks, 1 cpu/task.
- Single-process, multi-threaded: 1 task, n cpu/task
- Multi-process/multi-threaded: m tasks and n cpus/task

So I’m not sure if VS Code is primarily multi-process or multi-thread. My intuition (just based on running it on my Mac with the activity montior) is that it’s spawning a bunch of single-threaded subprocesses. So I _think_ I should request multiple tasks in my slurm job, each with 1 cpu/task.

---

<div class="post-metadata">

**Author:** ![RonRahaman](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/ronrahaman/32/1031_2.png) [@RonRahaman](https://discourse.openondemand.org/u/RonRahaman)\
**Post date:** [April 14, 2023, 3:11pm UTC](https://discourse.openondemand.org/t/vs-code-choosing-tasks-and-cores-on-cluster/2619/4 "2023-04-14T15:11:50Z")

</div>

I did some really quick-and-dirty profiling in the slurm job. It looks like requesting multiple tasks (`--ntasks=whatever`) and 1 CPU/task (`--cpus-per-task=1`) gives appropriate CPU utilization. In the job, there are bunch of subprocesses spawned by `code-server`. There are \<= `ntasks` cores active, with the subprocesses context-switching in and out.
