Commit graph

812 commits

Author SHA1 Message Date
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
Franciszek Stachura
558f75e3f5 web: Parse range state from URL
Fixes #329
2024-11-06 17:19:11 +01:00
Franciszek Stachura
6b47af27a7 README, Dockerfile: Update to support version in footer 2024-11-06 17:18:07 +01:00
Franciszek Stachura
305395e8e9 web: Link to current commit from the footer 2024-11-06 17:18:07 +01:00
Franciszek Stachura
cb28f73dbc web: Display Elixir commit hash in footer 2024-11-06 17:18:07 +01:00
Louis Chauvet
18376d3f7b web: Display documentation before other things
The current order for displaying references is:

- [definitions] prototype, label, typedef, variable, struct, member,
  function
- documentation
- references

This order is not very practical when you are searching for information
about a symbol, as you often want to know if the symbol is documented.

By inverting the order and displaying the documentation first, the user
experience may be improved for finding the documentation. This should not
significantly change the UX for definitions, as there are already many
definitions, and you already have to search for what you want.
2024-11-06 17:17:00 +01:00
Théo Lebrun
a776fff7ae static/style.css: update normalize.css from v7.0.0 to v8.0.1
Project homepage:
https://necolas.github.io/normalize.css/

Changelog:
https://github.com/necolas/normalize.css/blob/master/CHANGELOG.md

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-11-06 15:33:13 +01:00
Théo Lebrun
41de913669 templates/layout.html: add preload links for CSS resources
Tell to browsers the resources we will need, as soon as possible. This
means they do not need to fully download our CSS to know what they
should load next.

For some reason, crossorigin is required on fonts to avoid them being
loaded twice by Firefox.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-11-06 15:06:11 +01:00
Théo Lebrun
6356cdc3c7 static: embed all CSS files into /static/style.css
Avoid many tiny requests. The issue is that browsers have a limited
amount of concurrent requests they can make. We do 19 for
loading /linux/v6.11.6/source. Reduce that to 14.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-11-06 15:00:41 +01:00
Théo Lebrun
d06c760b2a web: add handler for '/' URL
Previously, the web server was responsible for redirecting '/' to a
sensible URL. Most likely, the target URL was '/linux/latest/source'.
From there on, web did the redirect to the proper version.

Avoid a redirect by handling '/' directly from our application to the
correct version.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-11-06 14:25:24 +01:00
Franciszek Stachura
4779965e0f Fix styles for latest version of Pygments
Pygments 2.12.0 slightly changed the order of HTML elements which
makes line numbers look weird with current CSS styles.

Quoting changelog:
> When linenos=table is used, the <table> itself is now wrapped
> with a <div class="highlight"> tag instead of placing it
> inside the <td class="code"> cell (#632.) With this change,
> the output matches the documented behavior.

https://pygments.org/docs/changelog/#version-2-12-0
Related issue: https://github.com/pygments/pygments/issues/632

This commit aims to fix this by further restricting CSS selectors
that selected everything under .highlight to only select source code
related elements - descendants of .code in the new layout.

This was also tested on Pygemnts 2.14.0, version currently packaged
for Debian Bookworm
https://packages.debian.org/bookworm/armel/python3-pygments
2024-11-05 23:20:51 +01:00
Franciszek Stachura
1762568c85 web: Meta descriptions improvements
* Make source tree descriptions shorter
* Make default title more descriptive
* Add a short summary of results to ident search description
2024-11-05 12:20:02 +01:00
Franciszek Stachura
3f6aa021a7 Improve tests
* Run pytest only for t, do not run tests for other libraries
* Add email and name git options to test repo init
* Change test repo permissions to avoid "dubious ownership" error
2024-11-05 12:20:02 +01:00
Théo Lebrun
c54a4c3dec data.py: simplify BsdDB.__init__() flags code logic
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-10-11 14:37:39 +02:00
Franciszek Stachura
0b8d735641 update: Make database usage thread safe
Current update script serializes database access using mutexes.
According to a user of Oracle support forums, this is not enough.

https://forums.oracle.com/ords/apexds/post/berkeley-db-file-corrupted-while-operating-for-hours-panic-4953
> if you are accessing the same database from multiple threads or
> multiple processes, they must share a cache (memory pool). In other
> words, it is not sufficient to just make sure no DB->put or DB->get
> operations are run simultaneously as you do with mutexes. Berkeley
> DB also maintains information about database files across calls in
> the cache, such as the list of free pages. If two threads accessing
> a database file have independent freelists, they will eventually
> both try to allocate the same page for different purposes, and the
> structure of the file will be compromised.

DB.open provides a flag that should be specified if database is to be
shared between threads

https://docs.oracle.com/cd/E17276_01/html/api_reference/C/dbopen.html

> DB_THREAD
> Cause the DB handle returned by DB->open() to be free-threaded; that
> is, concurrently usable by multiple threads in the address space.
> You should use this flag only in the absence of an encompassing
> environment.

While this probably won't solve all database concurrency issues (web
accessing the database during updates likely still will behave weird)
it could help with recent database corruption issues.

