Commit graph

885 commits

Author SHA1 Message Date
Théo Lebrun
5420995681 utils: rename index-repository to index
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
9b0f4b7c31 utils/index-repository: refactor by creating project_index() function
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
c6ae14e5cd utils/index-repository: refactor by creating project_fetch() function
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
2250ef321b utils/index-repository: refactor by creating project_add_remote() function
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
d8ce24d244 utils/index-repository: refactor by creating project_init() function
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
a58e8b55bd utils/*: delete common.sh and inline $ELIXIR_THREADS fallback
$ELIXIR_THREADS fallback to nproc is straight forward code, much more
than the incantation to find the path to the Elixir install path.
Remove the incantation and replace by simple code:

    if test -z "$ELIXIR_THREADS"; then
        ELIXIR_THREADS="$(nproc)"
    fi

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
9d90b07201 utils/index-repository: support calling on existing repository
Make utils/index-repository idempotent, meaning we can call it multiple
times on the same repo and same remotes without issues.

Also allow adding new remotes to an existing repo.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
a34a6c692a utils/index-repository: add alias for git -C ...
Simplify the script. We never `cd` into the directory, we instead use
`git -C`. Avoid repeating it by creating a $git variable.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
a4b8cb4c02 utils/update-elixir-data: fetch in parallel
This is pretty useful as update-elixir-data gets called often to check
for new updates. Most often, there are none, so checking all remotes at
the same time is useful. This only applies to the kernel, that is the
only project using multiple (three) remotes.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
50ef3cd46d utils/index-repository: fetch in parallel
Previous sequence:
 - git clone ...               # first fetch
 - git remote add remote0 ...
 - git fetch remote0           # second fetch
 - git remote add remote1 ...
 - git fetch remote1           # third fetch

Now:
 - git init
 - git remote add remote0 ...
 - git remote add remote1 ...
 - git remote add remote2 ...
 - git fetch --all -j4         # all fetches at the same time

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
420581700e gitignore: add .envrc files from Direnv
https://direnv.net/

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:26:07 +01:00
Théo Lebrun
ad558b04c8 static: robots.txt: change Crawl-Delay from 1s to 2s
Recently crawlers have risen back up to high levels.
Let's ask them nicely to calm down.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-14 10:49:51 +01:00
Thomas Petazzoni
ede73902cd Update training course messages
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2025-01-14 10:43:00 +01:00
Théo Lebrun
7fbf9ec9e6 static: robots.txt: change Crawl-Delay from 5s to 1s
Crawl-Delay does have a big impact on the loadavg of the server,
meaning:
 - (1) most requests are from crawlers and,
 - (2) most crawlers listen to Crawl-Delay.

The prod server can handle the current loadavg just fine, let's let them
up their game.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-09 10:48:14 +01:00
Théo Lebrun
56156027f1 py: query: avoid assert triggering on None family
lib.getFileFamily() returns None for many files. Our assert to ensure
the family is valid should only be done once we have checked the family
is NOT None.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-06 15:16:18 +01:00
Théo Lebrun
6c9decb84b docker: apache-config: add favicon.ico
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-06 15:10:52 +01:00
Franciszek Stachura
a51430a2e9 apache: Add robots.txt to apache docker setup 2025-01-06 15:06:16 +01:00
Théo Lebrun
644a35b4c5 treewide: add guardrails to ensure definitions are cached
Add a list (CACHED_DEFINITIONS_FAMILIES) that tells us which families
have their definitions cached. We use that to assert at DB.__init__()
and q.query('file') that everything is working as expected.

If someone modifies lib.getFileFamily() for example, we'll get an
explicit warning that we should add a definitions cache to that new
family.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-03 12:23:15 +01:00
Théo Lebrun
412bb85940 docker: Apache config: set WSGI restart-interval to 12 hours
By default it never restarts. It is a good idea to avoid leaks across
weeks of a Python process running.

Also remove useless comment about processes value (16 is probably higher
than CPU count and will be fine).

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-03 12:08:29 +01:00
Théo Lebrun
c6bc09ed10 script/query: don't restrict ./script.sh get-latest to a single tag
`./script.sh get-latest <offset>` gets the full list of tags, filters
it, sorts it then returns a single result. On the Python side, it gets
the first one. If that works, it uses it, else it tries the second one,
etc.

That is a weird implementation: modify get-latest to return all tags so
that Python code only has to spawn a single subprocess.

Also, rename it from `get-latest` to `get-latest-tags`. This makes
things more explicit (what latest?) and also explicits that more than
one tag is required.

Also, argument 1 is supposed to be an offset.
No custom implementation of get_latest() did implement that.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-03 11:44:22 +01:00
Théo Lebrun
972fdd73e1 js: remove 301 redirect cache fix
This code was required because we messed-up in the past regarding
caching headers. This is not required anymore because the caching set
has expired, so no well behaving user-agent should have remains.

This represents something like 240k requests to the backend (not the
cache) over two weeks. Server load was minimal because generating those
responses is really fast.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-03 11:33:30 +01:00
Théo Lebrun
9033e80fb2 Dockerfile: set processes to 16 (convenient for prod server)
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-12-25 10:50:50 +01:00
Théo Lebrun
d24114b0fe Dockerfile: add WSGIApplicationGroup %{GLOBAL} for C libraries
Apparently we might need this for some C code extensions:

> Forcing a WSGI application to run within the first interpreter can be
> necessary when a third party C extension module for Python has used
> the simplified threading API for manipulation of the Python GIL and
> thus will not run correctly within any additional sub interpreters
> created by Python.

https://www.modwsgi.org/en/latest/configuration-directives/WSGIApplicationGroup.html

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-12-25 10:31:20 +01:00
Théo Lebrun
05f7ad4f6b data: add definitions-cache-[FAMILY].db databases
Lookup if a definition exists is taking too long to render source code.
Generate small databases that only tell us if a definition exists for a
given family. Because the database is much smaller, it is faster to
query.

Many URLs could only be queried at 12 req/s. With that patch, I can do
>80 req/s on the same URLs, with the same config.

We generate the caches from update.py. We also add an edge-case to
generate the files (if they don't exist) even if no new tag exists.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-12-25 03:55:22 +01:00
Théo Lebrun
1f5f16d5b8 data: support calling get() on a non-existent key, by returning None
This behavior isn't used at the moment, but is much more sensible that
the past that was to give None to whatever content-type lambda we had
(eg DefList that would call split on the None).

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-12-25 03:50:16 +01:00
Théo Lebrun
9cd1b140d2 Dockerfile: add virtualenv to $PATH by default
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-12-25 03:48:53 +01:00
Théo Lebrun
38c258c0ef Dockerfile: copy requirements.txt early to reduce iteration time
Before, we copied all source files at the start of the Dockerfile; that
meant we always rebuilt most steps. Only copy requirements.txt first,
then copy the rest after many steps.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-12-25 03:48:33 +01:00
Théo Lebrun
9c387e4835 docker: add gitconfig to mark all safe directories
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-12-24 16:05:17 +01:00
Théo Lebrun
24e11d2749 docker: set WSGI processes=8 threads=1
Benchmarks tell us throughput increases linearly with processes count.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-12-24 16:05:03 +01:00
Thomas Petazzoni
ec9d0b6538 Update with upcoming training courses
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2024-12-20 17:24:35 +01:00
Thomas Petazzoni
566da29ccd Adjust year of audio course
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2024-12-20 17:24:29 +01:00
K
3d08d50c08
README: fix formatting for venv commands 2024-12-13 18:45:24 +03:00
Théo Lebrun
7be0bfec96 static/messages.json: fix different desktop/mobile link
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-12-04 11:47:30 +01:00
Théo Lebrun
b8f71f74f8 static/messages.json: fix invalid FIXME link
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-12-04 11:47:12 +01:00
Théo Lebrun
a3e6a10b7a static/messages.json: fix unicode typo 2024-12-04 11:46:58 +01:00
Thomas Petazzoni
452fb5d352 static/messages.json: update messages for training courses
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2024-12-04 11:34:30 +01:00
Franciszek Stachura
44965fcbfa banner: Add functions for testing banner contents
See: cycleBanner
2024-12-04 11:18:53 +01:00
Franciszek Stachura
018677d1c5 banner: Add static/messages.json file listing banner texts 2024-12-04 11:18:53 +01:00
Franciszek Stachura
701d609c2a banner, js: Add dynamic message banner 2024-12-04 11:08:06 +01:00
Lukas Joisten
1a761e98d3 Dockerfile: set environment variable $ELIXIR_ROOT
Set env variable $ELIXIR_ROOT inside the Dockerfile. That is used by
utils/index-all-repositories to know where to put repo/data directories.

With that adjustment the docker setup is working as indicated in the
README.

Fix the following error:

$ docker exec -it -e PYTHONUNBUFFERED=1 elixir-container /bin/bash -c \
  'export "PATH=/usr/local/elixir/venv/bin:$PATH" ; /usr/local/elixir/utils/index-all-repositories'
Error: ELIXIR_ROOT environment variable not set
It's where Elixir data are stored
2024-12-02 18:14:27 +01:00
Nathan Wang
5fe2a8eef1
Fix docker build command in README 2024-11-23 15:07:44 -08:00
Théo Lebrun
3d81fa4e4e query: fix Query.query('latest')
It seems that now self.db.vers.exists('') returns True for some
projects, perhaps following the change from bsddb3 to berkeleydb.

Modify the logic to always call `./script.sh get-latest` at least once.

Fixes: #349

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-11-15 15:57:46 +01:00
Théo Lebrun
f7ed4e84fd js: simplify line range anchor parsing
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-11-12 10:19:00 +01:00
James Raphael Tiovalen
f2146891c9 js: Highlight line of code when start == end
Enable code highlighting when there is only 1 selected line of code.

Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com>
2024-11-12 10:18:17 +01:00
Théo Lebrun
4b3d35399d templates/header: update link to Bootlin's LinkedIn
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-11-08 18:14:34 +01:00
Franciszek Stachura
5e8eb77912 Migrate from bsddb3 to berkeleydb
Following official documentation, move away from bsddb3 to berkeleydb.
https://www.jcea.es/programacion/pybsddb.htm

Main change: key and values are now bytes and not strings.

The code diff is really simple because all operations on keys/values is
done from elixir/data.py and that works fine with both bytes and
strings (it does explicit casting).
2024-11-07 16:55:14 +01:00
Franciszek Stachura
7df3543b2a Make Query.query('exist') lookup faster by adding a filename cache
Add a cache for `exists` queries. Currently, `exists` calls `git
ls-tree` and parses the result to check if a file exists. A single
call takes around 20-30 ms.

It only gets used by Makefile filters. Large Makefiles cause a filter to
make hundreds of these calls, causing filter processing to take
seconds.

Statistics on 20 HTTP requests on /linux/v6.11.6/source/MAINTAINERS:

                 without:     with:
    avg            1160        843
    median          951        790
    75th perc      1289        861
    95th perc      2452       1078
    max            2874       1749

The cache is stored inside Query, of which there is one instance per
request. We do not risk cache invalidation issues.

About memory usage: on Linux v6.9.4, the cache is 12MB.
2024-11-07 16:43:37 +01:00
Franciszek Stachura
81a1116013 web: increment ?v= range link state fixes 2024-11-06 17:19:39 +01:00
Franciszek Stachura
9a09df90e9 js: Update range highlight on manual hash change 2024-11-06 17:19:11 +01:00
Franciszek Stachura
54bd3bc0a4 js: Refactor line range handling
Important changes that should make reading the diff easier:
* Script now only works on line numbers. Elements are queried when
  necessary
* handleLineRange was refactored into functions that only validate and
  return line number(s), it's now the callers responsibility to
  highlight the range
2024-11-06 17:19:11 +01:00