git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] move sleep_millisec to git-compat-util.h
@ 2020-11-24 19:10 Han-Wen Nienhuys via GitGitGadget
  2020-11-24 21:51 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Han-Wen Nienhuys via GitGitGadget @ 2020-11-24 19:10 UTC (permalink / raw)
  To: git; +Cc: Han-Wen Nienhuys, Han-Wen Nienhuys

From: Han-Wen Nienhuys <hanwen@google.com>

The sleep function is defined in wrapper.c, so it makes more sense to be a in
system compatibility header.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
---
    move sleep_millisec to git-compat-util.h
    
    The sleep function is defined in wrapper.c, so it makes more sense to be
    a in system compatibility header.
    
    Signed-off-by: Han-Wen Nienhuys hanwen@google.com [hanwen@google.com]

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-922%2Fhanwen%2Fsleep-header-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-922/hanwen/sleep-header-v1
Pull-Request: https://github.com/git/git/pull/922

 cache.h           | 1 -
 git-compat-util.h | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/cache.h b/cache.h
index c0072d43b1..e986cf4ea9 100644
--- a/cache.h
+++ b/cache.h
@@ -1960,7 +1960,6 @@ int stat_validity_check(struct stat_validity *sv, const char *path);
 void stat_validity_update(struct stat_validity *sv, int fd);
 
 int versioncmp(const char *s1, const char *s2);
-void sleep_millisec(int millisec);
 
 /*
  * Create a directory and (if share is nonzero) adjust its permissions
diff --git a/git-compat-util.h b/git-compat-util.h
index adfea06897..7d509c5022 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1354,4 +1354,6 @@ static inline void *container_of_or_null_offset(void *ptr, size_t offset)
 	((uintptr_t)&(ptr)->member - (uintptr_t)(ptr))
 #endif /* !__GNUC__ */
 
+void sleep_millisec(int millisec);
+
 #endif

base-commit: faefdd61ec7c7f6f3c8c9907891465ac9a2a1475
-- 
gitgitgadget

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

* Re: [PATCH] move sleep_millisec to git-compat-util.h
  2020-11-24 19:10 [PATCH] move sleep_millisec to git-compat-util.h Han-Wen Nienhuys via GitGitGadget
@ 2020-11-24 21:51 ` Junio C Hamano
  2020-11-24 22:12   ` Randall S. Becker
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2020-11-24 21:51 UTC (permalink / raw)
  To: Han-Wen Nienhuys via GitGitGadget; +Cc: git, Han-Wen Nienhuys, Han-Wen Nienhuys

"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Han-Wen Nienhuys <hanwen@google.com>
>
> The sleep function is defined in wrapper.c, so it makes more sense to be a in
> system compatibility header.
>
> Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
> ---
>     move sleep_millisec to git-compat-util.h

Makes sense.

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

* RE: [PATCH] move sleep_millisec to git-compat-util.h
  2020-11-24 21:51 ` Junio C Hamano
@ 2020-11-24 22:12   ` Randall S. Becker
  2020-11-25  3:12     ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Randall S. Becker @ 2020-11-24 22:12 UTC (permalink / raw)
  To: 'Junio C Hamano',
	'Han-Wen Nienhuys via GitGitGadget'
  Cc: git, 'Han-Wen Nienhuys', 'Han-Wen Nienhuys'

On November 24, 2020 4:51 PM, Junio C Hamano wrote:
> To: Han-Wen Nienhuys via GitGitGadget <gitgitgadget@gmail.com>
> Cc: git@vger.kernel.org; Han-Wen Nienhuys <hanwenn@gmail.com>; Han-
> Wen Nienhuys <hanwen@google.com>
> Subject: Re: [PATCH] move sleep_millisec to git-compat-util.h
> 
> "Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
> > From: Han-Wen Nienhuys <hanwen@google.com>
> >
> > The sleep function is defined in wrapper.c, so it makes more sense to
> > be a in system compatibility header.
> >
> > Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
> > ---
> >     move sleep_millisec to git-compat-util.h
> 
> Makes sense.

