Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
59853eff
Commit
59853eff
authored
Jan 23, 2013
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Global options setter
parent
d47c6aab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
16 deletions
+53
-16
include/git2/common.h
+23
-0
src/mwindow.c
+7
-16
src/util.c
+23
-0
No files found.
include/git2/common.h
View file @
59853eff
...
@@ -123,6 +123,29 @@ enum {
...
@@ -123,6 +123,29 @@ enum {
*/
*/
GIT_EXTERN
(
int
)
git_libgit2_capabilities
(
void
);
GIT_EXTERN
(
int
)
git_libgit2_capabilities
(
void
);
enum
{
GIT_OPT_MWINDOW_SIZE
,
GIT_OPT_MWINDOW_MAPPED_LIMIT
};
/**
* Set or query a library global option
*
* Available options:
*
* opts(GIT_OPT_MWINDOW_SIZE, size_t):
* set the maximum mmap window size
*
* opts(GIT_OPT_MWINDOW_MAPPED_LIMIT, size_t):
* set the maximum amount of memory that can be mapped at any time
* by the library
*
* @param option Option key
* @param ... value to set the option
*/
GIT_EXTERN
(
void
)
git_libgit2_opts
(
int
option
,
...);
/** @} */
/** @} */
GIT_END_DECL
GIT_END_DECL
...
...
src/mwindow.c
View file @
59853eff
...
@@ -20,17 +20,8 @@
...
@@ -20,17 +20,8 @@
#define DEFAULT_MAPPED_LIMIT \
#define DEFAULT_MAPPED_LIMIT \
((1024 * 1024) * (sizeof(void*) >= 8 ? 8192ULL : 256UL))
((1024 * 1024) * (sizeof(void*) >= 8 ? 8192ULL : 256UL))
/*
size_t
git_mwindow__window_size
=
DEFAULT_WINDOW_SIZE
;
* These are the global options for mmmap limits.
size_t
git_mwindow__mapped_limit
=
DEFAULT_MAPPED_LIMIT
;
* TODO: allow the user to change these
*/
static
struct
{
size_t
window_size
;
size_t
mapped_limit
;
}
_mw_options
=
{
DEFAULT_WINDOW_SIZE
,
DEFAULT_MAPPED_LIMIT
,
};
/* Whenever you want to read or modify this, grab git__mwindow_mutex */
/* Whenever you want to read or modify this, grab git__mwindow_mutex */
static
git_mwindow_ctl
mem_ctl
;
static
git_mwindow_ctl
mem_ctl
;
...
@@ -166,7 +157,7 @@ static git_mwindow *new_window(
...
@@ -166,7 +157,7 @@ static git_mwindow *new_window(
git_off_t
offset
)
git_off_t
offset
)
{
{
git_mwindow_ctl
*
ctl
=
&
mem_ctl
;
git_mwindow_ctl
*
ctl
=
&
mem_ctl
;
size_t
walign
=
_mw_options
.
window_size
/
2
;
size_t
walign
=
git_mwindow__
window_size
/
2
;
git_off_t
len
;
git_off_t
len
;
git_mwindow
*
w
;
git_mwindow
*
w
;
...
@@ -179,16 +170,16 @@ static git_mwindow *new_window(
...
@@ -179,16 +170,16 @@ static git_mwindow *new_window(
w
->
offset
=
(
offset
/
walign
)
*
walign
;
w
->
offset
=
(
offset
/
walign
)
*
walign
;
len
=
size
-
w
->
offset
;
len
=
size
-
w
->
offset
;
if
(
len
>
(
git_off_t
)
_mw_options
.
window_size
)
if
(
len
>
(
git_off_t
)
git_mwindow__
window_size
)
len
=
(
git_off_t
)
_mw_options
.
window_size
;
len
=
(
git_off_t
)
git_mwindow__
window_size
;
ctl
->
mapped
+=
(
size_t
)
len
;
ctl
->
mapped
+=
(
size_t
)
len
;
while
(
_mw_options
.
mapped_limit
<
ctl
->
mapped
&&
while
(
git_mwindow__
mapped_limit
<
ctl
->
mapped
&&
git_mwindow_close_lru
(
mwf
)
==
0
)
/* nop */
;
git_mwindow_close_lru
(
mwf
)
==
0
)
/* nop */
;
/*
/*
* We treat
_mw_options.mapped_limit
as a soft limit. If we can't find a
* We treat
`mapped_limit`
as a soft limit. If we can't find a
* window to close and are above the limit, we still mmap the new
* window to close and are above the limit, we still mmap the new
* window.
* window.
*/
*/
...
...
src/util.c
View file @
59853eff
...
@@ -34,6 +34,29 @@ int git_libgit2_capabilities()
...
@@ -34,6 +34,29 @@ int git_libgit2_capabilities()
;
;
}
}
/* Declarations for tuneable settings */
extern
size_t
git_mwindow__window_size
;
extern
size_t
git_mwindow__mapped_limit
;
void
git_libgit2_opts
(
int
key
,
...)
{
va_list
ap
;
va_start
(
ap
,
key
);
switch
(
key
)
{
case
GIT_OPT_MWINDOW_SIZE
:
git_mwindow__window_size
=
va_arg
(
ap
,
size_t
);
break
;
case
GIT_OPT_MWINDOW_MAPPED_LIMIT
:
git_mwindow__mapped_limit
=
va_arg
(
ap
,
size_t
);
break
;
}
va_end
(
ap
);
}
void
git_strarray_free
(
git_strarray
*
array
)
void
git_strarray_free
(
git_strarray
*
array
)
{
{
size_t
i
;
size_t
i
;
...
...
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