public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] stdlib: reorganize stdlib Makefile routines by functionality
@ 2024-04-01 11:47 abush wang
  2024-04-01 13:12 ` Florian Weimer
  2024-04-02 14:15 ` Adhemerval Zanella Netto
  0 siblings, 2 replies; 14+ messages in thread
From: abush wang @ 2024-04-01 11:47 UTC (permalink / raw)
  To: abushwang via Libc-alpha; +Cc: adhemerval.zanella

[-- Attachment #1: Type: text/plain, Size: 617 bytes --]

This is test:
```
uint64_t getnsecs() {
    uint32_t lo, hi;
    __asm__ __volatile__ (
        "rdtsc" : "=a"(lo), "=d"(hi)
    );
    return ((uint64_t)hi << 32) | lo;
}

int main() {
    const int num_iterations = 1;
    uint64_t start, end, total_time = 0;

    start = getnsecs();
    for (int i = 0; i < num_iterations; i++) {
        (void) lrand48();
    }
    end = getnsecs();
    total_time += (end - start);

    printf("Average time for lrand48: %lu cycles\n", total_time /
num_iterations);
    return 0;
}
```
before:
Average time for lrand48: 21418 cycles

after:
Average time for lrand48: 9892 cycles

^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH] stdlib: reorganize stdlib Makefile routines by functionality
@ 2024-04-01 11:44 abushwang
  2024-04-01 12:03 ` Xi Ruoyao
  0 siblings, 1 reply; 14+ messages in thread
From: abushwang @ 2024-04-01 11:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: adhemerval.zanella, Shuo Wang

From: Shuo Wang <abushwang@tencent.com>

Commit d275970ab sort all functions by lexicographic Order,
which potentially impacts performance (such as 'lrand48')
due to increased distance in the compiled output

Signed-off-by: Shuo Wang <abushwang@tencent.com>
---
 stdlib/Makefile | 215 ++++++++++++------------------------------------
 1 file changed, 51 insertions(+), 164 deletions(-)

diff --git a/stdlib/Makefile b/stdlib/Makefile
index 8b0ac63ddb..d2d912db27 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -51,170 +51,57 @@ headers := \
   ucontext.h \
   # headers
 
-routines := \
-  a64l \
-  abort \
-  abs \
-  arc4random \
-  arc4random_uniform \
-  at_quick_exit \
-  atof \
-  atoi \
-  atol\
-  atoll \
-  bsearch \
-  canonicalize \
-  cxa_at_quick_exit \
-  cxa_atexit \
-  cxa_finalize \
-  cxa_thread_atexit_impl \
-  div \
-  drand48 \
-  drand48-iter \
-  drand48_r \
-  erand48 \
-  erand48_r \
-  exit \
-  fmtmsg \
-  getcontext \
-  getentropy \
-  getenv \
-  getrandom \
-  getsubopt \
-  jrand48 \
-  jrand48_r \
-  l64a \
-  labs \
-  lcong48 \
-  lcong48_r \
-  ldiv \
-  llabs \
-  lldiv \
-  lrand48 \
-  lrand48_r \
-  makecontext \
-  mblen \
-  mbstowcs \
-  mbtowc \
-  mrand48 \
-  mrand48_r \
-  nrand48 \
-  nrand48_r \
-  old_atexit  \
-  on_exit atexit \
-  putenv \
-  qsort \
-  quick_exit \
-  rand \
-  rand_r \
-  random \
-  random_r \
-  rpmatch \
-  secure-getenv \
-  seed48 \
-  seed48_r \
-  setcontext \
-  setenv \
-  srand48 \
-  srand48_r \
-  stdc_bit_ceil_uc \
-  stdc_bit_ceil_ui \
-  stdc_bit_ceil_ul \
-  stdc_bit_ceil_ull \
-  stdc_bit_ceil_us \
-  stdc_bit_floor_uc \
-  stdc_bit_floor_ui \
-  stdc_bit_floor_ul \
-  stdc_bit_floor_ull \
-  stdc_bit_floor_us \
-  stdc_bit_width_uc \
-  stdc_bit_width_ui \
-  stdc_bit_width_ul \
-  stdc_bit_width_ull \
-  stdc_bit_width_us \
-  stdc_count_ones_uc \
-  stdc_count_ones_ui \
-  stdc_count_ones_ul \
-  stdc_count_ones_ull \
-  stdc_count_ones_us \
-  stdc_count_zeros_uc \
-  stdc_count_zeros_ui \
-  stdc_count_zeros_ul \
-  stdc_count_zeros_ull \
-  stdc_count_zeros_us \
-  stdc_first_leading_one_uc \
-  stdc_first_leading_one_ui \
-  stdc_first_leading_one_ul \
-  stdc_first_leading_one_ull \
-  stdc_first_leading_one_us \
-  stdc_first_leading_zero_uc \
-  stdc_first_leading_zero_ui \
-  stdc_first_leading_zero_ul \
-  stdc_first_leading_zero_ull \
-  stdc_first_leading_zero_us \
-  stdc_first_trailing_one_uc \
-  stdc_first_trailing_one_ui \
-  stdc_first_trailing_one_ul \
-  stdc_first_trailing_one_ull \
-  stdc_first_trailing_one_us \
-  stdc_first_trailing_zero_uc \
-  stdc_first_trailing_zero_ui \
-  stdc_first_trailing_zero_ul \
-  stdc_first_trailing_zero_ull \
-  stdc_first_trailing_zero_us \
-  stdc_has_single_bit_uc \
-  stdc_has_single_bit_ui \
-  stdc_has_single_bit_ul \
-  stdc_has_single_bit_ull \
-  stdc_has_single_bit_us \
-  stdc_leading_ones_uc \
-  stdc_leading_ones_ui \
-  stdc_leading_ones_ul \
-  stdc_leading_ones_ull \
-  stdc_leading_ones_us \
-  stdc_leading_zeros_uc \
-  stdc_leading_zeros_ui \
-  stdc_leading_zeros_ul \
-  stdc_leading_zeros_ull \
-  stdc_leading_zeros_us \
-  stdc_trailing_ones_uc \
-  stdc_trailing_ones_ui \
-  stdc_trailing_ones_ul \
-  stdc_trailing_ones_ull \
-  stdc_trailing_ones_us \
-  stdc_trailing_zeros_uc \
-  stdc_trailing_zeros_ui \
-  stdc_trailing_zeros_ul \
-  stdc_trailing_zeros_ull \
-  stdc_trailing_zeros_us \
-  strfmon \
-  strfmon_l \
-  strfromd \
-  strfromf \
-  strfroml \
-  strtod \
-  strtod_l \
-  strtod_nan \
-  strtof \
-  strtof_l \
-  strtof_nan \
-  strtol \
-  strtol_l \
-  strtold \
-  strtold_l \
-  strtold_nan \
-  strtoll \
-  strtoll_l \
-  strtoul \
-  strtoul_l \
-  strtoull \
-  strtoull_l \
-  swapcontext \
-  system \
-  wcstombs \
-  wctomb  \
-  xpg_basename \
-  # routines
+routines        :=                                                                           \
+        atof atoi atol atoll                                                                 \
+        abort                                                                                \
+        bsearch qsort                                                                        \
+        getenv putenv setenv secure-getenv                                                   \
+        exit on_exit atexit cxa_atexit cxa_finalize old_atexit                               \
+        quick_exit at_quick_exit cxa_at_quick_exit cxa_thread_atexit_impl                    \
+        abs labs llabs                                                                       \
+        div ldiv lldiv                                                                       \
+        mblen mbstowcs mbtowc wcstombs wctomb                                                \
+        arc4random arc4random_uniform                                                        \
+        random random_r rand rand_r                                                          \
+        drand48 erand48 lrand48 nrand48 mrand48 jrand48                                      \
+        srand48 seed48 lcong48                                                               \
+        drand48_r erand48_r lrand48_r nrand48_r mrand48_r jrand48_r                          \
+        srand48_r seed48_r lcong48_r                                                         \
+        drand48-iter getrandom getentropy                                                    \
+        strfromf strfromd strfroml                                                           \
+        strtol strtoul strtoll strtoull                                                      \
+        strtol_l strtoul_l strtoll_l strtoull_l                                              \
+        strtof strtod strtold                                                                \
+        strtof_l strtod_l strtold_l                                                          \
+        strtof_nan strtod_nan strtold_nan                                                    \
+        system canonicalize                                                                  \
+        stdc_bit_ceil_uc stdc_bit_ceil_ui stdc_bit_ceil_ul                                   \
+        stdc_bit_ceil_ull stdc_bit_ceil_us stdc_bit_floor_uc                                 \
+        stdc_bit_floor_ui stdc_bit_floor_ul stdc_bit_floor_ull                               \
+        stdc_bit_floor_us stdc_bit_width_uc stdc_bit_width_ui                                \
+        stdc_bit_width_ul stdc_bit_width_ull stdc_bit_width_us                               \
+        stdc_count_ones_uc stdc_count_ones_ui stdc_count_ones_ul                             \
+        stdc_count_ones_ull stdc_count_ones_us stdc_count_zeros_uc                           \
+        stdc_count_zeros_ui stdc_count_zeros_ul stdc_count_zeros_ull                         \
+        stdc_count_zeros_us stdc_first_leading_one_uc stdc_first_leading_one_ui              \
+        stdc_first_leading_one_ul stdc_first_leading_one_ull stdc_first_leading_one_us       \
+        stdc_first_leading_zero_uc stdc_first_leading_zero_ui stdc_first_leading_zero_ul     \
+        stdc_first_leading_zero_ull stdc_first_leading_zero_us stdc_first_trailing_one_uc    \
+        stdc_first_trailing_one_ui stdc_first_trailing_one_ul stdc_first_trailing_one_ull    \
+        stdc_first_trailing_one_us stdc_first_trailing_zero_uc stdc_first_trailing_zero_ui   \
+        stdc_first_trailing_zero_ul stdc_first_trailing_zero_ull stdc_first_trailing_zero_us \
+        stdc_has_single_bit_uc stdc_has_single_bit_ui stdc_has_single_bit_ul                 \
+        stdc_has_single_bit_ull stdc_has_single_bit_us stdc_leading_ones_uc                  \
+        stdc_leading_ones_ui stdc_leading_ones_ul stdc_leading_ones_ull                      \
+        stdc_leading_ones_us stdc_leading_zeros_uc stdc_leading_zeros_ui                     \
+        stdc_leading_zeros_ul stdc_leading_zeros_ull stdc_leading_zeros_us                   \
+        stdc_trailing_ones_uc stdc_trailing_ones_ui stdc_trailing_ones_ul                    \
+        stdc_trailing_ones_ull stdc_trailing_ones_us stdc_trailing_zeros_uc                  \
+        stdc_trailing_zeros_ui stdc_trailing_zeros_ul stdc_trailing_zeros_ull                \
+        stdc_trailing_zeros_us                                                               \
+        a64l l64a                                                                            \
+        rpmatch strfmon strfmon_l getsubopt xpg_basename fmtmsg                              \
+        getcontext setcontext makecontext swapcontext
 
 # Exclude fortified routines from being built with _FORTIFY_SOURCE
 routines_no_fortify += \
-- 
2.37.3


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-04-08  2:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-01 11:47 [PATCH] stdlib: reorganize stdlib Makefile routines by functionality abush wang
2024-04-01 13:12 ` Florian Weimer
2024-04-01 13:17   ` H.J. Lu
2024-04-01 13:46     ` Adhemerval Zanella Netto
2024-04-02  3:54     ` abush wang
2024-04-08  2:48       ` abush wang
2024-04-02  2:17   ` abush wang
2024-04-02  2:28     ` abush wang
2024-04-02  3:13       ` H.J. Lu
2024-04-02  6:18         ` abush wang
2024-04-02 14:15 ` Adhemerval Zanella Netto
2024-04-03  1:57   ` abush wang
  -- strict thread matches above, loose matches on Subject: below --
2024-04-01 11:44 abushwang
2024-04-01 12:03 ` Xi Ruoyao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).