Copy link to clipboard
Copied
We implemented the retrieval function through the ITextwalker interface. After upgrading from SDK 13 to SDK 14, the performance of the retrieval operation deteriorated. However, it was not all the data, but only some data performed worse. The data that took more than 200 milliseconds in SDK 13 took more than 700 milliseconds in SDK 114.
The following is our code implementation. Can anyone give me some advises? Thank you。
/** SearchText
Search text in a story ITextWalker
* @Param textStart [in] the start position of the text search range
* @Param textLength [in] the length of the text search range
* @Param searchText [in] text to be searched
* @Param foundStartPos [out] the start position of the found text
* @retval kSuccess success
* @retval kFailure failure
* @note
*/
ErrorCode TextModelHelper::SearchText(int32 textStart, int32 textLength, const WideString& searchText, int32& foundStartPos)
{
ErrorCode status = kFailure;
do
{
if (!m_StoryUIDRef || searchText.CharCount()<=0) break;
ISession* currSess = GetExecutionContextSession();
InterfacePtr<IK2ServiceRegistry> serviceRegistry(currSess, UseDefaultIID());
if (!serviceRegistry) break;
InterfacePtr<IK2ServiceProvider> serviceProvider(serviceRegistry->QueryServiceProviderByClassID(kTextWalkerService, kTextWalkerServiceProviderBoss));
if (!serviceProvider) break;
InterfacePtr<IWorkspace> sessionWorkSpace(currSess->QueryWorkspace());
if (!sessionWorkSpace) break;
#if(defined ID_CS5 || defined ID_CS5_5 || defined ID_CS6 || defined ID_CC || defined ID_CC2014 || defined ID_CC2015 || defined ID_CC2017 || defined ID_CC2018 || defined ID_CC2019 || defined ID_CC2020 || defined ID_CC2021 || defined ID_CC2022 || defined ID_CC2023)
InterfacePtr<IFindChangeOptions>
findChangeOptions(static_cast<IFindChangeOptions*>
(::CreateObject(kSpellCheckFindChangeDataBoss, IID_IFINDCHANGEOPTIONS)));
#else
InterfacePtr<IFindChangeOptions> findChangeOptions((IFindChangeOptions*)sessionWorkSpace->QueryInterface(IID_IFINDCHANGEOPTIONS));
#endif
if (!findChangeOptions)
break;
findChangeOptions->SetFindString(searchText, IFindChangeOptions::kTextSearch);
InterfacePtr<ITextWalker> textWalker(serviceProvider, UseDefaultIID());
if (!textWalker) break;
if (!textWalker->IsWalking())
{
InterfacePtr<ITextModel> textModel(m_StoryUIDRef, UseDefaultIID());
if (!textModel) break;
InterfacePtr<ITextWalkerScope> textWalkerScope(Utils<IWalkerScopeFactoryUtils>()->QueryRangeWalkerScope(textModel, textStart, textLength));
if (!textWalkerScope) break;
InterfacePtr<ITextWalkerClient> textWalkerClient(static_cast<ITextWalkerClient*>(::CreateObject2<ITextWalkerClient>(kFindChangeClientBoss)));
if (!textWalkerClient) break;
textWalker->Initialize(textWalkerClient, textWalkerScope, findChangeOptions, nil);
}
CAlert::SetShowAlerts(kFalse);
InterfacePtr<ICommand> findCmd(CmdUtils::CreateCommand(kFindTextCmdBoss));
InterfacePtr<IFindChangeCmdData> findChangeCmdData(findCmd, UseDefaultIID());
if (!findChangeCmdData) break;
findChangeCmdData->SetTextWalker(textWalker);
findChangeCmdData->SetRange(m_StoryUIDRef, textStart, textStart+textLength);
status = CmdUtils::ProcessCommand(findCmd);
if (status != kSuccess) break;
CAlert::SetShowAlerts(kTrue);
// Get the found position
int32 foundEndPos = 0;
findChangeCmdData->GetRange(foundStartPos, foundEndPos);
textWalker->Halt();
status = (findChangeCmdData->GetFindChangeResult() != IFindChangeService::kFailure && foundStartPos >= textStart && foundStartPos <= (textStart + textLength)) ? kSuccess : kFailure;
}
while(kFalse);
return status;
}
Copy link to clipboard
Copied
HI @dorinho,
This would require elaborate testing before a conclusion can be drawn and since you said this happens not with all text it becomes all the more hard to test. Is there any possibility that you could open a technical support ticket with Adobe, as that would be the best and I suppose the only way to get some help on this. In the meanwhile I am tagging @Rishabh_Tiwari to this thread so that if possible he can connect to the Adobe InDesign team and ask if any changes were made to this portion of the codebase.
-Manan
Copy link to clipboard
Copied
Thank you for your enthusiastic reply. Next I will investigate what kind of data will slow down. If technical support is needed, I will propose separately.
Copy link to clipboard
Copied
Hi @Manan Joshi @dorinho ,
Thank you for reaching out. I have shared this with the team and will update the discussion as soon as I hear from the them.
Thanks
Rishabh
Copy link to clipboard
Copied
Before I further seek technical support, I want to ask something. When processing the same data, CC2019 takes nearly 20 times as long as CC2018. Although the processing time has decreased slightly since CC2020, it is still about 10 times that of CC2018. I used the Visual Studio Profiler tool to generate reports on the processing of these three versions respectively. It is obvious that many SDK processing has slowed down since version 14. I want to know if InDesign itself has undergone a major overhaul since CC2019.
Also, I want to confirm that if I seek technical support, can I just provide the Visual Studio Profiler reports generated by processing the same data?
Copy link to clipboard
Copied
Is this about a generic find-change operation, as per the comment?
Why are you then using kSpellCheckFindChangeDataBoss? Sure, when I search the SDK for text walker the spell check example comes up first, but there is also SnpFindAndReplace ...
That stretch of "defined ID…" looks also suspicious - it will fall back to the #else approach with every new version or when the expected macro somehow is missing. Do you really still support pre CS5 as default case? Does the compiler produce code on the intended side of the #if #else ?
Beyond that, performance is not in a SDK, but in the executing application. If you think your current version is behaving differently compared to an earlier one, use a profiler on both to drill down on the code that's actually wasting the time.
Copy link to clipboard
Copied
Thank you! I will check it.