public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: caiyinyu <caiyinyu@loongson.cn>, libc-alpha@sourceware.org
Cc: adhemerval.zanella@linaro.org
Subject: Re: [PATCH] LoongArch: Add Syscall Assembly Implementation
Date: Thu, 23 Mar 2023 21:12:39 +0800	[thread overview]
Message-ID: <7fec684ef1f47ac0072338e2757ec0c245407de5.camel@xry111.site> (raw)
In-Reply-To: <8a4e2e72-9daf-d264-f49d-719daa2407b5@loongson.cn>

On Thu, 2023-03-23 at 20:01 +0800, caiyinyu wrote:
> Without this patch(objdump -d libc.so...):
> 
> 00000000000dd45c <syscall>:
>     dd45c:       02fec063        addi.d          $sp, $sp, -80(0xfb0)
>     dd460:       02c0606c        addi.d          $t0, $sp, 24(0x18)

/* snip */

Yes, I know this will save some cycles.  The problem is during a
syscall, the context switch etc. uses much more time than the
instruction sequence in syscall() function itself.

I wrote a program which calls syscall(SYS_getpid) 1000000 times. 
Without the (unpatched) Glibc syscall(), the time consumed is 1.376s;
with a syscall() in asm (similar to the one in the patch but I changed
the __syscall_error tail call to a "break 0"), the time consumed is
1.203s (0.173s faster).  So we can say it saves 17.3us (about 430
cycles) per syscall.

I doubt if the improvement is really worthy for real life applications:
is there any application invoking syscalls so intensively that the
17.3us will accumulate into something we can feel?

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  parent reply	other threads:[~2023-03-23 13:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23  8:40 caiyinyu
2023-03-23  9:25 ` Xi Ruoyao
2023-03-23 12:01   ` caiyinyu
2023-03-23 13:12     ` Andreas Schwab
2023-03-23 13:34       ` Xi Ruoyao
2023-03-23 13:43         ` Xi Ruoyao
2023-03-23 17:34           ` Xi Ruoyao
2023-03-23 18:26             ` Xi Ruoyao
2023-03-23 18:40               ` Adhemerval Zanella Netto
2023-03-23 19:08                 ` Xi Ruoyao
2023-03-23 13:12     ` Xi Ruoyao [this message]
2023-03-23 12:00 caiyinyu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7fec684ef1f47ac0072338e2757ec0c245407de5.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=adhemerval.zanella@linaro.org \
    --cc=caiyinyu@loongson.cn \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).