Skip to content

Unit of work slower when cache is enabled. #100

@ralphga

Description

@ralphga

Describe the bug
Hello! We are trying to optimize our code and is looking at enabling di_Configurations__c.UsePlatformCacheToStoreBindings__c
And we are noticing that the UnitOfWork newInstance is slower when cache is enabled. I might be wrong but it seems that if cache is enabled, it is adding the binding to the cache but not using the cached binding in the succeeding execution?

To Reproduce
I have in total:

  • 8 domain bindings
  • 26 selector bindings
  • 19 service bindings
  • 6 unit of working bindings

In a scratch org, running the code below yields these CPU time results:
 fflib_ISObjectUnitOfWork uow = new fflib_SObjectUnitOfWork();

  • Disabled cache CPU time: 222 out of 10000
  • Enabled cache CPU time (3rd execution): 585 out of 10000

Selector test with 1 id, WHERE ID IN condition
List<XObject> tickets = XObjectSelector.newInstance().selectByIds(new Set<String> { 'XObjectID' });

  • Disabled cache CPU time: 254 out of 10000
  • Enabled cache Maximum CPU time: 0 out of 10000 --

Expected behavior
Faster execution is our expected result which we found in both Selector and Domain. Unfortunately the UnitOfWork newInstance is slower when cache is enabled.

Screenshots and text of error observed
Unit of work, cache Disabled
image

Unit of work, cache Enabled (3rd Execution)
image

Version
yes, we have the latest

Metadata

Metadata

Assignees

Labels

activeThis issue is currently activebugSomething isn't workinginvestigatinginvestigating

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions