Skip to content

Poly-ITE Olympiad in Informatics [PIOI]

PIOI is the flagship external event of Overflow. Here are some key points:

  • 4 days of workshops
  • 1 day of contest, split across two sessions
  • 4 questions, 100 points each

Registration

The kick off to PIOI starts with the registration. A registration form is prepared and is sent out by the lecturer in charge to the various polytechnics.

A few things must be kept in mind when creating the registration form:

  • Participants dietary restrictions
  • Participants emergency contacts
  • Participants existing health conditions (allergies, etc)
  • Has the participant read through and agreed to the T&Cs + Rules?

Being able to confirm these during the registration process will reduce the administrative overhead down the road.

Workshops

Historically, we provide 4 workshops, spread across 4 days. The workshop content generally remain the same, although the organizers of each iteration are encouraged to make their own enhancements and changes. Importantly, the workshops should focus on covering basics of doing competitive programming using C++. It is safe to assume that the audience have little to no knowledge of C++, or competitive programming, and the workshops should be tailored as such.

The workshops held usually cover the topics below:

  • Introductions to C++
  • Introductions to Data Structures in C++
  • Introductions to Algorithms in C++
  • Practical workshop

The practical workshop places is a sort of familiarization session for the participants. The intended goal is for them to do any preparation necessary before the actual contest day. Some of the things that could be covered include:

  • Setting up their account on the contest platform
  • Familiarizing themselves with the computers provided
  • Going through practice questions

Contest

The contest comprises of many components, including:

  • Contest platform

Contest platform

Previously, the contest platform used was Contest Management System. But it has since been replaced with DMOJ, which is a more modern and feature-rich platform.

For historical reasons, the contest platform is still referred to as the "CMS".

The preferred way of "hosting" the contest platform is using a "flat-rate" service such as DigitalOcean / Linode. Alternatively, if you're up for the adventure, using larger cloud platforms such as AWS, Google Cloud Platform, or Azure is also possible.

Generally, a firewall is not needed as the server should be put behind Cloudflare.

Below are of the observations noted between DO / Linode:

DO:

  • By default, DO applies some limitation on the total amount of VMs that can be created per account. This may cause issues during testing. You may need to contact DO support early on to increase this limit.
  • DO is generally slower than Linode.
  • Favorable compared to Linode in terms of creating snapshots.

Linode:

  • Linode can only create 1 manual snapshot per VM. The "hacky" way to get around this is to clone the VM, but the VM is also billed.

Installation

Security

Security of the platform is important to prevent unauthorized access. Please use cryptographically random passwords and SSH keys.

The easy way

Download the two .img files from SharePoint and restore them to VMs.

Link

The manual way
  1. Setup a new Debian-based VM on your cloud provider of choice:

    Name: pioi-dmoj-site

  2. Update and create non-root users

    ssh root@

    apt-get update -y && \ apt-get upgrade -y && \ adduser dmoj && \ adduser dmoj sudo && \ exit

  3. Add your SSH key, then login to the dmoj non-root user

    ssh-copy-id -i dmoj@ && \ ssh dmoj@

  4. Follow the DMOJ setup guide here

    Replace the npm install command with the following (install postcss-cli@9 instead of postcss-cli)

    npm install -g sass postcss-cli@9 postcss autoprefixer
    

    After "Creating the database tables", run the following command:

    mysql_tzinfo_to_sql /usr/share/zoneinfo/  | sudo mysql -D mysql
    

    It is recommended to create separate user accounts for the following services ran on supervisord:

    adduser dmojbridged && \
    adduser dmojcelery && \
    adduser dmojuwsgi && \
    adduser dmojwsevent
    

    The supervisord configurations are below:

    supervisord configuration files
    dmoj@localhost:~$ ls /etc/supervisor/conf.d/
    bridged.conf  celery.conf  site.conf  wsevent.conf
    
    dmoj@localhost:~$ cat /etc/supervisor/conf.d/*
    [program:bridged]
    command=/home/dmoj/dmojsite/bin/python manage.py runbridged
    directory=/home/dmoj/site
    stopsignal=INT
    # You should create a dedicated user for the bridged to run under.
    user=dmojbridged
    group=dmojbridged
    stdout_logfile=/var/log/dmoj/bridged/bridged.stdout.log
    stderr_logfile=/var/log/dmoj/bridged/bridged.stderr.log
    
    [program:celery]
    command=/home/dmoj/dmojsite/bin/celery -A dmoj_celery worker
    directory=/home/dmoj/site
    # You should create a dedicated user for celery to run under.
    user=dmojcelery
    group=dmojcelery
    stdout_logfile=/var/log/dmoj/celery/celery.stdout.log
    stderr_logfile=/var/log/dmoj/celery/celery.stderr.log
    
    [program:site]
    command=/home/dmoj/dmojsite/bin/uwsgi --ini uwsgi.ini
    directory=/home/dmoj/site
    stopsignal=QUIT
    stdout_logfile=/var/log/dmoj/uwsgi/site.stdout.log
    stderr_logfile=/var/log/dmoj/uwsgi/site.stderr.log
    
    [program:wsevent]
    command=/home/dmoj/.nvm/versions/node/v12.22.12/bin/node /home/dmoj/site/websocket/daemon.js
    environment=NODE_PATH="/home/dmoj/site/node_modules"
    # Should create a dedicated user.
    user=dmojwsevent
    group=dmojwsevent
    stdout_logfile=/var/log/dmoj/wsevent/wsevent.stdout.log
    stderr_logfile=/var/log/dmoj/wsevent/wsevent.stderr.log
    

    For the uWSGI service, the user account should be specified in the uwsgi.ini configuration file rather than the supervisord configuration file.

    The uwsgi.ini configuration file is as follows:

    uwsgi.ini
    [uwsgi]
    # Socket and pid file location/permission.
    uwsgi-socket = /tmp/dmoj-site.sock
    chmod-socket = 665
    pidfile = /tmp/dmoj-site.pid
    
    # You should create an account dedicated to running dmoj under uwsgi.
    uid = dmojuwsgi
    gid = dmojuwsgi
    
    # Paths.
    chdir = /home/dmoj/site
    pythonpath = /home/dmoj/site
    virtualenv = /home/dmoj/dmojsite
    
    # Details regarding DMOJ application.
    protocol = uwsgi
    master = true
    env = DJANGO_SETTINGS_MODULE=dmoj.settings
    module = dmoj.wsgi:application
    optimize = 1
    
    # Scaling settings. Tune as you like.
    memory-report = true
    cheaper-algo = backlog
    cheaper = 2
    cheaper-initial = 4
    cheaper-step = 0
    cheaper-rss-limit-soft = 201326591
    cheaper-rss-limit-hard = 234881023
    workers = 6
    

Last update: August 23, 2024
Created: August 23, 2024

Comments