Comments (6)
I tried both of those on two different machines (archlinux and ubuntu 16.10 x86_64) multiple times and I can't reproduce your result at all. Do you get similar differences in user time? Can you compute the average wall time of 1000 runs, for instance?
from isolate.
User time is always 0.00. Wall time average is computed with this script, isolate.sh
:
sumt1=0
sumt2=0
for ((i=1; i<=$ITERATIONS; i++)); do
isolate --init >/dev/null
/usr/bin/time -f %e -o /tmp/time1 isolate --run -- /usr/bin/echo 1 >/dev/null 2>/dev/null
isolate --cleanup >/dev/null
isolate --init >/dev/null
/usr/bin/time -f %e -o /tmp/time2 isolate --run -- /usr/bin/echo 2 >/dev/null 2>/dev/null
isolate --cleanup >/dev/null
sumt1=$(echo $sumt1 + $(cat /tmp/time1) | bc)
sumt2=$(echo $sumt2 + $(cat /tmp/time2) | bc)
sleep $SLEEPTIME
done
echo sumt1 = $sumt1, sumt2 = $sumt2
On the first machine:
$ sudo env ITERATIONS=1000 SLEEPTIME=0.1 bash isolate.sh
sumt1 = 43.54, sumt2 = 99.61
On the second machine:
johnchen902@johnchen902 ~> sudo env ITERATIONS=100 SLEEPTIME=1 bash isolate.sh
sumt1 = 4.34, sumt2 = 84.86
from isolate.
Seems like kernel just spent that much time tearing down namespaces before the child can be reaped, as demostrated by timing the following code and toggling the comments.
#define _GNU_SOURCE
#include <fcntl.h>
#include <sched.h>
#include <signal.h>
#include <sys/wait.h>
#include <unistd.h>
#define CHILD_STACK_SIZE (1 << 23)
static int fd[2];
static int child_main(void *param) { (void) param;
// close(fd[1]);
// execl("/usr/bin/true", "/usr/bin/true", NULL);
return 0;
}
int main() {
static int child_stack[CHILD_STACK_SIZE];
int flags = SIGCHLD | CLONE_NEWCGROUP | CLONE_NEWIPC | CLONE_NEWNET
| CLONE_NEWNS | CLONE_NEWPID | CLONE_NEWUTS ;
pipe2(fd, O_CLOEXEC);
clone(child_main, child_stack + CHILD_STACK_SIZE, flags, NULL);
close(fd[1]);
// char buf[1]; read(fd[0], buf, 1);
// wait(NULL);
}
A special "init" program in the namespace may serve as a workaround, because we need not to wait for the init to die.
from isolate.
This is definitely a kernel issue. I do not think it matters much as average execution times in most contests are significantly higher than this delay, but if anybody feels it does matter, please reopen this issue and we shall investigate further.
from isolate.
When I opened this issue, it did matter because I want to run 20 tasks concurrently on the 0.8s machine (with >20 cores), and it is observed that such overhead cannot be parallelized.
Later I decided to roll my solution, which avoids destroying and recreating namespaces. As I no longer use isolate at all, it doesn't matter to me now.
from isolate.
See further discussion and proposed workaround in issue #34.
from isolate.
Related Issues (20)
- cg2 version fails if memory.swap.max does not exist HOT 7
- I also encountered the same issue. This worked for me:
- Getting Resource temporarily unavailable error while compiling C program HOT 3
- Is this possible? HOT 13
- cg2: `cf_cg_root` points to junk after `clone()` on Fedora HOT 2
- Unable to access internet inside isolate box even after using --share-net HOT 4
- "No such file or directory" issue when trying to run C# program using Dotnet HOT 7
- Memory corruption bug in cg_init HOT 2
- C# program failed to compile using mcs - error CS2001: Source file `Main.cs' could not be found HOT 1
- make install exited with error code 1. HOT 1
- Error Running isolate in Ubuntu:22.04 with Systemd HOT 10
- Support for Docker HOT 12
- Error using isolate HOT 15
- Assertion Failure Issue HOT 4
- --as-uid and --as-gid seem to be not usable in Docker container HOT 3
- Cannot set disk quota: No such process HOT 1
- chown: cannot access /var/local/lib/isolate/XX/box': No such file or directory HOT 6
- CPU time (--time) consumed in subsequent runs in the same box with cg (cgroup2) enabled HOT 9
- Limitation on number of sandboxes HOT 1
- [Query] Isolate Mac OS setup HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from isolate.