I have a platform fix that I'd like to apply once this makes it into the
main code. The sleep_millisec uses poll(), which is rather heavy-weight on
the NonStop platform. We have a much more efficient sleep function available
(with microsecond resolution), which would be more useful unless there is a
poll side-effect on which git depends. Would this be acceptable? I could
push this at any time really.

index bcda41e374..972ecd67bf 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -4,6 +4,10 @@
 #include "cache.h"
 #include "config.h"

+#ifdef __TANDEM
+#include <cextdecs> /* for PROCESS_DELAY_ */
+#endif
+
 static int memory_limit_check(size_t size, int gentle)
 {
        static size_t limit = 0;
@@ -650,7 +654,11 @@ void write_file(const char *path, const char *fmt, ...)

 void sleep_millisec(int millisec)
 {
+#ifdef __TANDEM
+       PROCESS_DELAY_(millisec * 1000LL);
+#else
        poll(NULL, 0, millisec);
+#endif
 }

 int xgethostname(char *buf, size_t len)

Regards,
Randall


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

* Re: [PATCH] move sleep_millisec to git-compat-util.h
  2020-11-24 22:12   ` Randall S. Becker
@ 2020-11-25  3:12     ` Junio C Hamano
  2020-11-25 21:23       ` Randall S. Becker
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2020-11-25  3:12 UTC (permalink / raw)
  To: Randall S. Becker
  Cc: 'Han-Wen Nienhuys via GitGitGadget', git,
	'Han-Wen Nienhuys', 'Han-Wen Nienhuys'

"Randall S. Becker" <rsbecker@nexbridge.com> writes:

> I have a platform fix that I'd like to apply once this makes it into the
> main code. The sleep_millisec uses poll(), which is rather heavy-weight on
> the NonStop platform. We have a much more efficient sleep function available
> (with microsecond resolution), which would be more useful unless there is a
> poll side-effect on which git depends. Would this be acceptable? I could
> push this at any time really.

We strongly prefer not to contaminate generic part of source with
platform specific conditional compilation.

If this were a much larger helper function, it might make sense to
perform the compat/*.c dance, but in this case:

 * [PATCH 1/2] that implements sleep_millisec() in git-compat-util.h
   as a static inline function; and then

 * [PATCH 2/2] that does the equivalent of your patch below, but in
   git-compat-util.h

might be the cleanest.

> index bcda41e374..972ecd67bf 100644
> --- a/wrapper.c
> +++ b/wrapper.c
> @@ -4,6 +4,10 @@
>  #include "cache.h"
>  #include "config.h"
>
> +#ifdef __TANDEM
> +#include <cextdecs> /* for PROCESS_DELAY_ */
> +#endif
> +
>  static int memory_limit_check(size_t size, int gentle)
>  {
>         static size_t limit = 0;
> @@ -650,7 +654,11 @@ void write_file(const char *path, const char *fmt, ...)
>
>  void sleep_millisec(int millisec)
>  {
> +#ifdef __TANDEM
> +       PROCESS_DELAY_(millisec * 1000LL);
> +#else
>         poll(NULL, 0, millisec);
> +#endif
>  }
>
>  int xgethostname(char *buf, size_t len)
>
> Regards,
> Randall

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

* RE: [PATCH] move sleep_millisec to git-compat-util.h
  2020-11-25  3:12     ` Junio C Hamano
@ 2020-11-25 21:23       ` Randall S. Becker
  2020-11-25 23:12         ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Randall S. Becker @ 2020-11-25 21:23 UTC (permalink / raw)
  To: 'Junio C Hamano'
  Cc: 'Han-Wen Nienhuys via GitGitGadget', git,
	'Han-Wen Nienhuys', 'Han-Wen Nienhuys'

On November 24, 2020 10:12 PM, Junio C Hamano wrote:
> "Randall S. Becker" <rsbecker@nexbridge.com> writes:
> > I have a platform fix that I'd like to apply once this makes it into
> > the main code. The sleep_millisec uses poll(), which is rather
> > heavy-weight on the NonStop platform. We have a much more efficient
> > sleep function available (with microsecond resolution), which would be
> > more useful unless there is a poll side-effect on which git depends.
> > Would this be acceptable? I could push this at any time really.
> 
> We strongly prefer not to contaminate generic part of source with platform
> specific conditional compilation.
> 
> If this were a much larger helper function, it might make sense to perform
> the compat/*.c dance, but in this case:
> 
>  * [PATCH 1/2] that implements sleep_millisec() in git-compat-util.h
>    as a static inline function; and then
> 
>  * [PATCH 2/2] that does the equivalent of your patch below, but in
>    git-compat-util.h
> 
> might be the cleanest.
> 
> > index bcda41e374..972ecd67bf 100644
> > --- a/wrapper.c
> > +++ b/wrapper.c
> > @@ -4,6 +4,10 @@
> >  #include "cache.h"
> >  #include "config.h"
> >
> > +#ifdef __TANDEM
> > +#include <cextdecs> /* for PROCESS_DELAY_ */ #endif
> > +
> >  static int memory_limit_check(size_t size, int gentle)  {
> >         static size_t limit = 0;
> > @@ -650,7 +654,11 @@ void write_file(const char *path, const char
> > *fmt, ...)
> >
> >  void sleep_millisec(int millisec)
> >  {
> > +#ifdef __TANDEM
> > +       PROCESS_DELAY_(millisec * 1000LL); #else
> >         poll(NULL, 0, millisec);
> > +#endif
> >  }
> >
> >  int xgethostname(char *buf, size_t len)

I just chatted with my team and we think that sticking with the existing
poll call is probably better in the long term. We are planning to try to get
git to work using PUT threads - but that is a longer project for a whole
slew of reasons. It involves pulling all or most of the FLOSS stuff out, or
making that configurable to use FLOSS when not using threads and not using
FLOSS when using threads. It might be useful, however, to use usleep()
instead of poll(NULL) when threading is used on most platforms as it is a
more effective way of context switching between threads than select().

Regards,
Randall


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

* Re: [PATCH] move sleep_millisec to git-compat-util.h
  2020-11-25 21:23       ` Randall S. Becker
@ 2020-11-25 23:12         ` Junio C Hamano
  0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2020-11-25 23:12 UTC (permalink / raw)
  To: Randall S. Becker
  Cc: 'Han-Wen Nienhuys via GitGitGadget', git,
	'Han-Wen Nienhuys', 'Han-Wen Nienhuys'

"Randall S. Becker" <rsbecker@nexbridge.com> writes:

> I just chatted with my team and we think that sticking with the existing
> poll call is probably better in the long term. We are planning to try to get
> git to work using PUT threads - but that is a longer project for a whole
> slew of reasons. It involves pulling all or most of the FLOSS stuff out, or
> making that configurable to use FLOSS when not using threads and not using
> FLOSS when using threads. It might be useful, however, to use usleep()
> instead of poll(NULL) when threading is used on most platforms as it is a
> more effective way of context switching between threads than select().

Yeah, if usleep() is portable enough, that would probably be the
ideal direction to go.


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

end of thread, other threads:[~2020-11-25 23:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 19:10 [PATCH] move sleep_millisec to git-compat-util.h Han-Wen Nienhuys via GitGitGadget
2020-11-24 21:51 ` Junio C Hamano
2020-11-24 22:12   ` Randall S. Becker
2020-11-25  3:12     ` Junio C Hamano
2020-11-25 21:23       ` Randall S. Becker
2020-11-25 23:12         ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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).