All Projects → vijos → Jd4

vijos / Jd4

Licence: agpl-3.0
Judging daemon for programming contests

Programming Languages

python
139335 projects - #7 most used programming language
cython
566 projects

Projects that are alternatives of or similar to Jd4

Python Microjet
Python 3 asynchronous microservices framework powered by asyncio.
Stars: ✭ 11 (-87.06%)
Mutual labels:  asyncio, daemon
Yubikeylockd
Simple daemon for locking and unlocking macOS with Yubikey
Stars: ✭ 78 (-8.24%)
Mutual labels:  daemon
Carc.in
Compile & run code in
Stars: ✭ 62 (-27.06%)
Mutual labels:  sandbox
Unjailme
A sandbox escape based on the proof-of-concept (CVE-2018-4087) by Rani Idan (Zimperium)
Stars: ✭ 73 (-14.12%)
Mutual labels:  sandbox
Junest
The lightweight Arch Linux based distro that runs upon any Linux distros without root access
Stars: ✭ 1,134 (+1234.12%)
Mutual labels:  sandbox
Git Repo Watcher
A simple bash script to watch a git repository and pull upstream changes if needed.
Stars: ✭ 73 (-14.12%)
Mutual labels:  daemon
Hproxy
hproxy - Asynchronous IP proxy pool, aims to make getting proxy as convenient as possible.(异步爬虫代理池)
Stars: ✭ 62 (-27.06%)
Mutual labels:  asyncio
Aiosip
SIP support for AsyncIO (DEPRECATED)
Stars: ✭ 83 (-2.35%)
Mutual labels:  asyncio
Python Dependency Injector
Dependency injection framework for Python
Stars: ✭ 1,203 (+1315.29%)
Mutual labels:  asyncio
Pebble
Unofficial Pebble watch support for SailfishOS/Jolla
Stars: ✭ 71 (-16.47%)
Mutual labels:  daemon
Oragono
A modern IRC server (daemon/ircd) written in Go.
Stars: ✭ 1,171 (+1277.65%)
Mutual labels:  daemon
Web develop
《Python Web开发实战》书中源码
Stars: ✭ 1,146 (+1248.24%)
Mutual labels:  asyncio
Pfun
Functional, composable, asynchronous, type-safe Python.
Stars: ✭ 75 (-11.76%)
Mutual labels:  asyncio
Skillbox Async Chat
Пример клиент-серверного чата на Python для Skillbox
Stars: ✭ 64 (-24.71%)
Mutual labels:  asyncio
Pytask Io
Python Async Task Queue
Stars: ✭ 81 (-4.71%)
Mutual labels:  asyncio
Peony Twitter
An asynchronous Twitter API client for Python 3.5+
Stars: ✭ 62 (-27.06%)
Mutual labels:  asyncio
Pyfailsafe
Simple failure handling. Failsafe implementation in Python
Stars: ✭ 70 (-17.65%)
Mutual labels:  asyncio
Pymarketcap
Python3 API wrapper and web scraper for https://coinmarketcap.com
Stars: ✭ 73 (-14.12%)
Mutual labels:  asyncio
Aiomysql
aiomysql is a library for accessing a MySQL database from the asyncio
Stars: ✭ 1,252 (+1372.94%)
Mutual labels:  asyncio
Moolticute
Mooltipass crossplatform daemon/tools
Stars: ✭ 82 (-3.53%)
Mutual labels:  daemon

Judge Daemon

.. image:: https://travis-ci.org/vijos/jd4.svg?branch=master :target: https://travis-ci.org/vijos/jd4

.. image:: https://images.microbadger.com/badges/image/vijos/jd4.svg :target: https://microbadger.com/images/vijos/jd4

.. contents::

Introduction

jd4 is a judging daemon for programming contests like OI and ACM. It is called jd4 because we had jd, jd2, jd3 before. Unlike previous versions that use Windows sandboxing techniques, jd4 uses newer sandboxing facilities that appear in Linux 4.4+. jd4 also multiplexes most I/O on an event loop so that only two extra threads are used during a judge - one for input, and one for output, thus allowing blocking custom judge implementations.

Usage

Prerequisites:

  • Linux 4.4+
  • Docker

Put config.yaml in the configuration directory, usually in $HOME/.config/jd4. Examples can be found under the examples directory. Create a directory for caching problem data, such as $HOME/.cache/jd4.

Use the following command to pull and run jd4::

docker run --privileged \
    -v ~/.config/jd4/config.yaml:/root/.config/jd4/config.yaml \
    -v ~/.cache/jd4:/root/.cache/jd4 \
    vijos/jd4

Development

Prerequisites:

  • Linux 4.4+
  • Python 3.5+

Use the following command to install Python requirements::

pip3 install -r requirements.txt

The python libraries require kernel headers and libffi-dev.

Put config.yaml and langs.yaml in the configuration directory, usually in $HOME/.config/jd4. config.yaml includes the server address, user and password and langs.yaml includes the compiler options. Examples can be found under the examples directory.

We recommend to use the following commands to initialize the config::

mkdir -p ~/.config/jd4
cp examples/config.yaml ~/.config/jd4/

  ln -sr examples/langs.yaml ~/.config/jd4/

Build the cython extensions inplace::

python3 setup.py build_ext --inplace

Use the following command to run the daemon::

python3 -m jd4.daemon

Note that this requires a sudo to create cgroups on first execution.

Playing with the sandbox

Use the following command to create and enter the sandbox::

$ python3 -m jd4.sandbox
[D 170312 15:15:38 selector_events:53] Using selector: EpollSelector
[I 170312 15:15:38 sandbox:153] sandbox_dir: /tmp/jd4.sandbox.k6ig1fv8
bunny-4.3$ ls
bin  etc  in  lib  lib64  out  proc  usr
bunny-4.3$

The in and out directory are bound to the corresponding directory in sandbox_dir, where in is read-only and out has write permission.

FAQ

How are the programs sandboxed? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We unshare everything (namely mount, uts, ipc, user, pid and net), and then create a root filesystem using tmpfs and bind mount, finally pivot_root into it. We also use cgroup to limit the time, memory and number of processes of user execution.

Why are the sandboxes reused? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We noticed that sandbox creation took around 100ms, therefore becomes the bottleneck while judging small programs. With sandbox pooling, we see 300-400 executions per second on our development machine.

Why is comparator written in Cython? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The comparator needs to process the user output by characters (in other word bytes). This kind of operation is very slow in Python. We see a 50x+ throughput increment by using Cython (like 3MB/s to 200MB/s).

Copyright and License

Copyright (c) 2017 Vijos Dev Team. All rights reserved.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].