1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

Compare commits

...

2 commits

Author SHA1 Message Date
Helmut Eller
b01c6b2849 Abort if EMACS_IGC_ARENA_SIZE can't be parsed
* src/igc.c (parse_error): New helper.
(read_gens, read_arena_size): Use it.
2025-11-29 20:52:56 +01:00
Helmut Eller
845b93cb12 * src/igc.c (process_one_message): Format timestamps as floats. 2025-11-29 20:52:56 +01:00

View file

@ -4100,7 +4100,8 @@ process_one_message (struct igc *gc)
{
mps_clock_t clock = mps_message_clock (gc->arena, msg);
const char *why = mps_message_gc_start_why (gc->arena, msg);
message ("[%lu] GC start: %s", (unsigned long) clock, why);
double secs = (double) clock / mps_clocks_per_sec ();
message ("[%f] GC start: %s", secs, why);
}
}
else if (type == mps_message_type_gc ())
@ -4113,11 +4114,10 @@ process_one_message (struct igc *gc)
size_t not_condemned
= mps_message_gc_not_condemned_size (gc->arena, msg);
mps_clock_t clock = mps_message_clock (gc->arena, msg);
message ("[%lu] GC: condemned: %lu live: %lu "
"not_condemned: %lu",
(unsigned long) clock, (unsigned long) condemned,
(unsigned long) live,
(unsigned long) not_condemned);
double secs = (double) clock / mps_clocks_per_sec ();
message ("[%f] GC: condemned: %" pD "u live: %" pD "u "
"not_condemned: %" pD "u",
secs, condemned, live, not_condemned);
}
}
else
@ -5169,6 +5169,15 @@ For internal use only. */)
return Qnil;
}
static bool
parse_error (const char *key)
{
fprintf (stderr, "Failed to parse %s: %s\n", key, getenv (key));
fflush (stderr);
emacs_abort ();
return false;
}
/* Read GC generation settings from environment variable
EMACS_IGC_GENS. Value must be a string consisting of pairs SIZE
MORTALITY, where SIZE Is the size of the generation in KB, and
@ -5184,7 +5193,8 @@ For internal use only. */)
static bool
read_gens (size_t *ngens, mps_gen_param_s parms[*ngens])
{
const char *env = getenv ("EMACS_IGC_GENS");
const char *key = "EMACS_IGC_GENS";
const char *env = getenv (key);
if (env == NULL)
return false;
const char *end = env + strlen (env);
@ -5207,30 +5217,27 @@ read_gens (size_t *ngens, mps_gen_param_s parms[*ngens])
*ngens = i + 1;
}
else
goto parse_error;
return parse_error (key);
}
if (*ngens > 0 && env == end)
return true;
parse_error:
fprintf (stderr, "Failed to parse EMACS_IGC_GENS: %s\n",
getenv ("EMACS_IGC_GENS"));
emacs_abort ();
return parse_error (key);
}
static bool
read_arena_size (size_t *size)
{
const char *env = getenv ("EMACS_IGC_ARENA_SIZE");
const char *key = "EMACS_IGC_ARENA_SIZE";
const char *env = getenv (key);
if (env == NULL)
return false;
char *end;
*size = strtoull (env, &end, 10);
bool ok = *end == '\0';
if (!ok)
fprintf (stderr, "Failed to parse EMACS_IGC_ARENA_SIZE: %s\n",
env);
return parse_error (key);
return ok;
}