Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
c1a117cc
Commit
c1a117cc
authored
May 25, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize pathInode.GetPath().
* Hand code a reverse string join. * Do not use defer. Speed up: 7%
parent
fff4a3ab
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
20 deletions
+35
-20
README
README
+5
-6
fuse/misc.go
fuse/misc.go
+0
-9
fuse/misc_test.go
fuse/misc_test.go
+1
-0
fuse/pathfs.go
fuse/pathfs.go
+29
-5
No files found.
README
View file @
c1a117cc
...
@@ -4,9 +4,8 @@ GO-FUSE: native bindings for the FUSE kernel module.
...
@@ -4,9 +4,8 @@ GO-FUSE: native bindings for the FUSE kernel module.
HIGHLIGHTS
HIGHLIGHTS
* High speed: about 50% slower than libfuse, using the gc
* High speed: as fast as libfuse using the gc compiler for single
compiler. For most real world applications, the difference will be
threaded loads.
negligible.
* Supports in-process mounting of different FileSystems onto
* Supports in-process mounting of different FileSystems onto
subdirectories of the FUSE mount.
subdirectories of the FUSE mount.
...
@@ -80,9 +79,9 @@ interface, all kernel caching turned off, median stat time:
...
@@ -80,9 +79,9 @@ interface, all kernel caching turned off, median stat time:
platform libfuse Go-FUSE difference (%)
platform libfuse Go-FUSE difference (%)
Lenovo T60/Fedora17 (1cpu) 349us 3
79us 9
% slower
Lenovo T60/Fedora17 (1cpu) 349us 3
55us 2
% slower
Lenovo T400/Lucid (1cpu) 133us 140us 5% slower
//
Lenovo T400/Lucid (1cpu) 133us 140us 5% slower
Dell T3500/Lucid (1cpu) 78us 78us 0%
//
Dell T3500/Lucid (1cpu) 78us 78us 0%
CREDITS
CREDITS
...
...
fuse/misc.go
View file @
c1a117cc
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
"log"
"log"
"os"
"os"
"reflect"
"reflect"
"strings"
"syscall"
"syscall"
"time"
"time"
"unsafe"
"unsafe"
...
@@ -88,14 +87,6 @@ func Version() string {
...
@@ -88,14 +87,6 @@ func Version() string {
return
"unknown"
return
"unknown"
}
}
func
ReverseJoin
(
rev_components
[]
string
,
sep
string
)
string
{
components
:=
make
([]
string
,
len
(
rev_components
))
for
i
,
v
:=
range
rev_components
{
components
[
len
(
rev_components
)
-
i
-
1
]
=
v
}
return
strings
.
Join
(
components
,
sep
)
}
func
CurrentOwner
()
*
Owner
{
func
CurrentOwner
()
*
Owner
{
return
&
Owner
{
return
&
Owner
{
Uid
:
uint32
(
os
.
Getuid
()),
Uid
:
uint32
(
os
.
Getuid
()),
...
...
fuse/misc_test.go
View file @
c1a117cc
...
@@ -49,3 +49,4 @@ func TestLinkAt(t *testing.T) {
...
@@ -49,3 +49,4 @@ func TestLinkAt(t *testing.T) {
t
.
Fatal
(
"Ino mismatch"
,
s1
,
s2
)
t
.
Fatal
(
"Ino mismatch"
,
s1
,
s2
)
}
}
}
}
fuse/pathfs.go
View file @
c1a117cc
...
@@ -219,18 +219,42 @@ func (n *pathInode) RLockTree() func() {
...
@@ -219,18 +219,42 @@ func (n *pathInode) RLockTree() func() {
// GetPath returns the path relative to the mount governing this
// GetPath returns the path relative to the mount governing this
// inode. It returns nil for mount if the file was deleted or the
// inode. It returns nil for mount if the file was deleted or the
// filesystem unmounted.
// filesystem unmounted.
func
(
n
*
pathInode
)
GetPath
()
(
path
string
)
{
func
(
n
*
pathInode
)
GetPath
()
string
{
defer
n
.
RLockTree
()()
if
n
==
n
.
pathFs
.
root
{
return
""
}
pathLen
:=
0
rev_components
:=
make
([]
string
,
0
,
10
)
// The simple solution is to collect names, and reverse join
// them, them, but since this is a hot path, we take some
// effort to avoid allocations.
n
.
pathFs
.
pathLock
.
RLock
()
p
:=
n
p
:=
n
for
;
p
.
Parent
!=
nil
;
p
=
p
.
Parent
{
for
;
p
.
Parent
!=
nil
;
p
=
p
.
Parent
{
rev_components
=
append
(
rev_components
,
p
.
Name
)
pathLen
+=
len
(
p
.
Name
)
+
1
}
}
pathLen
--
if
p
!=
p
.
pathFs
.
root
{
if
p
!=
p
.
pathFs
.
root
{
n
.
pathFs
.
pathLock
.
RUnlock
()
return
".deleted"
return
".deleted"
}
}
path
=
ReverseJoin
(
rev_components
,
"/"
)
pathBytes
:=
make
([]
byte
,
pathLen
)
end
:=
len
(
pathBytes
)
for
p
=
n
;
p
.
Parent
!=
nil
;
p
=
p
.
Parent
{
l
:=
len
(
p
.
Name
)
copy
(
pathBytes
[
end
-
l
:
],
p
.
Name
)
end
-=
len
(
p
.
Name
)
+
1
if
end
>
0
{
pathBytes
[
end
]
=
'/'
}
}
n
.
pathFs
.
pathLock
.
RUnlock
()
path
:=
string
(
pathBytes
)
if
n
.
pathFs
.
Debug
{
if
n
.
pathFs
.
Debug
{
log
.
Printf
(
"Inode %d = %q (%s)"
,
n
.
Inode
()
.
nodeId
,
path
,
n
.
fs
.
String
())
log
.
Printf
(
"Inode %d = %q (%s)"
,
n
.
Inode
()
.
nodeId
,
path
,
n
.
fs
.
String
())
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment