Commit graph

855 commits

Author SHA1 Message Date
Chris White
973d00665e find-file-doc-comments.pl: don't look for a doc comment before the file starts
Related to #232
2025-01-31 20:25:02 +01:00
Chris White
f9267417fa find-file-doc-comments.pl: die on non-existent input files [minor] 2025-01-31 20:25:02 +01:00
Franciszek Stachura
2cf83f5f7b web: Add input reset button
I tried type="reset", but it reverts to initial value that is sometimes
set by the backend, instead of actually cleraing data.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/reset
2025-01-31 20:11:53 +01:00
Franciszek Stachura
de31767f6b web: Add types 2025-01-31 19:55:56 +01:00
Théo Lebrun
1921e05ab1 gitignore: add /data/ for use as data root
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:49 +01:00
Théo Lebrun
808ed15dbc Dockerfile: add utils/ in $PATH by default, for easy indexing
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
43a0eba20a Dockerfile: set PYTHONUNBUFFERED=1 by default
This changes the stdout/stderr buffering behavior of Python. Without it,
indexing scripts don't stream updates and use really big buffers.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
7093c4ab6e Dockerfile: add virtualenv to $PATH by default
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
bb7131fafb utils/index: avoid passing argument to test(1)
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
894920a4ff utils/index: force use of bash, we depend on it for ${@:5} syntax
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
ab553d2e63 README: update following utils/* script changes
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
ebb06050aa utils/index: remove /usr/local/elixir/update.py absolute path
Instead, start from $0 and move back up two times. So, something like:

    ./elixir/utils/index
    ./elixir/utils
    ./elixir
    ./elixir/update.py

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
7f9562a13f utils/index: remove git config --system --add safe.directory call
Stop writing a global file when initializing projects. This can cause
permission issues. We instead pass the option manually for each Git
process call using:

    git -c safe.directory=...

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
d5ffe69f05 utils/index: allow indexing project with remote URLs
Previously, to start an indexing from scratch:

    ./utils/index /srv/elixir-data musl https://git.musl-libc.org/git/musl

This is annoying as the script already has the remote URLs for all known
projects. Now, a call without remote will automatically add the remote
URLs matching the project name:

    ./utils/index /srv/elixir-data musl

This copies the behavior that was previously only implemented for --all.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
0e9954b702 README: remove "Keeping git repository disk usage under control" section
New script utils/index does an automatic call to `git gc --auto` and if
it detects a gc.log file, it runs `git gc --aggressive`.

There shouldn't be any reason for people to have to think about that
aspect. Remove that info from the README and make it lighter weight.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
f17c56dc09 utils: deduplicate pack-repositories into index
utils/pack-repositories did the following on repos which have a gc.log
file existing (created when GC fails):

    git prune
    git gc --aggressive
    git prune
    git gc --aggressive

Here we:

 - Delete utils/pack-repositories; we don't want that detection to be
   done manually. Instead, we integrate the gc.log detection into
   utils/index that should be called often.

 - Create a hidden flag ($ELIXIR_GC) to allow manual trigger.

 - Replace the above sequence with a simpler `git gc --aggressive`.
   Let's trust Git.

 - Do a `git gc --auto` in the default case. This call is automatically
   done by porcelain commands but we don't run any so let's give Git an
   opportunity to cleanup from time to time (heuristic based).

 - Replace the gc.log detection from:
      find . -name gc.log
   To:
      test -e $data/$project/repo/gc.log
   It should be more reliable. With the first approach we risk projects
   that contain a file gc.log to trigger the detection on each run.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
dd4bc063b7 utils/index: add init.defaultBranch= config to git init call
Avoid the following Git warning:

hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:   git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m <name>

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
cd89e643fb utils: deduplicate utils/update-elixir-data into utils/index
Previously:

    LXR_PROJ_DIR=/srv/elixir-data ./utils/update-elixir-data

Now:

    ./utils/index /srv/elixir-data --all

The impact is slightly different: it also has the side-effect of
creating all known projects (Linux, U-Boot, etc.) if they didn't exist.
We have asked around and we are not aware of any other Elixir instance.
To keep the previous behavior, if people don't want to index all
supported projects:

    x=/srv/elixir-data
    find $x -mindepth 1 -maxdepth 1 -printf "%f\n | \
        xargs -L1 -r ./utils/index $x

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
359c76f720 utils/index: make it possible to update a specific project
Allow calling like:

    ./utils/index musl

That will do the same thing as before (fetch+index).
It works only if a previous call was made to add remotes.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
Théo Lebrun
a76c95546d utils: deduplicate index-all-repositories into index
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-31 19:27:17 +01:00
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