Closed vsbogd closed 6 years ago
The code looks reasonable to me. I'll let Nil look at it and merge. I made comments, but those don't need to be fixed before merging.
Nil might want to review the complexity of the ScopeLink -- it seems to be over-simplified, and not very much like a "typical" scope link.
re diary.txt
, for now, leave that alone, and/or start a new one. Some time late, in a few weeks/months, I'll rename diary.txt
to something else, update it, make comments about old vs new.
Anyway, I like it. Results on scale-free graphs might be the most useful, the most real-life-like
I have found that numbers above are not correct as I used debug versions of libraries by accident. Correct numbers are below and they are ten times better:
$ ./atomspace/atomspace/benchmark
2018-05-31 18:18:44
Running ./atomspace/atomspace/benchmark
Run on (12 X 4000 MHz CPU s)
CPU Caches:
L1 Data 32K (x6)
L1 Instruction 32K (x6)
L2 Unified 256K (x6)
L3 Unified 12288K (x1)
-----------------------------------------------------------------------------
Benchmark Time CPU Iterations
-----------------------------------------------------------------------------
BM_CreateScopeLinkWithVariableList 583 ns 583 ns 1207156
BM_CreateScopeLinkWithoutVariableList 441 ns 441 ns 1601252
BM_CreateScopeLinkWithLambdaLink 409 ns 409 ns 1713858
BM_AddSameScopeLink 1160 ns 1160 ns 601468
BM_AddScopeLink/4096 1316 ns 1316 ns 505942
BM_AddScopeLink/8192 1614 ns 1614 ns 423016
BM_AddScopeLink/16384 1691 ns 1691 ns 381658
BM_CreateEvaluationLink 292 ns 292 ns 2386244
BM_AddSameEvaluationLink 793 ns 793 ns 896268
BM_AddEvaluationLink/16384 1014 ns 1014 ns 670038
BM_AddEvaluationLink/32768 1070 ns 1070 ns 585950
BM_AddEvaluationLink/65536 1185 ns 1185 ns 437785
@vsbogd Just curious, what was compiled in debug mode? google benchmark? atomspace? cogutil? opencog benchmark? All?
atomspace and cogutil - I have two versions built: debug and release and debug was loaded because of LD_LIBRARY_PRELOAD override.
Nevertheless profile analysis gives the same results: ScopeLink adding:
- 86,57% 0,57% benchmark benchmark [.] _ZL19BM_AddSameScopeLinkRN9benchmark5StateE▒
- 86,01% _ZL19BM_AddSameScopeLinkRN9benchmark5StateE ◆
- 85,99% _ZN7opencog9AtomSpace8add_atomERKNS_6HandleEb ▒
- 78,02% _ZN7opencog9AtomTable3addESt10shared_ptrINS_4AtomEEb ▒
- 32,35% _ZN7opencog10createLinkIJRSt6vectorINS_6HandleESaIS2_EERtEEES2_DpOT_ ▒
- 23,10% _ZNK7opencog11ClassServer7factoryERKNS_6HandleE ▒
- 23,01% _ZN7opencog9ScopeLink7factoryERKNS_6HandleE ▒
- 22,84% ?? (inlined) ▒
- 21,90% ?? (inlined) ▒
- 21,49% ?? (inlined) ▒
- 21,47% ?? (inlined) ▒
- 21,01% ?? (inlined) ▒
- ?? (inlined) ▒
- 20,05% ?? (inlined) ▒
- 19,62% _ZN7opencog9ScopeLink7factoryERKNS_6HandleE ▒
- 19,27% _ZN7opencog9ScopeLinkC2ERKSt6vectorINS_6HandleE▒
+ 16,79% _ZN7opencog9ScopeLink17extract_variablesERKS▒
EvaluationLink adding:
- 89,26% 1,08% benchmark benchmark [.] _ZL24BM_AddSameEvaluationLinkRN9benchmark5S▒
- 88,18% _ZL24BM_AddSameEvaluationLinkRN9benchmark5StateE ◆
- 88,15% _ZN7opencog9AtomSpace8add_atomERKNS_6HandleEb ▒
- 80,14% _ZN7opencog9AtomTable3addESt10shared_ptrINS_4AtomEEb ▒
+ 32,21% _ZNK7opencog9AtomTable9getHandleERKSt10shared_ptrINS_4AtomEE ▒
- 20,35% _ZN7opencog10createLinkIJRSt6vectorINS_6HandleESaIS2_EERtEEES2_DpOT_ ▒
- 11,93% ?? (inlined) ▒
- 11,01% ?? (inlined) ▒
- ?? (inlined) ▒
- 7,20% ?? (inlined) ▒
- 5,56% ?? (inlined) ▒
- 4,37% ?? (inlined) ▒
- 4,30% ?? (inlined) ▒
- 2,79% ?? (inlined) ▒
- 2,10% _ZN7opencog10createLinkIJRSt6vectorINS_6HandleESaIS2_E▒
+ 2,02% _ZN7opencog4Link4initERKSt6vectorINS_6HandleESaIS2_
It looks more or less as I would expect.
Issue https://github.com/opencog/benchmark/issues/8
I have added benchmarks for creating and adding ScopeLink into atomspace. I have added same EvaluationLink tests to compare performance.
(0) Benchmark results (atomspace and cogutil debug versions) see release results below in comment https://github.com/opencog/benchmark/pull/13#issuecomment-393573327:
(1) I have used Google Benchmark to create this stuff but it can be discussed. Pros:
Contras:
(2) I have found comparing BM_AddSameScopeLink and BM_AddSameEvaluationLink profiles that main additional complexity for ScopeLink adding is copying ScopeLink. It leads to second ScopeLink.init() method call which is heavy.
BM_AddSameScopeLink profile:
BM_AddSameEvaluationLink profile: