aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Kleen <ak@gcc.gnu.org>2024-12-25 11:54:13 -0800
committerAndi Kleen <ak@gcc.gnu.org>2025-02-02 21:40:37 -0800
commitae814afad900edf1f19850985614398e0875618c (patch)
tree1158f600d62afc1acefb52d1601967fd541374b6
parent6fef3852c5e8506a9d97091b26ee6d0dbd830a67 (diff)
downloadgcc-ae814afad900edf1f19850985614398e0875618c.zip
gcc-ae814afad900edf1f19850985614398e0875618c.tar.gz
gcc-ae814afad900edf1f19850985614398e0875618c.tar.bz2
Add tunables for input buffer
The input machinery to read the source code independent of the lexer has a range of hard coded maximum array sizes that can impact performance. Make them tunable. input.cc is part of libcommon so it cannot direct access params without a level of indirection. gcc/ChangeLog: PR preprocessor/118168 * input.cc (file_cache::tune): New function. * input.h (class file_cache): Make tunables non const. * params.opt: Add new tunables. * toplev.cc (toplev::main): Initialize input buffer context tunables.
-rw-r--r--gcc/input.cc18
-rw-r--r--gcc/input.h4
-rw-r--r--gcc/params.opt8
-rw-r--r--gcc/toplev.cc2
4 files changed, 30 insertions, 2 deletions
diff --git a/gcc/input.cc b/gcc/input.cc
index 9f3cc66..8605202 100644
--- a/gcc/input.cc
+++ b/gcc/input.cc
@@ -79,6 +79,10 @@ public:
void evict ();
void set_content (const char *buf, size_t sz);
+ static void tune(size_t line_record_size_) {
+ line_record_size = line_record_size_;
+ }
+
private:
/* These are information used to store a line boundary. */
class line_info
@@ -116,7 +120,7 @@ public:
bool goto_next_line ();
static const size_t buffer_size = 4 * 1024;
- static const size_t line_record_size = 100;
+ static size_t line_record_size;
/* The number of time this file has been accessed. This is used
to designate which file cache to evict from the cache
@@ -192,6 +196,18 @@ public:
};
+size_t file_cache_slot::line_record_size = 100;
+
+/* Tune file_cache. */
+void
+file_cache::tune (size_t num_file_slots_, size_t lines)
+{
+ num_file_slots = num_file_slots_;
+ file_cache_slot::tune (lines);
+}
+
+size_t file_cache::num_file_slots = 16;
+
static const char *
find_end_of_line (const char *s, size_t len);
diff --git a/gcc/input.h b/gcc/input.h
index 18ccf44..a60afe8 100644
--- a/gcc/input.h
+++ b/gcc/input.h
@@ -161,13 +161,15 @@ class file_cache
const char *buffer,
size_t sz);
+ static void tune(size_t num_file_slots_, size_t lines);
+
private:
file_cache_slot *evicted_cache_tab_entry (unsigned *highest_use_count);
file_cache_slot *add_file (const char *file_path);
file_cache_slot *lookup_file (const char *file_path);
private:
- static const size_t num_file_slots = 16;
+ static size_t num_file_slots;
file_cache_slot *m_file_slots;
input_context m_input_context;
};
diff --git a/gcc/params.opt b/gcc/params.opt
index b5e7800..5d234a6 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -134,6 +134,14 @@ Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
Common Joined UInteger Var(param_early_inlining_insns) Init(6) Optimization Param
Maximal estimated growth of function body caused by early inlining of single call.
+-param=file-cache-files=
+Common Joined UInteger Var(param_file_cache_files) Init(16) Param
+Max number of files in the file cache.
+
+-param=file-cache-lines=
+Common Joined UInteger Var(param_file_cache_lines) Init(100) Param
+Max number of lines to index into file cache.
+
-param=fsm-scale-path-stmts=
Common Joined UInteger Var(param_fsm_scale_path_stmts) Init(2) IntegerRange(1, 10) Param Optimization
Scale factor to apply to the number of statements in a threading path crossing a loop backedge when comparing to max-jump-thread-duplication-stmts.
diff --git a/gcc/toplev.cc b/gcc/toplev.cc
index d45a12c..e03af8b 100644
--- a/gcc/toplev.cc
+++ b/gcc/toplev.cc
@@ -2333,6 +2333,8 @@ toplev::main (int argc, char **argv)
UNKNOWN_LOCATION, global_dc,
targetm.target_option.override);
+ file_cache::tune (param_file_cache_files, param_file_cache_lines);
+
handle_common_deferred_options ();
init_local_tick ();