demarches-normaliennes/config
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
..
environments Use explicit name to avoid unknown constant errors 2021-05-06 16:10:48 +02:00
initializers services: cache zxcvbn dictionaries per-thread 2021-10-25 12:04:56 +02:00
locales allow instructeur and administrateur to change their email to legit domain (#6550) 2021-10-19 15:54:57 +02:00
webpack Another attempt at fixing IE 2021-03-09 11:29:20 +01:00
application.rb app: restore the default cache settings 2021-07-20 11:11:52 +02:00
boot.rb app: enable Bootsnap 2021-03-19 08:05:14 +01:00
brakeman.ignore gems: clean brakeman obsolete false-positives 2021-09-02 16:12:52 -05:00
cable.yml app: update code to Rails 6.1 2021-03-25 13:24:53 +01:00
database.yml config: fix spring randomly crashing in the pg gem 2020-05-25 09:23:41 +00:00
deploy.rb add webserver file logic 2021-03-29 18:45:40 +02:00
env.example Feat (API Particulier): new encryption service 2021-07-30 11:18:44 +02:00
env.example.optional allow instructeur and administrateur to change their email to legit domain (#6550) 2021-10-19 15:54:57 +02:00
environment.rb app: update code to Rails 6.1 2021-03-25 13:24:53 +01:00
i18n-tasks.yml Fix file size validation message 2021-09-21 12:11:20 -05:00
puma.rb config: remove pre and post boot code from puma config 2021-10-25 11:28:09 +02:00
routes.rb merge with another new account 2021-10-14 14:47:50 +02:00
secrets.yml Feat (API Particulier): new encryption service 2021-07-30 11:18:44 +02:00
skylight.yml [ENV] Add skylight conf 2018-08-23 15:55:31 +02:00
spring.rb Rails app:update 2020-07-07 18:03:56 +02:00
storage.yml fix catalog v3 2020-06-19 14:20:32 +02:00
webpacker.yml app: upgrade webpacker by running rails webpacker:install 2021-09-30 17:05:26 +02:00