Issue 89730 - osl_getAbsoluteFileURL() lstat()s too much
Summary: osl_getAbsoluteFileURL() lstat()s too much
Status: CONFIRMED
Alias: None
Product: porting
Classification: Code
Component: code (show other issues)
Version: DEV300m12
Hardware: All All
: P3 Trivial (vote)
Target Milestone: 4.x
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-21 14:58 UTC by kendy
Modified: 2013-07-29 17:55 UTC (History)
8 users (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
The patch. (10.07 KB, patch)
2008-05-21 15:13 UTC, kendy
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description kendy 2008-05-21 14:58:48 UTC
The implementation of osl_getAbsoluteFileURL_impl_() is done so that it 
lstat()s O(n^2), instead of n paths (where n is depth of the path).  It is 
because it calls realpath() on each of the components of the path, and 
realpath() itself does lstat() on each of the components itself.  I'll attach 
a patch that changes it to lstat()ing n paths only - on the price of _not_ 
absolutizing non-existing paths.  To me, it seems like a good deal ;-) - if 
the path does not exist, who cares what part of it is absolute?  In the case 
it was created later, nobody can expect what part of that path were symlinks 
etc. anyway, and it should go through the full realpath() process anyway.

Here's a part of strace log showing the wrong behavior:

10406 19:41:49.765833 lstat("/local", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.765887 lstat("/local", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.765936 lstat("/local/inst", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.765993 lstat("/local", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.766042 lstat("/local/inst", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.766092 lstat("/local/inst/OpenOffice.org3.0-m12", 
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10406 19:41:49.766153 lstat("/local", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.766202 lstat("/local/inst", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.766251 lstat("/local/inst/OpenOffice.org3.0-m12", 
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10406 19:41:49.766303 
lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org", {st_mode=S_IFDIR|
0755, st_size=4096, ...}) = 0
10406 19:41:49.766363 lstat("/local", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.766412 lstat("/local/inst", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.766461 lstat("/local/inst/OpenOffice.org3.0-m12", 
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10406 19:41:49.766514 
lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org", {st_mode=S_IFDIR|
0755, st_size=4096, ...}) = 0
10406 19:41:49.766568 
lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure", 
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10406 19:41:49.766628 lstat("/local", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.766677 lstat("/local/inst", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.766726 lstat("/local/inst/OpenOffice.org3.0-m12", 
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10406 19:41:49.766779 
lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org", {st_mode=S_IFDIR|
0755, st_size=4096, ...}) = 0
10406 19:41:49.766833 
lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure", 
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10406 19:41:49.766887 
lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure/bin", 
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10406 19:41:49.766949 lstat("/local", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.766997 lstat("/local/inst", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.767047 lstat("/local/inst/OpenOffice.org3.0-m12", 
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10406 19:41:49.767099 
lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org", {st_mode=S_IFDIR|
0755, st_size=4096, ...}) = 0
10406 19:41:49.767153 
lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure", 
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10406 19:41:49.767208 
lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure/lib", 
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0

The patch changes it to simple:

10406 19:41:49.766949 lstat("/local", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.766997 lstat("/local/inst", {st_mode=S_IFDIR|0755, 
st_size=4096, ...}) = 0
10406 19:41:49.767047 lstat("/local/inst/OpenOffice.org3.0-m12", 
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10406 19:41:49.767099 
lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org", {st_mode=S_IFDIR|
0755, st_size=4096, ...}) = 0
10406 19:41:49.767153 
lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure", 
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10406 19:41:49.767208 
lstat("/local/inst/OpenOffice.org3.0-m12/openoffice.org/ure/lib", 
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
Comment 1 kendy 2008-05-21 15:13:26 UTC
Created attachment 53820 [details]
The patch.
Comment 2 kai.sommerfeld 2008-05-23 13:02:27 UTC
hro: Please take over.
Comment 3 kai.sommerfeld 2008-05-23 13:02:50 UTC
.
Comment 4 hennes.rohling 2008-05-30 13:55:54 UTC
Retargeted.
Comment 5 kai.sommerfeld 2008-06-03 09:17:29 UTC
hro: We should integrate this patch in 3.1
Comment 6 hennes.rohling 2008-08-15 14:47:25 UTC
Good approach but there were ancious reason that it also worked with nonexistant
paths. will review it for scheduled release.
Comment 7 hennes.rohling 2008-09-15 10:00:22 UTC
Ping
Comment 8 kendy 2008-09-15 12:31:27 UTC
hro: Please, any more info needed from my side?
Comment 9 kendy 2008-09-26 14:41:38 UTC
Back to myself, apparently there are problems with this on MacOS X.
Comment 10 Mathias_Bauer 2009-04-16 12:27:09 UTC
Kendy, in case you are still working on this: Mikhail (mav) is now maintaining
the osl_file stuff.

As 3.1 obviously is an unrealistic target I changed it to 3.x.
Comment 11 Rob Weir 2013-03-11 15:02:06 UTC
I'm adding this comment to all open issues with Issue Type == PATCH.  We have 220 such issues, many of them quite old.  I apologize for that.  

We need your help in prioritizing which patches should be integrated into our next release, Apache OpenOffice 4.0.

If you have submitted a patch and think it is applicable for AOO 4.0, please respond with a comment to let us know.

On the other hand, if the patch is no longer relevant, please let us know that as well.

If you have any general questions or want to discuss this further, please send a note to our dev mailing list:  dev@openoffice.apache.org

Thanks!

-Rob