Skip to content

Perf/optimise wpool process#218

Merged
elbrujohalcon merged 2 commits intomainfrom
perf/optimise_wpool_process
Feb 21, 2026
Merged

Perf/optimise wpool process#218
elbrujohalcon merged 2 commits intomainfrom
perf/optimise_wpool_process

Conversation

@NelsonVides
Copy link
Collaborator

@NelsonVides NelsonVides commented Feb 21, 2026

Reduce the number of operations that the wpool_process needs to do on every loop:

  • Options get all its keys as mandatory, and will extract them all at once instead of on subsequent map gets in separate modules.
  • utils task_init and task_end are moved into wpool_process, as within the same module the JIT can optimise types, and readouts can be done all at once
  • task_end doesn't do erase(wpool_task) but put(wpool_task, undefined), as this way the process dictionary doesn't need any hash-table or bucket reshuffling, potentially.
  • notify_queue_manager chooses the function to call directly, instead of doing a dynamic call, it's more performant as it doesn't need to lookup the function pointer at runtime, instead it only needs to choose it based on a function clause of just 4 elements that are in the same module, so again, JIT can optimise more aggressively.

Reduce the number of operations that the wpool_process needs to do on
every loop:

- Options get all its keys as mandatory, and will extract them all at
  once instead of on subsequent map gets in separate modules.
- utils task_init and task_end are moved into wpool_process, as within
  the same module the JIT can optimise types, and readouts can be done
  all at once
- task_end doesn't do erase(wpool_task) but put(wpool_task, undefined),
  as this way the process dictionary doesn't need any hash-table or
  bucket reshuffling, potentially.
- notify_queue_manager chooses the function to call directly, instead of
  doing a dynamic call, it's more performant as it doesn't need to
  lookup the function pointer at runtime, instead it only needs to
  choose it based on a function clause of just 4 elements that are in
  the same module, so again, JIT can optimise more aggressively.
@NelsonVides NelsonVides self-assigned this Feb 21, 2026
Copy link
Member

@elbrujohalcon elbrujohalcon left a comment

Choose a reason for hiding this comment

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

I LOVE ❤️ this kind of pull requests! This is the type of PR I would never ever come up with, even if my life would depend on it.
Thank you, very much, @NelsonVides !

@elbrujohalcon elbrujohalcon merged commit e516797 into main Feb 21, 2026
2 checks passed
@elbrujohalcon elbrujohalcon deleted the perf/optimise_wpool_process branch February 21, 2026 15:39
@elbrujohalcon
Copy link
Member

Let me know if you want me to generate a new release… or, I'm not sure if you can, but if you can… go for it and generate/publish one yourself whenever you want.

@NelsonVides
Copy link
Collaborator Author

Released and published, thank you very much for reviews 😁

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.

2 participants