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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7c832590816ff7438ea62c6692d2567775088ab27567d407b2294b8caafced7
4
- data.tar.gz: 3c4b7313117776731de9b91cca81c472cd6dfe9dd64e7390381e54194b912b77
3
+ metadata.gz: 4b573b12e8a04a0b69a2e4c33c6ccd17c21c1c14a52a644c87564738388de546
4
+ data.tar.gz: b4c888226e04aee8054ff26d056cc04f34fd3a1fb29455ff6c77ce4dd2103d45
5
5
  SHA512:
6
- metadata.gz: b7569a94be51517bb2860cf368849aaa22f89f96b04a16a29fafba294c6ad72c8b03e359f35024a482a82f657edfb36710ec7f60504ff4422663a96cc0a3ebc8
7
- data.tar.gz: 7991d24eae8705444c781b35e00fe74b3f3087e015b3ac2cc1d59d250e0afddd70b7c23006dabf85d4d14dbc2c920a78f1e7e6068edc235c0b45dbdb4af5c17b
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.5.0)
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.2)
41
+ minitest (6.0.5)
42
42
  drb (~> 2.0)
43
43
  prism (~> 1.5)
44
- minitest-reporters (1.7.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.0)
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.3.1)
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
- query all facts from an empty factbase 0.00
254
- insert 20000 facts 0.66
255
- export 20000 facts 0.02
256
- import 410996 bytes (20000 facts) 0.02
257
- insert 10 facts 0.00
258
- query 10 times w/txn 2.13
259
- query 10 times w/o txn 0.12
260
- modify 10 attrs w/txn 1.62
261
- delete 10 facts w/txn 10.22
262
- build index on 5000 facts 0.03
263
- export 5000 facts with index 0.04
264
- import 5000 facts with persisted index 0.03
265
- query 5000 facts using persisted index 0.08
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-02-26 at 06:08,
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/22430010182
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] || 'all'
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
- fb = Factbase.new
73
- fb = Factbase::CachedFactbase.new(fb)
74
- fb = Factbase::IndexedFactbase.new(fb)
75
- fb = Factbase::SyncFactbase.new(fb)
76
- if bname == 'all'
77
- Dir['benchmark/bench_*.rb'].each do |f|
78
- require_relative f
79
- Kernel.send(File.basename(f).gsub(/\.rb$/, '').to_sym, b, fb)
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
- else
82
- f = "benchmark/#{bname}.rb"
82
+ files.each do |f|
83
83
  require_relative f
84
- Kernel.send(File.basename(f).gsub(/\.rb$/, '').to_sym, b, fb)
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, @idx, @fresh)
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
@@ -9,5 +9,5 @@
9
9
  # License:: MIT
10
10
  class Factbase
11
11
  # Current version of the gem (changed by .rultor.yml on every release)
12
- VERSION = '0.19.9' unless const_defined?(:VERSION)
12
+ VERSION = '0.19.10' unless const_defined?(:VERSION)
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.9
4
+ version: 0.19.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko