Getcwd performance issues | Unix Linux Forums | Solaris

  Go Back    


Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle.

Getcwd performance issues

Solaris


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-15-2013
KotekBury KotekBury is offline
Registered User
 
Join Date: Jun 2013
Last Activity: 16 June 2013, 2:54 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Getcwd performance issues

Hello everyone,
recently we have been experiencing performance issues with chmod. We managed to narrow it down to getcwd.


Code:
The following folder exists:
 /Folder1/subfol1/subfol2/subfol3

cd /Folder1/subfol1/subfol2/subfol3 

truss -D pwd 2>&1 | grep getcwd
 0.0001 getcwd("/folder1/subfol1/subfol2/subfol3", 1025) = 0

-- rename subfol3 to subfol4
cd ..
mv subfol3 subfol4

-enter new folder and analyze pwd

cd subfol4
truss -D pwd 2>&1 | grep getcwd
 0.2789 getcwd("/folder1/subfol1/subfol2/subfol4", 1025) = 0

-- rename to the original name
cd ..
mv subfol4 subfol3
cd subfol3

-- analyze pwd
truss -D pwd 2>&1 | grep getcwd
 0.0001 getcwd("/folder1/subfol1/subfol2/subfol3", 1025) = 0

Question: why is there a difference in a response time after renaming the folder ?


Code:
uname -a
SunOS algenib 5.10 Generic_147440-19 sun4u sparc SUNW,SPARC-Enterprise


Last edited by Scott; 06-15-2013 at 08:30 AM.. Reason: Please use code tags
Sponsored Links
    #2  
Old 06-15-2013
Don Cragun's Avatar
Don Cragun Don Cragun is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 29 August 2014, 7:37 AM EDT
Location: San Jose, CA, USA
Posts: 4,468
Thanks: 176
Thanked 1,499 Times in 1,271 Posts
Note that the cd utility is a shell built-in; so the results of a test like this could vary widely from shell to shell.

Most shells will need to set the variable PWD when they start. Some shells will remember some number of directories they have seen in calls to cd and if they have seen a target direcotry path before, they can change the value of PWD (a side effect of calling cd) by looking at an in memory cache of previously visited directories. When you renamed subfol3 to subfol4, the shell's cache didn't contain an entry for subfol4 and had to make at least one system call to determine if subfol4 was a real directory or a symbolic link to a directory.

When you renamed subfol4 back to subfol3, the shell's cache could have contained an entry for subfol3, so it may have assumed that its cache was still valid.

If you look at the truss output (instead of just looking at the getcwd line in the output) you might be able to glean what is going on under the covers. You haven't said whether either of the subfol3 or subfol4 directories had been visited before the output you showed. My guess would be that you had visited subfol3 before, to get the results you showed, but without a lot more details this is purely speculation.
Sponsored Links
    #3  
Old 06-15-2013
KotekBury KotekBury is offline
Registered User
 
Join Date: Jun 2013
Last Activity: 16 June 2013, 2:54 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for the suggestion but I can also reproduce it with a newly created folder:


Code:
>> mkdir test
>> cd test
>> truss -D pwd 2>&1 | grep getcwd
0.0001 getcwd("/opt_local/product/test", 1025) = 0
>> cd ..
>> mv test test1
>> cd test1
>> truss -D pwd 2>&1 | grep getcwd
0.2130 getcwd("/opt_local/product/test1", 1025) = 0
>> cd ..
>> mv test1 test
>> cd test
>> truss -D pwd 2>&1 | grep getcwd
 0.0001 getcwd("/opt_local/product/test", 1025) = 0

As soon as I rename it back to test1 it becomes slow again.
Session or shell change has no effect on it.


The same does not happen on a similar server with a different OS level
SunOS 5.10 Generic_147147-26 sun4u sparc SUNW,SPARC-Enterprise
    #4  
Old 06-15-2013
Don Cragun's Avatar
Don Cragun Don Cragun is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 29 August 2014, 7:37 AM EDT
Location: San Jose, CA, USA
Posts: 4,468
Thanks: 176
Thanked 1,499 Times in 1,271 Posts
Quote:
Originally Posted by KotekBury View Post
thanks for the suggestion but I can also reproduce it with a newly created folder:


Code:
>> mkdir test
>> cd test
>> truss -D pwd 2>&1 | grep getcwd
0.0001 getcwd("/opt_local/product/test", 1025) = 0
>> cd ..
>> mv test test1
>> cd test1
>> truss -D pwd 2>&1 | grep getcwd
0.2130 getcwd("/opt_local/product/test1", 1025) = 0
>> cd ..
>> mv test1 test
>> cd test
>> truss -D pwd 2>&1 | grep getcwd
 0.0001 getcwd("/opt_local/product/test", 1025) = 0

As soon as I rename it back to test1 it becomes slow again.
Session or shell change has no effect on it.
Of course. Renaming a directory or creating a new directory is exactly the same condition for this discussion; the shell is seeing a directory name that is not in its cache.
Quote:
Originally Posted by KotekBury View Post
The same does not happen on a similar server with a different OS level
SunOS 5.10 Generic_147147-26 sun4u sparc SUNW,SPARC-Enterprise
As I said before, different shells may show different results. Even if the pathname of the shell you're using on the two servers is the same, there is no guarantee that the shell's processing remains the same from release to release. Changes in the OS itself or the filesystem type underlying the directories involved could also have a profound effect.
Sponsored Links
    #5  
Old 06-16-2013
KotekBury KotekBury is offline
Registered User
 
Join Date: Jun 2013
Last Activity: 16 June 2013, 2:54 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
I'm still not convienced about your argumentation. If the shell cache played a role then I would expect the exactly oposite results. How can you explain the fact that a newly created folder yields better results than a renamed one?
As you can see above I visited the 2 folders the same way and only once after the creation.
The issue does not seem to occour for new folders.

Moreover, the real directory under a question is an existing application folder, which have been visited hundreds of times over the last few years. We have noticed the drop in the response time only recently.
The above Code was just a demonstration of how we manged to reproduce the issue.

No changes were made to shell, OS or hardware that would explain any of this.

any other suggestions or am I missing something here ?
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
zfs send receive performance issues fugitive Solaris 9 10-31-2012 12:25 PM
Performance issues for LPAR with GPFS 3.4 aixromeo AIX 1 08-24-2011 01:34 AM
Awk Performance Issues pgp_acc1 UNIX for Dummies Questions & Answers 4 09-07-2009 07:14 AM
raidctl performance issues skamal4u Solaris 1 06-03-2009 11:12 PM
shell script performance issues --Urgent icefish Shell Programming and Scripting 18 12-14-2007 09:43 AM



All times are GMT -4. The time now is 08:01 AM.