demarches-normaliennes/config/initializers
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
..
01_application_name.rb config: move application_name to an initializer 2021-02-24 15:06:55 +01:00
active_model_serializer.rb Files should end with a new line 2017-04-04 16:59:38 +02:00
active_storage.rb jobs: also retry native ActiveStorage's jobs on transient errors 2021-04-29 14:08:12 +02:00
after_party.rb Enable the Lint/UnusedBlockArgument cop 2019-01-03 10:53:50 +01:00
application_controller_renderer.rb Rails app:update 2020-07-07 18:03:56 +02:00
assets.rb app: update code to Rails 6.1 2021-03-25 13:24:53 +01:00
authorized_content_types.rb Add authorized content type for pj 2021-01-18 17:23:08 +01:00
backtrace_silencers.rb app: update code to Rails 6.1 2021-03-25 13:24:53 +01:00
chartkick.rb change stats colors 2021-09-28 14:49:24 +02:00
contacts.rb allow mailers/_bizdev_signature to be configured in .env file 2021-02-04 13:09:40 +01:00
content_security_policy.rb app: update code to Rails 6.1 2021-03-25 13:24:53 +01:00
cookies_serializer.rb Rails app:update 2020-07-07 18:03:56 +02:00
core_ext.rb zeitwerk: move our Array extension to initializers/core_ext 2021-02-11 12:30:43 +01:00
date_select.rb fix display of labels for datetime on screenreaders 2020-07-20 11:37:01 +02:00
devise.rb add recoverable and two_factor stragegy for administration 2020-11-05 16:03:55 +01:00
dynamic_smtp_settings_interceptor.rb config: fix DynamicSmtpSettingsInterceptor warning again 2021-03-04 22:52:19 +01:00
env_vars.rb Enable the Lint/UnusedBlockArgument cop 2019-01-03 10:53:50 +01:00
excon_setup.rb Fix uninitialized excon constant 2020-09-08 18:36:24 +02:00
filter_parameter_logging.rb app: update code to Rails 6.1 2021-03-25 13:24:53 +01:00
flipper.rb refactor(routage): remove administrateur_routage feature flag 2021-09-18 11:21:26 +02:00
france_connect.rb [ENV] France connect particulier config in secrets.yml 2018-08-23 15:55:31 +02:00
geocoder.rb Add api address external data fetch 2021-02-17 19:10:16 +01:00
graphql.rb added application name in config/ 2020-07-23 16:17:54 +02:00
groupdate.rb stats: make groupdate week start on Monday 2019-01-10 16:14:14 +01:00
images.rb allow email footer logo to be configured in .env file 2021-02-09 09:39:02 +01:00
inflections.rb CNAF in lowercase 2021-10-12 14:26:40 +02:00
legit_admin_domains.rb change in whitelist 2021-10-19 21:07:24 +02:00
lograge.rb jobs: move ActiveJobLogSubscriber out of initializers 2021-10-12 11:40:19 +02:00
mailjet.rb initializers: lazy-load Mailjet gem 2021-04-20 15:11:43 +02:00
mime_types.rb First Commit 2015-08-10 11:05:06 +02:00
open_id_connect.rb Files should end with a new line 2017-04-04 16:59:38 +02:00
otp.rb set OTP: Enable or Disable 2021-09-09 10:25:15 -05:00
passwords.rb Rename gestionnaire to instructeur in a comment 2019-08-13 10:27:49 +02:00
permissions_policy.rb app: update code to Rails 6.1 2021-03-25 13:24:53 +01:00
pg_interval_5_2.rb add interval data type to ActiveRecord 2020-03-24 18:10:13 +01:00
phonelib.rb refuse les numéros de tel invalides 2019-12-04 05:34:43 +01:00
rack.rb [fix #2387] Rack: increase max multipart number 2018-08-13 17:45:47 +02:00
rack_attack.rb Use rack_attack_enabled? 2019-08-20 13:29:29 +02:00
rack_attack_request.rb RackAttack: use remote ip and test it ! 2019-08-20 13:29:29 +02:00
rack_mini_profiler.rb activate rack_mini_profiler in dev and display query count 2021-05-05 17:16:10 +02:00
saml_idp.rb act as an saml identity provider 2020-11-16 12:19:54 +01:00
sendinblue.rb ajout de la gem sendinblue 2020-10-13 17:36:43 +02:00
sentry.rb config: report job exceptions after max retry count reached 2021-07-01 15:06:14 +02:00
session_store.rb Change the cookie key 2018-03-01 10:33:53 +01:00
typhoeus.rb added application name in config/ 2020-07-23 16:17:54 +02:00
urls.rb Add api particulier url in conf 2021-09-15 14:37:04 +02:00
watermark.rb Make watermark configurable 2020-11-25 16:19:06 +01:00
wrap_parameters.rb app: update code to Rails 6.1 2021-03-25 13:24:53 +01:00
zxcvbn_dictionnaries.yaml [Fix #1285] Add a custom dictionary for zxcvbn 2018-09-26 09:02:59 +02:00