demarches-normaliennes/spec/services
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
..
administrateur_usage_statistics_service_spec.rb fix tests that now requir an admin user to have a strong password 2020-09-18 11:16:34 +02:00
api_entreprise_service_spec.rb zeitwerk: Api -> API 2021-02-09 13:07:30 +01:00
bill_signature_service_spec.rb WIP 2020-07-07 18:03:56 +02:00
clamav_service_spec.rb specs: always require rails_helper 2020-03-31 12:48:32 +02:00
commentaire_service_spec.rb active_storage: refactor concerns 2021-03-16 11:49:14 +01:00
dossier_projection_service_spec.rb add test to dossier_projection_service 2021-09-07 15:17:06 +02:00
dossier_search_service_spec.rb cleanup tests 2021-05-18 11:42:10 +02:00
encryption_service_spec.rb Feat (API Particulier): new encryption service 2021-07-30 11:18:44 +02:00
expired_dossiers_deletion_service_spec.rb fix(dossier): send expiration notifications 2 weeks prior to supression instead of a month 2021-08-26 11:28:57 +02:00
france_connect_service_spec.rb disable france connect authentication for admin and instructeurs 2021-02-10 18:13:47 +01:00
geojson_service_spec.rb Remove quartiers prioritaires 2020-04-14 10:29:59 +02:00
instructeurs_import_service_spec.rb tests 2021-06-15 19:36:46 +02:00
ip_service_spec.rb specs: always require rails_helper 2020-03-31 12:48:32 +02:00
notification_service_spec.rb fetch all notification at once 2021-04-29 11:23:41 +02:00
pieces_justificatives_service_spec.rb tests 2021-10-05 15:00:21 +02:00
procedure_archive_service_spec.rb archives: move bugreport 2021-08-05 09:24:20 +02:00
procedure_export_service_spec.rb add cnaf type de champ 2021-10-12 14:26:40 +02:00
zxcvbn_service_spec.rb services: cache zxcvbn dictionaries per-thread 2021-10-25 12:04:56 +02:00