Commit graph

56 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
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
Franciszek Stachura
9e18f26aeb Restructure Elixir to avoid Python path hacks
* Move static files from http to a new directory
2024-08-27 11:33:18 +02:00
Michael Opdenacker
a8581e5fd4 Revert "update.py: simplify and optimize thread management"
This gave suboptimal results in terms of indexing time,
plus a stuck job. Should be investigated further before
changing this.

This reverts commit e1dd2b4881.
2023-05-08 07:18:31 +02:00
Michael Opdenacker
e1dd2b4881 update.py: simplify and optimize thread management
Instead of having a complicated thread count scheme and
ending up wasting time waiting for the docs task to finish
with a too low thread count at the end, let's run all
tasks with same number of threads, which by default
is the number of CPUs in the system.

This way, the indexing work always uses as many CPUs
as possible, especially when same tasks are finished
before the others.

The OS shouldn't bother if we try to run more threads
than the actual number of CPUs.

Set the ELIXIR_THREADS environment variable
if you want to use a lower number of threads,
typically on a desktop machine on which you want some
responsiveness.

Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2023-05-05 15:50:43 +02:00
Ziyue Pan
7c4886cf3c Style: fix redundant parentheses and typos
(cherry picked from commit cd89684ce633c4997b328395cc882de3ab655475)
2023-03-23 09:54:14 +01:00
Maxime Chretien (MixLeNain)
763e4fd1aa update.py: use a constant for the key modifier of defs_idxes
As Chris White said it, it's better to have only one line to change if
we have to update that value.

Signed-off-by: Maxime Chretien (MixLeNain) <mchretien@linuxmail.org>
2020-12-07 14:19:44 +01:00
Maxime Chretien (MixLeNain)
c7f427b672 update.py: Filter defs when indexing refs
Signed-off-by: Maxime Chretien (MixLeNain) <mchretien@linuxmail.org>
2020-12-07 12:02:26 +01:00
Riccardo Magliocchetti
681e6ca31f update: silence assigned but never use warnings
As spotted by pyflakes
2020-10-21 08:47:36 +02:00
Riccardo Magliocchetti
016d848b38 update: remove unused imports 2020-10-20 21:29:16 +02:00
Michael Opdenacker
c04e9e3065 Remove trailing ";"
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2020-08-18 12:01:56 +02:00
Maxime Chretien
603db9e55b Index CONFIG_ references in makefiles
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-12 16:04:34 +02:00
Maxime Chretien
5c91812449 update.py: Fix vers indexing problem and add more messages
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-12 12:06:17 +02:00
Maxime Chretien
a05f4972bc update.py: Use lib.isIdent while parsing definitions
If an ident is in db.defs it's already a valid ident.
So we need to test the idents with lib.isIdent before adding an ident in
db.defs and not while parsing references.

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-11 10:02:04 +02:00
Maxime Chretien
c555bf4338 defs: Add family once we are sure that the element is added in the db
This prevent wrong entries in the database

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-11 09:53:06 +02:00
Maxime Chretien
32c5c19b97 update.py: Results from FindCompatiblesDTS are not encoded
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-10 10:34:41 +02:00
Maxime Chretien
e2adc03d1e find_compatibles_dts: Convert to a python class to increase performances
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-10 10:16:19 +02:00
Maxime Chretien
9c45c0fae1 update.py: Exit if there is no tag to add
This prevent the script from locking at line 578 because UpdateIds will never send an event to wake up the threads (line 91) if there is no tag to add.

Also change len(tag_buf) to num_tags in line 548, no need to compute the
length again as we already have it.

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-09 09:16:24 +02:00
Maxime Chretien
a77845c55c update.py: UpdateCompsDocs rely on UpdateVersions
Also fix some typos

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-08 15:37:59 +02:00
Maxime Chretien
bd93e4da67 update.py: Simplify threads handling
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-08 15:37:59 +02:00
Maxime Chretien
1bd4cd464a update.py: Split updateComps in two threads
One thread that parse C and DT files and one that parse Documentations
files

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-08 15:37:59 +02:00
Maxime Chretien
6e2a37fef9 update.py: Update versions file tree in a separate thread
We don't need multiple threads for that as it is significantly faster
than defs, refs, docs and comps

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-08 15:37:59 +02:00
Maxime Chretien
76c68265d3 DT compatibles : Add a separate database for documentation
Idxes needs to be sorted in RefLists but documentation idxes are lower
than others and we added them latter in the RefList so there was a
problem. The easiest solution to solve that is to create a separate
database for documentations.

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-08 15:37:59 +02:00
Maxime Chretien
6bb9d5f848 update.py: Improve comps database
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-08 15:37:59 +02:00
Maxime Chretien
71e469f9af update.py: fix some typos
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-08 15:37:59 +02:00
Maxime Chretien
4a8c99b7e5 database: Enable db.comps only when needed
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-08 15:37:59 +02:00
Maxime Chretien
81fa361c54 database: Add support for dts compatible strings
They can be found in C, DTS and documentation files

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-08 15:37:59 +02:00
Maxime Chretien
455b5b6766 update.py: fix import mistake
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-03 10:27:28 +02:00
Maxime Chretien
b92556655c update.py: Update copyright notice
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-03 10:18:46 +02:00
Maxime Chretien
8b29bccfb3 update.py: Pass number of threads as a cmdline argument
The threads are then distributed among the functions using a specific
rule (see code comments)

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-03 10:06:58 +02:00
Maxime Chretien
c72f5292ef update.py : Improve flexibility and use 4 threads for refs
It's now easier to change the number of threads for each functions