https://docs.oracle.com/cd/E17276_01/html/programmer_reference/program_mt.html

> The DB_THREAD flag must be specified to the DB_ENV->open() and
> DB->open() methods if the Berkeley DB handles returned by those
> interfaces will be used in the context of more than one thread.
> Setting the DB_THREAD flag inconsistently may result in database
> corruption.

> When using the non-cursor Berkeley DB calls to retrieve key/data
> items (for example, DB->get()), the memory to which the pointer
> stored into the Dbt refers is valid only until the next call using
> the DB handle returned by DB->open(). This includes any use of the
> returned DB handle, including by another thread within the process.
>
> For this reason, if the DB_THREAD handle was specified to the
> DB->open() method, either DB_DBT_MALLOC, DB_DBT_REALLOC or
> DB_DBT_USERMEM must be specified in the DBT when performing any
> non-cursor key or data retrieval.

It seems that bsddb3 sets appropriate flags in DBTs for us if DB_THREAD
is specified.

https://hg.jcea.es/pybsddb/file/tip/src/Module/berkeleydb.c#l2025

(ctrl+f for DB_THREAD)

I believe DBTs used in DB_put shouldn't require any extra flags because
the DBTs are only read by Berkeley DB (doesn't matter if they get
invalidated on the next call).
2024-10-11 11:44:45 +02:00
Théo Lebrun
55921f1957 utils/index-repository: support multiple remote URLs
Linux is the only currently supported project for which we want three
remote URLs; see index-all-repositories for the list.

We could optimise the fetching by doing a single fetch call to all
remotes at the same time using --jobs (or fetch.parallel config).

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-10-02 10:48:03 +02:00
Théo Lebrun
06d503e3d9 utils/index-repository: if $ELIXIR_THREADS is not passed, use nproc
Follow behavior of utils/index-all-repositories.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-10-01 16:31:07 +02:00
Théo Lebrun
905e6ef657 utils/index-repository: pass $ELIXIR_THREADS to update.py
Follow behavior of utils/index-all-repositories.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-10-01 16:27:10 +02:00
Théo Lebrun
1853abe7f9 README: fix docker image instructions
Two issues are fixed:

 - Initial `docker build` instructions fail because the Dockerfile path
   is wrong (elixir/Dockerfile versus elixir/docker/Dockerfile).

 - Indexing instructions are wrong because they do not use the
   virtualenv Python. It contains the installed packages, which we need
   for indexing. Issue appears as:

      ModuleNotFoundError: No module named 'bsddb3' (edited)

We also remove some common Docker knowledge (why we might want the
database to be coming from a mounted volume, rather than stored inside
the container).

Finally, we fix line widths but splitting commands into multiple lines.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-10-01 16:03:24 +02:00
Franciszek Stachura
426fff2dc5 web: Fix identifier unquoting
to make DT compatibles work again...
2024-09-30 14:14:13 +02:00
Théo Lebrun
4aac8fc8dc web: error page: make Github issue TODO message more straight forward
We reword the TODO message. We put two newlines before and after the
triple dashes to avoid Markdown title formatting.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-09-30 12:22:42 +02:00
Franciszek Stachura
46254c4a90 web: Add error details for bug reports 2024-09-30 12:00:53 +02:00
Franciszek Stachura
76d13c9193 web: Make GET /ident redirect to /source
Now making a GET to /project/version/ident will redirect to
/project/version/source.
Refreshing a page after making a request for an empty identifier won't
show 405 Method Not Allowed anymore.
2024-09-30 12:00:53 +02:00
Franciszek Stachura
5aca2d51e5 web: Improve error page
Add some useful links, including a link to a pre-filled bug report form
2024-09-30 12:00:53 +02:00