demarches-normaliennes/app/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.rb Use revision instead of groupe instructeur as dossier procedure link 2021-03-09 14:47:23 +01:00
api_entreprise_service.rb zeitwerk: Api -> API 2021-02-09 13:07:30 +01:00
bill_signature_service.rb Bug with time zone: Time.zone.today looses time_zone and may breaks database comparisons 2019-12-11 17:34:10 +01:00
browser_support.rb Update browser gem 2020-03-17 11:25:20 +01:00
clamav_service.rb If ClamavService fails then raise an error 2019-02-05 17:58:41 +01:00
commentaire_service.rb Remove the link between commentaire and user 2021-04-22 15:10:47 +01:00
countries_service.rb fix(i18n): add Kosovo to countries list 2021-09-08 12:11:25 +02:00
dossier_projection_service.rb fix(dossier_projection_service): select external_id on champs 2021-09-07 14:07:55 +02:00
dossier_search_service.rb avoid serializing long id list in case of huge procedure, search on it before 2021-05-20 12:08:04 +02:00
encryption_service.rb Feat (API Particulier): new encryption service 2021-07-30 11:18:44 +02:00
expired_dossiers_deletion_service.rb Do not send draft norifications to users on inactive démarches 2020-05-27 16:36:46 +02:00
france_connect_service.rb disable france connect authentication for admin and instructeurs 2021-02-10 18:13:47 +01:00
geojson_service.rb Fix geo length computations 2020-10-01 15:09:38 +02:00
instructeurs_import_service.rb fix import service 2021-06-21 14:11:05 +02:00
ip_service.rb Refactor (Rubocop): replace map{ … }.compact by filter_map 2021-06-11 15:38:09 +02:00
notification_service.rb remove email_notifications_enabled column because of the new daily_email_notifications_enabled 2020-02-27 11:09:19 +01:00
pieces_justificatives_service.rb modify pj service 2021-10-05 15:00:21 +02:00
pipedrive_service.rb Add nb_of_dossiers by years and deadline to PipeDrive Person 2019-06-04 16:55:11 +02:00
procedure_archive_service.rb fix(virus scan): prevent virus scan on archives and signatures uploads 2021-09-07 14:21:48 +02:00
procedure_export_service.rb perf(export): load dossiers.champs in batches 2021-10-20 16:52:38 +02:00
serializer_service.rb GraphQL byte_size should be BigInt 2021-06-03 10:53:17 +02:00
staging_auth_service.rb [ENV] Basic auth config 2018-08-23 15:55:32 +02:00
zxcvbn_service.rb services: cache zxcvbn dictionaries per-thread 2021-10-25 12:04:56 +02:00