Refs are always what remains at the end so more threads will be helpfull
to finish faster

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-02 13:46:03 +02:00
Maxime Chretien
9ff3cff564 update.py: Use 7 threads and reduce locking
Use 7 threads to do more things at once and spread the load
Lock file before the loop so we don't lock and unlock all the time

This will hopefully reduce database creation time

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-02 13:46:03 +02:00
Chris White
5e7cab18ca Added/updated copyright notices; whitespace fixes
No functional changes
2020-05-23 15:14:21 -04:00
Maxime Chretien
72571fbfd9 database: Add support for Kconfig et Devicetree files
This brings the idea of file families, each ident is identified by his
family and can be referenced in compatible families.

For exemple :
- A Kconfig ident can be referenced in a C file but not in a Devicetree file.
- A Devicetree ident is only referenced in Devicetree files.
- A C ident is only referenced in C files.

Kconfig idents are defined without the CONFIG_ at the beginning.
We add it while indexing for an easier processing of other files.

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-05-22 10:29:24 +02:00
Maxime Chretien
bdcb386626 update.py: Use 4 threads to speed up indexation
This allows to index multiple things at the same time so it speeds up
database indexation.

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-05-22 10:29:24 +02:00
Michael Opdenacker
893c4aabdb update.py: fix syntax issues (typical "C-isms")
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2020-04-06 17:21:30 +02:00
Christopher White
8a6031c8a1 Add doc-comment extraction
- find-file-doc-comments.pl: new file
- data.py: Add database to store doc-comment locations
- script.sh: Add parse-docs subcommand
- update.py:
  - Add code to process doc comments
  - Update some variable names in hopes of reducing confusion
- query.py:
  - Add code to report doc comments
  - Update some variable names in hopes of reducing confusion

Also:
- t/TestEnvironment.pm: Add find_doc attribute
- t/interact.pl: Don't die if update.py fails
- t/TestHelpers.pm: Permit checking specific sections of query.py output
- t/300: update regexes per the preceding
- gitignore tags (ctags output) and .cache (api_test.py output)
2020-04-02 13:03:03 -04:00
Michael Opdenacker
51a6dff682 Python parentheses coding style fixes
- According to https://www.python.org/dev/peps/pep-0008/

Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2019-12-01 07:01:26 +01:00
Michael Opdenacker
453e8a127c Factorize the definition of supported extensions
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2019-10-08 07:33:36 +02:00
Michael Opdenacker
f2b40c5f7e update.py: fix division by zero in progress report
- Required when there are no new tags

Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2019-10-04 15:13:52 +02:00
Michael Opdenacker
3c78f8a0fc Add some comments
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2019-10-04 13:07:54 +02:00
Michael Opdenacker
c6aee2ad9d Improve progress reporting + factorize LXR_DATA_DIR access
- For long runs, allows to see which project we are in, and the
  percentage of processed tags

Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2019-10-03 13:33:26 +02:00
Michael Opdenacker
89b777fb4f Add some comments
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2019-09-23 14:34:20 +02:00
Chen-Yu Tsai
0ab49d012f Add basic support for C++ files
Include C++ files when indexing and tokenizing files.

Unfortunately due to how C++ utilizes namespaces and classes, this
currently introduces a large amount of false positives for unqualified
identifiers that look the same.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
2018-04-10 07:45:12 +00:00
Chen-Yu Tsai
883281e446 Use os.path.splitext to split out file extension
Python's standard library provides a function to split out file
extensions, and it also handles dot files correctly.

Use that instead of just retrieving the last two characters of
the file name.

This should help with issue #27.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
2018-04-10 07:44:25 +00:00
Michael Opdenacker
b4118f3f9e
Merge pull request #34 from plaes/master
Clean up unused imports
2018-04-05 10:53:43 +02:00
Mikaël Bouillot
537e6b3a7b Change business name 2018-02-15 21:27:00 +00:00
Priit Laes
f02c6469fa Clean up unused imports
Signed-off-by: Priit Laes <plaes@plaes.org>
2017-10-21 14:03:37 +03:00
stdk
4845e25186 Filenames that contain spaces are now processed correctly (#24)
Fixes #23
2017-07-02 17:03:54 +00:00
Mikaël Bouillot
1b4c0fc7d4 Update notices to match the new license 2017-06-27 14:13:28 +02:00