d0e87a08cf
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. |
||
---|---|---|
.. | ||
01_application_name.rb | ||
active_model_serializer.rb | ||
active_storage.rb | ||
after_party.rb | ||
application_controller_renderer.rb | ||
assets.rb | ||
authorized_content_types.rb | ||
backtrace_silencers.rb | ||
chartkick.rb | ||
contacts.rb | ||
content_security_policy.rb | ||
cookies_serializer.rb | ||
core_ext.rb | ||
date_select.rb | ||
devise.rb | ||
dynamic_smtp_settings_interceptor.rb | ||
env_vars.rb | ||
excon_setup.rb | ||
filter_parameter_logging.rb | ||
flipper.rb | ||
france_connect.rb | ||
geocoder.rb | ||
graphql.rb | ||
groupdate.rb | ||
images.rb | ||
inflections.rb | ||
legit_admin_domains.rb | ||
lograge.rb | ||
mailjet.rb | ||
mime_types.rb | ||
open_id_connect.rb | ||
otp.rb | ||
passwords.rb | ||
permissions_policy.rb | ||
pg_interval_5_2.rb | ||
phonelib.rb | ||
rack.rb | ||
rack_attack.rb | ||
rack_attack_request.rb | ||
rack_mini_profiler.rb | ||
saml_idp.rb | ||
sendinblue.rb | ||
sentry.rb | ||
session_store.rb | ||
typhoeus.rb | ||
urls.rb | ||
watermark.rb | ||
wrap_parameters.rb | ||
zxcvbn_dictionnaries.yaml |