Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on unix systems, look for /etc/timezone first before /etc/localtime #3

Merged

Conversation

karenetheridge
Copy link
Contributor

On ubuntu systems (Etch and later), /etc/localtime is a copy of
/usr/share/zoneinfo/$zonefile, which means DateTime::TimeZone::Local::Unix
spends a lot of time looking for the file that matches it, and it takes a LONG
time (especially when done many times for a single page load!); whereas
/etc/timezone also exists, and this is a simple file that contains the name of
the timezone, so checking for this file first would be much faster.

On ubuntu systems (Etch and later), /etc/localtime is a copy of
/usr/share/zoneinfo/$zonefile, which means DateTime::TimeZone::Local::Unix
spends a lot of time looking for the file that matches it, and it takes a LONG
time (especially when done many times for a single page load!); whereas
/etc/timezone also exists, and this is a simple file that contains the name of
the timezone, so checking for this file first would be much faster.
autarch added a commit that referenced this pull request Oct 26, 2014
on unix systems, look for /etc/timezone first before /etc/localtime
@autarch autarch merged commit 87ae6de into houseabsolute:master Oct 26, 2014
@karenetheridge karenetheridge deleted the topic/timezone_file_ordering branch October 26, 2014 18:21
@ppisar
Copy link

ppisar commented Nov 3, 2014

I don't like this change because standard library does not consider /etc/timezone at all. So if the /etc/timezone does not match /etc/localtime, this Perl code will not match the system.

@karenetheridge
Copy link
Contributor Author

On Mon, Nov 03, 2014 at 03:46:45AM -0800, ppisar wrote:

I don't like this change because standard library does not consider /etc/timezone at all. So if the /etc/timezone does not match /etc/localtime, this Perl code will not match the system.

That sounds like a misconfigured system to me. The ubuntu documentation
says to change /etc/timezone --
https://help.ubuntu.com/community/UbuntuTime#Using_the_Command_Line_.28terminal.29

@ppisar
Copy link

ppisar commented Nov 4, 2014

On Mon, Nov 03, 2014 at 09:32:19AM -0800, Karen Etheridge wrote:

On Mon, Nov 03, 2014 at 03:46:45AM -0800, ppisar wrote:

I don't like this change because standard library does not consider
/etc/timezone at all. So if the /etc/timezone does not match
/etc/localtime, this Perl code will not match the system.

That sounds like a misconfigured system to me. The ubuntu documentation says
to change /etc/timezone --
https://help.ubuntu.com/community/UbuntuTime#Using_the_Command_Line_.28terminal.29

This is specific for Ubuntu.

Now read http://man7.org/linux/man-pages/man3/tzset.3.html how any
application gets the time zone configuration on any POSIX system.

-- Petr

@karenetheridge
Copy link
Contributor Author

On Mon, Nov 03, 2014 at 11:35:12PM -0800, ppisar wrote:

On Mon, Nov 03, 2014 at 09:32:19AM -0800, Karen Etheridge wrote:

On Mon, Nov 03, 2014 at 03:46:45AM -0800, ppisar wrote:

I don't like this change because standard library does not consider
/etc/timezone at all. So if the /etc/timezone does not match
/etc/localtime, this Perl code will not match the system.

That sounds like a misconfigured system to me. The ubuntu documentation says
to change /etc/timezone --
https://help.ubuntu.com/community/UbuntuTime#Using_the_Command_Line_.28terminal.29

This is specific for Ubuntu.

Now read http://man7.org/linux/man-pages/man3/tzset.3.html how any
application gets the time zone configuration on any POSIX system.

Do you have a suggestion for a solution?

@ppisar
Copy link

ppisar commented Nov 5, 2014

On Tue, Nov 04, 2014 at 08:44:57AM -0800, Karen Etheridge wrote:

On Mon, Nov 03, 2014 at 11:35:12PM -0800, ppisar wrote:

On Mon, Nov 03, 2014 at 09:32:19AM -0800, Karen Etheridge wrote:

On Mon, Nov 03, 2014 at 03:46:45AM -0800, ppisar wrote:

I don't like this change because standard library does not consider
/etc/timezone at all. So if the /etc/timezone does not match
/etc/localtime, this Perl code will not match the system.

That sounds like a misconfigured system to me. The ubuntu documentation
says to change /etc/timezone --
https://help.ubuntu.com/community/UbuntuTime#Using_the_Command_Line_.28terminal.29

This is specific for Ubuntu.

Now read http://man7.org/linux/man-pages/man3/tzset.3.html how any
application gets the time zone configuration on any POSIX system.

Do you have a suggestion for a solution?

Parse the /etc/localtime instead of guessing time zone name and then
looking it up in the database bundled with the DateTime-TimeZone which slips
behind the system database. Like in this patch
https://rt.cpan.org/Public/Bug/Display.html?id=55029.

(The patch is just a last reason fall-back, but I'm going to remove the
database from DateTime-TimeZone completly and make the
DateTime::TimeZone::Tzfile approach the first default option (just after TZ
environment variable).)

-- Petr

@karenetheridge
Copy link
Contributor Author

It occurs to me that this bit of the process:

/etc/localtime is a copy of
/usr/share/zoneinfo/$zonefile, which means DateTime::TimeZone::Local::Unix
spends a lot of time looking for the file that matches it, and it takes a LONG
time (especially when done many times for a single page load!)

...really should be only done once per process, and the result cached locally in DateTime::TimeZone::Local::Unix. There's no need to keep parsing the file multiple times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants