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
b55cc8ad
Commit
b55cc8ad
authored
Jun 23, 2014
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fuse: use sync.Pool for the buffers that read from the kernel.
parent
9d459bc5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
17 deletions
+12
-17
fuse/server.go
fuse/server.go
+12
-17
No files found.
fuse/server.go
View file @
b55cc8ad
...
...
@@ -39,9 +39,12 @@ type Server struct {
started
chan
struct
{}
// Pool for request structs.
reqPool
sync
.
Pool
// Pool for raw requests data
readPool
sync
.
Pool
reqMu
sync
.
Mutex
readPool
[][]
byte
reqReaders
int
outstandingReadBufs
int
kernelSettings
InitIn
...
...
@@ -140,6 +143,7 @@ func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server
opts
:
&
o
,
}
ms
.
reqPool
.
New
=
func
()
interface
{}
{
return
new
(
request
)
}
ms
.
readPool
.
New
=
func
()
interface
{}
{
return
make
([]
byte
,
o
.
MaxWrite
+
PAGESIZE
)
}
optStrs
:=
opts
.
Options
if
opts
.
AllowOther
{
optStrs
=
append
(
optStrs
,
"allow_other"
)
...
...
@@ -182,11 +186,10 @@ func (ms *Server) DebugData() string {
var
r
int
ms
.
reqMu
.
Lock
()
r
=
len
(
ms
.
readPool
)
+
ms
.
reqReaders
r
=
ms
.
reqReaders
ms
.
reqMu
.
Unlock
()
s
+=
fmt
.
Sprintf
(
" read buffers: %d (sz %d )"
,
r
,
ms
.
opts
.
MaxWrite
/
PAGESIZE
+
1
)
s
+=
fmt
.
Sprintf
(
" readers: %d"
,
r
)
return
s
}
...
...
@@ -196,21 +199,13 @@ const _MAX_READERS = 2
// Returns a new request, or error. In case exitIdle is given, returns
// nil, OK if we have too many readers already.
func
(
ms
*
Server
)
readRequest
(
exitIdle
bool
)
(
req
*
request
,
code
Status
)
{
var
dest
[]
byte
ms
.
reqMu
.
Lock
()
if
ms
.
reqReaders
>
_MAX_READERS
{
ms
.
reqMu
.
Unlock
()
return
nil
,
OK
}
req
=
ms
.
reqPool
.
Get
()
.
(
*
request
)
l
:=
len
(
ms
.
readPool
)
if
l
>
0
{
dest
=
ms
.
readPool
[
l
-
1
]
ms
.
readPool
=
ms
.
readPool
[
:
l
-
1
]
}
else
{
dest
=
make
([]
byte
,
ms
.
opts
.
MaxWrite
+
PAGESIZE
)
}
dest
:=
ms
.
readPool
.
Get
()
.
([]
byte
)
ms
.
outstandingReadBufs
++
ms
.
reqReaders
++
ms
.
reqMu
.
Unlock
()
...
...
@@ -233,7 +228,7 @@ func (ms *Server) readRequest(exitIdle bool) (req *request, code Status) {
ms
.
reqMu
.
Lock
()
if
!
gobbled
{
ms
.
outstandingReadBufs
--
ms
.
readPool
=
append
(
ms
.
readPool
,
dest
)
ms
.
readPool
.
Put
(
dest
)
dest
=
nil
}
ms
.
reqReaders
--
...
...
@@ -258,9 +253,9 @@ func (ms *Server) returnRequest(req *request) {
req
.
clear
()
ms
.
reqMu
.
Lock
()
if
req
.
bufferPoolOutputBuf
!=
nil
{
ms
.
readPool
=
append
(
ms
.
readPool
,
req
.
bufferPoolInputBuf
)
ms
.
outstandingReadBufs
--
ms
.
readPool
.
Put
(
req
.
bufferPoolInputBuf
)
req
.
bufferPoolInputBuf
=
nil
ms
.
outstandingReadBufs
--
}
ms
.
reqPool
.
Put
(
req
)
ms
.
reqMu
.
Unlock
()
...
...
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