factbase 0.19.9 → 0.19.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/README.md +16 -82
- data/Rakefile +16 -13
- data/lib/factbase/indexed/indexed_factbase.rb +3 -2
- data/lib/factbase/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4b573b12e8a04a0b69a2e4c33c6ccd17c21c1c14a52a644c87564738388de546
|
|
4
|
+
data.tar.gz: b4c888226e04aee8054ff26d056cc04f34fd3a1fb29455ff6c77ce4dd2103d45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a96ff08cc40deb0d17e25cc7c30f8e67d5c09b0179e623d7e941ade194ac7c52c2135730fb4a813faf7370097a1d151db74e1559de81a619bf572becb1eec408
|
|
7
|
+
data.tar.gz: 1f57d718a82c2c8d107c033c3d8b59440170822f5810fadfc3b99837cf4072493e96ec8a39bff41c73a913cc3dba75837a9f4ecc0804976da37ebe02c09b1777
|
data/Gemfile.lock
CHANGED
|
@@ -16,7 +16,7 @@ PATH
|
|
|
16
16
|
GEM
|
|
17
17
|
remote: https://rubygems.org/
|
|
18
18
|
specs:
|
|
19
|
-
ansi (1.
|
|
19
|
+
ansi (1.6.0)
|
|
20
20
|
ast (2.4.3)
|
|
21
21
|
backtrace (0.4.1)
|
|
22
22
|
benchmark (0.5.0)
|
|
@@ -38,13 +38,13 @@ GEM
|
|
|
38
38
|
loog (0.8.0)
|
|
39
39
|
ellipsized
|
|
40
40
|
logger (~> 1.0)
|
|
41
|
-
minitest (6.0.
|
|
41
|
+
minitest (6.0.5)
|
|
42
42
|
drb (~> 2.0)
|
|
43
43
|
prism (~> 1.5)
|
|
44
|
-
minitest-reporters (1.
|
|
44
|
+
minitest-reporters (1.8.0)
|
|
45
45
|
ansi
|
|
46
46
|
builder
|
|
47
|
-
minitest (>= 5.0)
|
|
47
|
+
minitest (>= 5.0, < 7)
|
|
48
48
|
ruby-progressbar
|
|
49
49
|
nokogiri (1.19.0-arm64-darwin)
|
|
50
50
|
racc (~> 1.4)
|
|
@@ -64,14 +64,14 @@ GEM
|
|
|
64
64
|
psych (5.3.1)
|
|
65
65
|
date
|
|
66
66
|
stringio
|
|
67
|
-
qbash (0.8.
|
|
67
|
+
qbash (0.8.3)
|
|
68
68
|
backtrace (> 0)
|
|
69
69
|
elapsed (> 0)
|
|
70
70
|
loog (> 0)
|
|
71
71
|
tago (> 0)
|
|
72
72
|
racc (1.8.1)
|
|
73
73
|
rainbow (3.1.1)
|
|
74
|
-
rake (13.
|
|
74
|
+
rake (13.4.2)
|
|
75
75
|
rdoc (7.1.0)
|
|
76
76
|
erb
|
|
77
77
|
psych (>= 4.0.0)
|
data/README.md
CHANGED
|
@@ -249,91 +249,25 @@ This is the result of the benchmark:
|
|
|
249
249
|
|
|
250
250
|
<!-- benchmark_begin -->
|
|
251
251
|
```text
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
query
|
|
266
|
-
export 5000 facts without index 0.02
|
|
267
|
-
import 5000 facts without index 0.01
|
|
268
|
-
query 5000 facts building index on-the-fly 0.07
|
|
269
|
-
query 15k facts sel: 20% card: 10 absent plain 0.60
|
|
270
|
-
query 15k facts sel: 20% card: 10 absent indexed(cold) 0.17
|
|
271
|
-
query 15k facts sel: 20% card: 10 absent indexed(warm) 0.16
|
|
272
|
-
query 15k facts sel: 20% card: 10 exists plain 0.57
|
|
273
|
-
query 15k facts sel: 20% card: 10 exists indexed(cold) 0.17
|
|
274
|
-
query 15k facts sel: 20% card: 10 exists indexed(warm) 0.13
|
|
275
|
-
query 15k facts sel: 20% card: 10 eq plain 0.86
|
|
276
|
-
query 15k facts sel: 20% card: 10 eq indexed(cold) 0.26
|
|
277
|
-
query 15k facts sel: 20% card: 10 eq indexed(warm) 0.19
|
|
278
|
-
query 15k facts sel: 20% card: 10 not plain 1.16
|
|
279
|
-
query 15k facts sel: 20% card: 10 not indexed(cold) 0.53
|
|
280
|
-
query 15k facts sel: 20% card: 10 not indexed(warm) 0.51
|
|
281
|
-
query 15k facts sel: 20% card: 10 gt plain 0.88
|
|
282
|
-
query 15k facts sel: 20% card: 10 gt indexed(cold) 0.29
|
|
283
|
-
query 15k facts sel: 20% card: 10 gt indexed(warm) 0.24
|
|
284
|
-
query 15k facts sel: 20% card: 10 lt plain 0.87
|
|
285
|
-
query 15k facts sel: 20% card: 10 lt indexed(cold) 0.29
|
|
286
|
-
query 15k facts sel: 20% card: 10 lt indexed(warm) 0.20
|
|
287
|
-
query 15k facts sel: 20% card: 10 and eq plain 1.43
|
|
288
|
-
query 15k facts sel: 20% card: 10 and eq indexed(cold) 0.91
|
|
289
|
-
query 15k facts sel: 20% card: 10 and eq indexed(warm) 0.50
|
|
290
|
-
query 15k facts sel: 20% card: 10 and complex plain 1.38
|
|
291
|
-
query 15k facts sel: 20% card: 10 and complex indexed(cold) 0.51
|
|
292
|
-
query 15k facts sel: 20% card: 10 and complex indexed(warm) 0.45
|
|
293
|
-
query 15k facts sel: 20% card: 10 one plain 0.75
|
|
294
|
-
query 15k facts sel: 20% card: 10 one indexed(cold) 0.21
|
|
295
|
-
query 15k facts sel: 20% card: 10 one indexed(warm) 0.16
|
|
296
|
-
query 15k facts sel: 20% card: 10 or plain 2.02
|
|
297
|
-
query 15k facts sel: 20% card: 10 or indexed(cold) 0.46
|
|
298
|
-
query 15k facts sel: 20% card: 10 or indexed(warm) 0.32
|
|
299
|
-
query 15k facts sel: 20% card: 10 unique plain 1.87
|
|
300
|
-
query 15k facts sel: 20% card: 10 unique indexed(cold) 0.67
|
|
301
|
-
query 15k facts sel: 20% card: 10 unique indexed(warm) 0.42
|
|
302
|
-
(and (eq what 'issue-was-closed') (exists... -> 200 1.08
|
|
303
|
-
(and (eq what 'issue-was-closed') (exists... -> 200/txn 1.24
|
|
304
|
-
(and (eq what 'issue-was-closed') (exists... -> zero 1.08
|
|
305
|
-
(and (eq what 'issue-was-closed') (exists... -> zero/txn 1.28
|
|
306
|
-
transaction rollback on factbase with 100000 facts 0.01
|
|
307
|
-
(gt time '2024-03-23T03:21:43Z') 0.31
|
|
308
|
-
(gt cost 50) 0.14
|
|
309
|
-
(eq title 'Object Thinking 5000') 0.02
|
|
310
|
-
(and (eq foo 42.998) (or (gt bar 200) (absent z... 0.03
|
|
311
|
-
(and (exists foo) (not (exists blue))) 1.23
|
|
312
|
-
(eq id (agg (always) (max id))) 2.80
|
|
313
|
-
(join "c<=cost,b<=bar" (eq id (agg (always) (ma... 4.44
|
|
314
|
-
(and (eq what "foo") (join "w<=what" (and (eq i... 7.39
|
|
315
|
-
delete! 0.44
|
|
316
|
-
(and (eq issue *) (eq repository *) (eq what '*') (eq where '*')) 0.41
|
|
317
|
-
Taped.append() x50000 0.02
|
|
318
|
-
Taped.each() x125 1.10
|
|
319
|
-
Taped.delete_if() x375 0.86
|
|
320
|
-
50000 facts: plain read (no txn) 4.10
|
|
321
|
-
50000 facts: read-only txn (no copy) 5.33
|
|
322
|
-
50000 facts: plain insert (no txn) 0.00
|
|
323
|
-
50000 facts: insert in txn (no copy triggered) 0.00
|
|
324
|
-
50000 facts: plain modify (no txn) 28.59
|
|
325
|
-
50000 facts: modify in txn (copy triggered) 37.78
|
|
326
|
-
100000 facts: plain read (no txn) 8.33
|
|
327
|
-
100000 facts: read-only txn (no copy) 12.80
|
|
328
|
-
100000 facts: plain insert (no txn) 0.00
|
|
329
|
-
100000 facts: insert in txn (no copy triggered) 0.00
|
|
330
|
-
100000 facts: plain modify (no txn) 57.26
|
|
331
|
-
100000 facts: modify in txn (copy triggered) 75.84
|
|
252
|
+
user
|
|
253
|
+
void scan 0.001102
|
|
254
|
+
20k facts: export: 2991KB 0.854774
|
|
255
|
+
20k facts: import: 2991KB 1.035671
|
|
256
|
+
50k facts: read 0.000138
|
|
257
|
+
50k facts: read in txn 0.002754
|
|
258
|
+
50k facts: insert 0.000090
|
|
259
|
+
50k facts: insert in txn 0.000243
|
|
260
|
+
50k facts: modify 1.085214
|
|
261
|
+
50k facts: modify in txn 2.480409
|
|
262
|
+
12k facts: large query: match 3k 14.187596
|
|
263
|
+
12k facts: large query: match 3k in txn 19.396334
|
|
264
|
+
12k facts: large query: match zero 15.139695
|
|
265
|
+
12k facts: large query: match zero in txn 21.046074
|
|
332
266
|
```
|
|
333
267
|
|
|
334
268
|
The results were calculated in [this GHA job][benchmark-gha]
|
|
335
|
-
on 2026-
|
|
269
|
+
on 2026-04-16 at 17:08,
|
|
336
270
|
on Linux with 4 CPUs.
|
|
337
271
|
<!-- benchmark_end -->
|
|
338
272
|
|
|
339
|
-
[benchmark-gha]: https://github.com/yegor256/factbase/actions/runs/
|
|
273
|
+
[benchmark-gha]: https://github.com/yegor256/factbase/actions/runs/24523476155
|
data/Rakefile
CHANGED
|
@@ -61,27 +61,30 @@ RuboCop::RakeTask.new(:rubocop) do |task|
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
desc 'Benchmark them all'
|
|
64
|
-
task :benchmark, [:name] do |_t, args|
|
|
65
|
-
bname = args[:name] || '
|
|
64
|
+
task :benchmark, [:name, :cycles] do |_t, args|
|
|
65
|
+
bname = args[:name] || 'essential'
|
|
66
|
+
cycles = (args[:cycles] || 5).to_i
|
|
66
67
|
require_relative 'lib/factbase'
|
|
67
68
|
require_relative 'lib/factbase/cached/cached_factbase'
|
|
68
69
|
require_relative 'lib/factbase/indexed/indexed_factbase'
|
|
69
70
|
require_relative 'lib/factbase/sync/sync_factbase'
|
|
70
71
|
require 'benchmark'
|
|
71
72
|
Benchmark.bm(60) do |b|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
files =
|
|
74
|
+
case bname
|
|
75
|
+
when 'all'
|
|
76
|
+
Dir['benchmark/bench_*.rb']
|
|
77
|
+
when 'essential'
|
|
78
|
+
%w[empty serialization txns large_query].map { |f| "benchmark/bench_#{f}.rb" }
|
|
79
|
+
else
|
|
80
|
+
["benchmark/#{bname}.rb"]
|
|
80
81
|
end
|
|
81
|
-
|
|
82
|
-
f = "benchmark/#{bname}.rb"
|
|
82
|
+
files.each do |f|
|
|
83
83
|
require_relative f
|
|
84
|
-
|
|
84
|
+
fb = Factbase.new
|
|
85
|
+
fb = Factbase::IndexedFactbase.new(fb)
|
|
86
|
+
fb = Factbase::CachedFactbase.new(fb)
|
|
87
|
+
Kernel.send(File.basename(f).gsub(/\.rb$/, '').to_sym, b, fb, cycles)
|
|
85
88
|
end
|
|
86
89
|
end
|
|
87
90
|
end
|
|
@@ -61,11 +61,12 @@ class Factbase::IndexedFactbase
|
|
|
61
61
|
# Run an ACID transaction.
|
|
62
62
|
# @return [Factbase::Churn] How many facts have been changed (zero if rolled back)
|
|
63
63
|
def txn
|
|
64
|
+
inner_idx = {}
|
|
64
65
|
result =
|
|
65
66
|
@origin.txn do |fbt|
|
|
66
|
-
yield Factbase::IndexedFactbase.new(fbt,
|
|
67
|
+
yield Factbase::IndexedFactbase.new(fbt, inner_idx, @fresh)
|
|
67
68
|
end
|
|
68
|
-
@idx.clear
|
|
69
|
+
@idx.clear if result.deleted.positive? || result.added.positive?
|
|
69
70
|
@fresh.clear
|
|
70
71
|
result
|
|
71
72
|
end
|
data/lib/factbase/version.rb
CHANGED