mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-24 11:54:01 +00:00
build system: don't optimize when compiling iso639_language_list.cpp
Even `-O1` causes compilation time & memory usage to skyrocket, possibly exponentially, with the number of entries to `emplace_back()` into the vector. This isn't so bad with the current number of entries (489). In that case compilation with `-O3` only takes 7.2s. However, extending the list to cover ISO 639-3 means that the list will include 7160 entries. With that many entries things are much, much more severe: • with `-O1` alone compilation takes 11m 23s already. • with `-O3` memory usage exceeded 20 GB after six minutes when I had to abort due to other running applications getting killed. Runtime cost is negligible. I ran a micro benchmark. With all 7160 entries and no optimizations (`-O0`) the initialization takes ~1.4 milliseconds for the one-time initialization on startup; with optimizations (`-O1`) it still took ~570 microseconds. Part of the implementation of #3007.
This commit is contained in:
parent
5b85b2fae5
commit
c9884c3e77
7
Rakefile
7
Rakefile
@ -347,6 +347,13 @@ cxx_compiler = lambda do |*args|
|
||||
flags.gsub!(%r{-Wpedantic}, '')
|
||||
end
|
||||
|
||||
if %r{src/common/iso639_language_list.cpp}.match(source)
|
||||
# Even -O1 causes compilation time & memory usage to skyrocket,
|
||||
# possibly exponentially, with the number of entries to
|
||||
# emplace_back() into the vector.
|
||||
flags.gsub!(%r{ -O\d+ }, ' -O0 ')
|
||||
end
|
||||
|
||||
args = [
|
||||
"cxx", source,
|
||||
"#{c(:CXX)} #{flags}#{pchu}#{pchx} #{$system_includes} -c -MMD -MF #{dep} -o #{t.name} -x #{lang} #{source}",
|
||||
|
@ -39,9 +39,9 @@ def create_iso639_language_list_file
|
||||
// NOTE: this file is auto-generated by the "dev:iso639_list" rake target.
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#include "common/common_pch.h"
|
||||
#include "common/iso639_types.h"
|
||||
|
||||
#include "common/iso639.h"
|
||||
using namespace std::string_literals;
|
||||
|
||||
namespace mtx::iso639 {
|
||||
|
||||
|
@ -403,7 +403,7 @@ PCH status: <%= c?(:USE_PRECOMPILED_HEADERS) ? "enabled" : "disabled" %>
|
||||
|
||||
def self.info_for_user(user, ofile)
|
||||
f = Info.new
|
||||
if c?(:USE_PRECOMPILED_HEADERS)
|
||||
if c?(:USE_PRECOMPILED_HEADERS) && !%r{src/common/iso639_language_list.cpp}.match(user)
|
||||
user = Pathname.new(user).cleanpath.to_s
|
||||
f.language = "c++-header" if user.end_with?(".h")
|
||||
header = @db_scan.fetch(user, nil)
|
||||
|
@ -15,24 +15,10 @@
|
||||
|
||||
#include "common/common_pch.h"
|
||||
|
||||
#include "common/iso639_types.h"
|
||||
|
||||
namespace mtx::iso639 {
|
||||
|
||||
struct language_t {
|
||||
std::string const english_name, alpha_3_code, alpha_2_code, terminology_abbrev;
|
||||
bool is_part_of_iso639_2{};
|
||||
|
||||
language_t(std::string &&p_english_name, std::string &&p_alpha_3_code, std::string &&p_alpha_2_code, std::string &&p_terminology_abbrev, bool p_is_part_of_iso639_2)
|
||||
: english_name{std::move(p_english_name)}
|
||||
, alpha_3_code{std::move(p_alpha_3_code)}
|
||||
, alpha_2_code{std::move(p_alpha_2_code)}
|
||||
, terminology_abbrev{std::move(p_terminology_abbrev)}
|
||||
, is_part_of_iso639_2{p_is_part_of_iso639_2}
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
extern std::vector<language_t> g_languages;
|
||||
|
||||
void init();
|
||||
std::optional<language_t> look_up(std::string const &s, bool allow_short_english_names = false);
|
||||
void list_languages();
|
||||
|
@ -15,9 +15,9 @@
|
||||
// NOTE: this file is auto-generated by the "dev:iso639_list" rake target.
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#include "common/common_pch.h"
|
||||
#include "common/iso639_types.h"
|
||||
|
||||
#include "common/iso639.h"
|
||||
using namespace std::string_literals;
|
||||
|
||||
namespace mtx::iso639 {
|
||||
|
||||
|
37
src/common/iso639_types.h
Normal file
37
src/common/iso639_types.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
mkvmerge -- utility for splicing together matroska files
|
||||
from component media subtypes
|
||||
|
||||
Distributed under the GPL v2
|
||||
see the file COPYING for details
|
||||
or visit https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
|
||||
ISO 639 types
|
||||
|
||||
Written by Moritz Bunkus <moritz@bunkus.org>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace mtx::iso639 {
|
||||
|
||||
struct language_t {
|
||||
std::string const english_name, alpha_3_code, alpha_2_code, terminology_abbrev;
|
||||
bool is_part_of_iso639_2{};
|
||||
|
||||
language_t(std::string &&p_english_name, std::string &&p_alpha_3_code, std::string &&p_alpha_2_code, std::string &&p_terminology_abbrev, bool p_is_part_of_iso639_2)
|
||||
: english_name{std::move(p_english_name)}
|
||||
, alpha_3_code{std::move(p_alpha_3_code)}
|
||||
, alpha_2_code{std::move(p_alpha_2_code)}
|
||||
, terminology_abbrev{std::move(p_terminology_abbrev)}
|
||||
, is_part_of_iso639_2{p_is_part_of_iso639_2}
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
extern std::vector<language_t> g_languages;
|
||||
|
||||
} // namespace mtx::iso639
|
Loading…
Reference in New Issue
Block a user