Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PERF] Actions: Fill missing ids with fast unique values #5029

Open
wants to merge 1 commit into
base: saas-17.4
Choose a base branch
from

Conversation

rrahir
Copy link
Collaborator

@rrahir rrahir commented Sep 27, 2024

The ActionsSpecs have a defaut behaviour where we are not obligated to provide an id in the actionSpec because "CreateAction" will end up generating it on demand with an uuidv4.

However, uuidv4 can become a problem if invoked to often and it so happens that some actionSpecs related to the topbar benefit from this automatic generation. Since the topbar items are regenerated at each rendering of a spreadsheet, they can become problematic.

For instance, in Odoo test suites, they take up to 2-3% of the computation time.

This revision bypasses the call to an actual uuidv4 by forcing a fast strategy in the uuidGenerator, which accomplishes the same result, having a unique identifier for each menu item generated.

Task: 4216427

Description:

description of this task, what is implemented and why it is implemented that way.

Task: TASK_ID

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Collaborator

robodoo commented Sep 27, 2024

Pull request status dashboard

Copy link
Collaborator

@LucasLefevre LucasLefevre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

I'm wondering how high the number can get with all the repeated renders though. And if there's even a remote chance of overflowing

@@ -92,6 +92,7 @@ export function createActions(menuItems: ActionSpec[]): Action[] {
}

const uuidGenerator = new UuidGenerator();
uuidGenerator.setIsFastStrategy(true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just use a incremented number here then. Instead of instantiating a UuidGenerator for no apparent reason.
Or it's the beginning of the enterprise fizzbuzz 😄

The ActionsSpecs have a defaut behaviour where we are not obligated
to provide an id in the actionSpec because "CreateAction" will end up
generating it on demand with an uuidv4.

However, uuidv4 can become a problem if invoked to often and it so
happens that some actionSpecs related to the topbar benefit from this
automatic generation. Since the topbar items are regenerated at each
rendering of a spreadsheet, they can become problematic.

For instance, in Odoo test suites, they take up to 2-3% of the
computation time.

This revision replaces the call to uuidv4 by a simple incremented
integer which still guarantees the uniqueness of the identifier.

Task: 4216427
@rrahir rrahir force-pushed the saas-17.4-fast-menu-item-id-rar branch from 60cd0db to 03d348a Compare September 27, 2024 17:12
@rrahir
Copy link
Collaborator Author

rrahir commented Sep 27, 2024

I'm wondering how high the number can get with all the repeated renders though. And if there's even a remote chance of overflowing

I was asking myself the same question, I think that for the time being it's quite controlled. each render was below 10 calls to UUIDGenerator and seeing the value of max integer, it seems safe :D. If it starts growing too much at some point, we can always force the id later on. As I said, i don't think it's too much of a bother.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants