httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject Re: ap_current_time() is not intuitive
Date Sat, 08 Jan 2000 16:23:23 GMT
On Wed, 5 Jan 2000, Ryan Bloom wrote:

> It's confusing because you are looking at things in the middle of being
> finished.

ah ok.

> The APR stat structure will look something like:
>     ap_fileperms_t protection
>     ap_uid_t       user
>     ap_gid_t       group
>     ap_off_t       size
>     ap_time_t      *atime
>     ap_time_t      *mtime
>     ap_time_t      *ctime

um.  yuck!

to stat a file you'll have to allocate 3 ap_time_t structures, and 3
struct timeval structures (assuming ap_time_t remains as it currently
is with a struct timeval *).  that's a lot of memory allocation dude.

time is an scalar quantity, you've got at least two pointer indirections
to use any of the time structures there.  actually it's worse than just
two pointer indirections, there's also a test for non-NULL, because
i'm assuming a struct atime_t can have a NULL currtime, with non-NULL
explodedtime.

> Basically, the ap_time_t structure will remain the same, on Unix:
>     struct timeval   /* I need to remember why I didn't use time_t, but I
>                         think it had to do with some of the current Apache
>                         functions. */
>     struct tm;
> When we get the current time, we will fill out the struct timeval. When we
> explode it, we fill out the struct tm with either localtime or gmtime.

exploded time and scalar time are two completely different beasts.
leave them as separate.  don't put them into a single structure with some
boolean.  it'll waste memory, and waste cpu cycles.

> Could you please tell Microsoft that, because the only function I have
> found to do get the current time on a system is GetSystemTime, and that
> returns the equivalent of an expanded time on Windows.

even unix gets it wrong -- gettimeofday() returns seconds and milliseconds,
and you have to multiply by 1000000 to create a 64-bit scalar.

on windows you'd have to do a few more multiplies...

right now you're crippling unix to get rid of a few multiplies on windows.
that's wrong.

> > the functions such as ap_get_fileatime would take an ap_time_t *, and
> > there would be a function equivalent to time(0) for getting the current
> > time as an ap_time_t.
> 
> If we were just unix, this is how I would have designed it, we aren't.  I
> was trying to make a good attempt at improving performance on Windows.

you're optimizing without profiling.  which is a common mistake :)

you've optimized the place where ap_time_t is written, but pushed cycles
into all the places where ap_time_t is read.

time sucks.

Dean


Mime
View raw message