demarches-normaliennes/app
Pierre de La Morinerie d0e87a08cf services: cache zxcvbn dictionaries per-thread
Before, every time a password was tested, the dictionaries were parsed
again by zxcvbn.

Parsing dictionaries is slow: it may take up to ~1s. This doesn't matter
that much in production, but it makes tests very slow (because we tend
to create a lot of User records).

With this changes, the initializer tester is shared between calls, class
instances and threads. It is lazily loaded on first use, in order not to
slow down the application boot sequence.

This uses ~20 Mo of memory (only once for all threads), but makes tests
more that twice faster.

For instance, model tests go from **8m 21s** to **3m 26s**.

NB:
An additionnal optimization could be to preload the tester on
boot, before workers are forked, to take advantage of Puma copy-on-write
mechanism. In this way all forked workers would use the same cached
instance.

But:

- We're not actually sure this would work properly. What if Ruby updates
  an interval ivar on the class, and this forces the OS to copy the
  whole data structure in each fork?
- Puma phased restarts are not compatible with copy-on-write anyway.

So we're avoiding this optimisation for now, and take the extra 20 Mo
per worker.
2021-10-25 12:04:56 +02:00
..
assets a password input must not be that wide 2021-10-14 14:47:50 +02:00
controllers fix(transfer): manually nullify staled transfers references 2021-10-21 13:54:26 +02:00
dashboards manager: localize dossier enums 2021-05-06 14:41:08 +02:00
fields manager: remove support for old pj 2019-07-30 16:11:17 +02:00
graphql add cnaf type de champ 2021-10-12 14:26:40 +02:00
helpers views: rename the procedure_publish_label helper 2021-10-12 16:25:11 +02:00
javascript merge with another preexisting account 2021-10-14 14:47:50 +02:00
jobs fix(transfer): manually nullify staled transfers references 2021-10-21 13:54:26 +02:00
lib source service supports unknown scope 2021-10-12 14:27:20 +02:00
mailers i18n-tasks: add hint for default_i18n_subject in mailers 2021-09-21 10:44:20 -05:00
models fix(transfer): manually nullify staled transfers references 2021-10-21 13:54:26 +02:00
policies policies: clarify the role of ChampPolicy 2020-06-24 15:42:30 +02:00
schemas add schema validations 2021-09-22 12:08:24 +02:00
serializers modify experts avis controllers, concern and serializer 2021-03-18 11:38:52 +01:00
services services: cache zxcvbn dictionaries per-thread 2021-10-25 12:04:56 +02:00
validators Add geo json validation 2021-03-11 15:51:09 +01:00
views feat(revisions): rebase dossiers brouillons 2021-10-20 17:26:09 +02:00