Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: speed up Lang.pm initialization, save 2 seconds x 100 tests #9197

Merged
merged 1 commit into from
Oct 27, 2023

Conversation

stephanegigandet
Copy link
Contributor

This is an attempt to speed up tests. Almost all tests load Lang.pm.

  • removed useless sleep()
  • made parsing of the po/tags/ file saved in a file (like we do for po/common)

In profiling done with nytprof, this saves about 2 seconds per initialization. As we have 100 unit + integration tests, I'm hoping this should save 3 minutes when running all tests.

@sonarcloud
Copy link

sonarcloud bot commented Oct 25, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

= ProductOpener::I18N::split_tags(ProductOpener::I18N::read_po_files("$data_root/po/tags/"));
%tag_type_singular = %{$tag_type_singular_ref};
%tag_type_plural = %{$tag_type_plural_ref};
$path = "$data_root/data/Lang_tags.${server_domain}.sto";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more cache data, could you move it to the cache folder.

@@ -48,6 +49,7 @@
mkdir("$data_root/data", 0755) or die("Could not create target directory $data_root/data : $!\n");
}
store("$data_root/data/Lang.${server_domain}.sto", \%Lang);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here also it would be better to have it in a cache folder.

Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I am just a bit picky about using a cache directory instead of a data directory (help to better identify what to backups, be redundant, etc.)

@stephanegigandet
Copy link
Contributor Author

Good idea, I am just a bit picky about using a cache directory instead of a data directory (help to better identify what to backups, be redundant, etc.)

Let's do it once the migration is done. In fact /data was intended to be a "cache" folder in the sense that it contains things that can be recomputed. We should revisit those things globally. The built lang files are more like the built taxonomies, we could just use the same system we have for taxonomies.

@stephanegigandet stephanegigandet merged commit 230b1d6 into main Oct 27, 2023
14 checks passed
@stephanegigandet stephanegigandet deleted the speed-lang branch October 27, 2023 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants