Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
bbe72558
Commit
bbe72558
authored
Mar 08, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c953e319
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
2 deletions
+34
-2
go/zodb/db.go
go/zodb/db.go
+23
-2
go/zodb/δtail.go
go/zodb/δtail.go
+7
-0
go/zodb/δtail_test.go
go/zodb/δtail_test.go
+4
-0
No files found.
go/zodb/db.go
View file @
bbe72558
...
...
@@ -103,12 +103,16 @@ type DB struct {
// FIXME for now we just fix
//
// Tδkeep = 10min
// δkeep = 10
//
// and keep δtail coverage for Tδkeep time
// and keep δtail coverage for Tδkeep time, with ensuring that we keep
// at least δkeep entries not to loose cache on very seldom commits:
//
// timelen(δtail) = Tδkeep
// len(δtail) ≥ δkeep
δtail
*
ΔTail
// [](rev↑, []oid)
tδkeep
time
.
Duration
δkeep
int
// waiters for δtail.Head to become ≥ their at.
hwait
map
[
hwaiter
]
struct
{}
// set{(at, ready)}
...
...
@@ -130,6 +134,7 @@ func NewDB(stor IStorage) *DB {
hwait
:
make
(
map
[
hwaiter
]
struct
{}),
tδkeep
:
10
*
time
.
Minute
,
// see δtail discussion
δkeep
:
10
,
// ---- // ----
}
at0
:=
stor
.
AddWatch
(
db
.
watchq
)
...
...
@@ -261,9 +266,25 @@ func (db *DB) watcher() (err error) {
// forget older δtail entries
tcut
:=
db
.
δtail
.
Head
()
.
Time
()
.
Add
(
-
db
.
tδkeep
)
δcut
:=
TidFromTime
(
tcut
)
δcut
:=
TidFromTime
(
tcut
)
// cut by δTkeep rule
//fmt.Printf("db: watcher: δtail: = (%s, %s]\n", db.δtail.Tail(), db.δtail.Head())
//fmt.Printf("db: watcher: forget <= %s\n", δcut)
// take db.δkeep into account, so that we preserve len(δtail) ≥ δkeep
δtail
:=
db
.
δtail
.
Data
()
rcut
:=
δcut
// cut by δkeep rule
if
l
:=
len
(
δtail
);
l
>
db
.
δkeep
{
rcut
=
δtail
[
l
-
db
.
δkeep
-
1
]
.
Rev
rcut
-=
1
// ForgetPast forgets by ≤
}
else
{
rcut
=
0
// keep everything
}
if
rcut
<
δcut
{
//fmt.Printf("db: watcher: forget %s -> %s (seldom commits)\n", δcut, rcut)
δcut
=
rcut
}
db
.
δtail
.
ForgetPast
(
δcut
)
//fmt.Printf("db: watcher: δtail: -> (%s, %s]\n", db.δtail.Tail(), db.δtail.Head())
...
...
go/zodb/δtail.go
View file @
bbe72558
...
...
@@ -87,6 +87,13 @@ func (δtail *ΔTail) Len() int {
return
len
(
δtail
.
tailv
)
}
// Data returns slice with δtail data.
//
// The caller must not modify returned slice.
func
(
δtail
*
ΔTail
)
Data
()
/*readonly*/
[]
ΔRevEntry
{
return
δtail
.
tailv
}
// Head returns newest database state for which δtail has history coverage.
//
// Head is ↑ on Append, in particular it does not ↓ on Forget even if δtail becomes empty.
...
...
go/zodb/δtail_test.go
View file @
bbe72558
...
...
@@ -61,6 +61,10 @@ func TestΔTail(t *testing.T) {
t
.
Fatalf
(
"tailv:
\n
have: %v
\n
want: %v"
,
δtail
.
tailv
,
tailv
)
}
if
d
:=
δtail
.
Data
();
!
tailvEqual
(
d
,
tailv
)
{
t
.
Fatalf
(
"Data():
\n
have: %v
\n
want: %v"
,
d
,
tailv
)
}
if
l
:=
δtail
.
Len
();
l
!=
len
(
tailv
)
{
t
.
Fatalf
(
"Len() -> %d ; want %d"
,
l
,
len
(
tailv
))
}
...
...
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