Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0031920Open CASCADE[OCCT] OCCT:Application Frameworkpublic2020-11-11 17:332021-01-02 12:19
Assigned Tonds 
PlatformOSOS Version
Product Version 
Target Version[OCCT] 7.6.0*Fixed in Version 
Summary0031920: Application Framework - speed up methods of getting label by entry and vice versa
DescriptionIt's proposed to implement some cache for Label, Entry methods of TDF_Tool.

When these methods are called for the same values, it takes too much time in a custom application. If we have some cache, it lets save time. If cache used, it requires additional memory for it. By this reason, it would be nice to make such cache optional. Then, the application might decide which way is more preferable.

It's proposed to implement it on OCCT side, not in the custom application because there are some internal places in OCCT, where this methods are also used, e.g.
STEPCAFControl_Reader for TDF_Tool::Entry,
XCAFPrs_DocumentExplorer, for TDF_Tool::Label.

The proposal of container is:
- tbb::concurrent_unordered_map<TCollection_AsciiString, TDF_Label, TCollection_AsciiStringHash, TCollection_AsciiStringEqual> m_ELCache;
(if tbb is used)
- std::map<TCollection_AsciiString, TDF_Label> m_ELCache;

TagsNo tags attached.
Test case number
Attached Files

- Relationships

-  Notes
git (administrator)
2020-12-31 12:51

Branch CR31920 has been created by vro.

SHA-1: a0cd478719e7d29da73614a0b4cb11cd7f389cfd

Detailed log of new commits:

Author: vro
Date: Thu Dec 31 12:52:03 2020 +0300

    0031920: Application Framework - speed up methods of getting label by entry and vice versa
    A table for fast access to the labels by entry is implemented in OCAF document. A method TDF_Data::SetAccessByEntries(true) fills-in a table for fast access to the labels. New labels, created later will be added to the table automatically. The method TDF_Tool::Label() will search the entry in the table and then, if not found, will call the old code. Disabling of usage of the table (by calling of TDF_Data::SetAccessByEntries(false)) cleans the internal table of entries - labels. By default, the table is not used.
    This improvement is useful for large documents with a lot of labels, and if the application uses entries to get labels. The application should call TDF_Data::SetAccessByEntries(true) for a document and then, the method TDF_Tool::Label() called inside OCAF and XCAF will use the fast access to the labels and speed-up the application.
    Also, the method TDF_Tool::Entry() is improved (by MPV).
    Modified files:
    - TDF_Data.hxx and cxx: the new methods SetAccessByEntries(bool), IsAccessByEntries() and GetLabel(entry) are implemented. No need to use the method GetLabel() directly. It is called in TDF_Tool::Label().
    - TDF_Label.cxx: adding of a newly created label to the table of entries - labels.
    - TDF_Tool.cxx: the method Entry() is accelerated (by MPV) and Label() is improved to call TDF_Data::GetLabel().
    - DDF_DataCommands.cxx: a new draw-command is added SetAccessByEntry, which sets or unsets usage of the table for fast access to the labels. Usage of the draw-command is illustrated in a new test "bugs caf bug31920".
    - bugs caf bug31920: a new simple test to check TDF_Tool::Label() when fast access to the labels is on.
    For test purpose I set usage of the table by default to true (temporary) and re-ran all test grids - it works!
git (administrator)
2020-12-31 15:34

Branch CR31920_1 has been created by vro.

SHA-1: 8f2e87bddeffea13156ca6b0d7a1ae7619403844

Detailed log of new commits:

Author: vro
Date: Thu Dec 31 15:34:42 2020 +0300

    0031920: Application Framework - speed up methods of getting label by entry and vice versa
    // A method TDF_Data::AddLabel() is set Standard_EXPORT.
kgv (developer)
2021-01-01 21:45

vro wrote:

Dear MPV, couldyou review, please: [^] [^]

A test "perf NCollection A1" fails, I don't know a reason... but it seems my little changes can't introduce such a regression...

The branch:
OCCT - CR31920_1
Products - none.

A test:
bugs caf bug31920 - it tests a new draw-command SetAccessByEntry.
kgv (developer)
2021-01-01 21:49
edited on: 2021-01-01 21:50

Vlad, speeding up Application Framework is great.

But could you please share here some measured numbers comparing performance of old/new implementations and some use case(s) where this difference is noticeable (probably, the latter could be shared by Natalia)?

vro (developer)
2021-01-02 09:23

Hello Kirill!

Certainly, I have some data on performance. But the end user is Natasha and only she could say whether it speeds-up the application or not...

So, the test:
- for TDF_Tool::Entry(), it was improved by Mikhail. For a big document (taranis.xbf, about 100Mb) I call TDF_Tool::Entry() for each label of the document 20 times. It was 1.5 seconds, now 0.08 seconds - about 20 times faster.
- for TDF_Tool::Label(), a similar test: I collected entries for all labels of the document and call TDF_Tool::Label() for each label 20 times. It was 0.5 seconds, now 0.04 seconds - about 10 times faster. Mikhail has an idea to use an array instead of a map. If this improvement is not enough, we could use an array... but it is more complicated and I would like to use a simple solution before implementation of a complicated.

May be it worth waiting for the tests from Natasha? I didn't ask her for testing yet...
mpv (developer)
2021-01-02 11:06

  Dear Natalia,

Could you check the improvements implemented are good for your demands and may be share with us some numbers of speedup on real use-cases.
vro (developer)
2021-01-02 12:19

Dear Natasha, by default the acceleration of the method TDF_Tool::Entry() is inactive. In order to activate it call a method anylabel.Data()->SetAccessByEntries(true). Nothing more is needed, since then it should work faster, hope so...

- Issue History
Date Modified Username Field Change
2020-11-11 17:33 nds New Issue
2020-11-11 17:33 nds Assigned To => mpv
2020-12-05 20:54 kgv Summary Application Framework - speed up methods of getting label by entry and vise versa => Application Framework - speed up methods of getting label by entry and vice versa
2020-12-31 12:51 git Note Added: 0097998
2020-12-31 15:34 git Note Added: 0097999
2021-01-01 16:33 vro Status new => resolved
2021-01-01 16:33 vro Steps to Reproduce Updated View Revisions
2021-01-01 21:45 kgv Note Added: 0098004
2021-01-01 21:45 kgv Steps to Reproduce Updated View Revisions
2021-01-01 21:49 kgv Note Added: 0098005
2021-01-01 21:50 kgv Note Edited: 0098005 View Revisions
2021-01-02 09:23 vro Note Added: 0098006
2021-01-02 11:06 mpv Note Added: 0098007
2021-01-02 11:06 mpv Assigned To mpv => nds
2021-01-02 11:06 mpv Status resolved => feedback
2021-01-02 12:19 vro Note Added: 0098010

Copyright © 2000 - 2021 MantisBT Team
Powered by Mantis Bugtracker