demarches-normaliennes/spec
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
..
controllers rename preexisting to targeted, remove duplicated test 2021-10-19 16:12:42 +02:00
factories add end to end spec 2021-10-12 14:27:20 +02:00
features add end to end test 2021-10-14 14:47:50 +02:00
fixtures homogennize api particulier endpoint test url 2021-10-12 14:27:20 +02:00
helpers add spec for archive weight estimation 2021-06-09 10:52:38 +02:00
jobs Prevent double processing of declarative dossiers 2021-06-04 17:55:40 +02:00
lib source service supports unknown scope 2021-10-12 14:27:20 +02:00
mailers fix(i18n): enable locale for email previews 2021-09-09 13:06:51 -05:00
middlewares specs: always require rails_helper 2020-03-31 12:48:32 +02:00
models fix(transfer): manually nullify staled transfers references 2021-10-21 13:54:26 +02:00
policies policies: fix champ policy for guest users 2020-04-02 11:27:14 +02:00
serializers Add compatibility cadsatre layer with old API GEO 2021-05-24 11:57:00 +02:00
services services: cache zxcvbn dictionaries per-thread 2021-10-25 12:04:56 +02:00
support specs: set i18n cookie before running browser specs 2021-10-19 16:41:36 +02:00
views specs: remove invalid js: true specifier 2021-10-19 16:41:36 +02:00
rails_helper.rb replace deprecated axe-matchers by axe-core-spec 2021-08-24 08:09:17 -05:00
spec_helper.rb Chore(test): enable rspec only-failures support 2021-04-15 14:17:39 +02:00