Open Bug 2092094 Opened 8 days ago Updated 1 day ago

Move aMessage instead of copying it in LlamaGenerateTask::MaybePushMessageLocked

Categories

(Core :: Machine Learning: On Device, defect, P3)

defect

Tracking

()

Tracking Status
firefox-esr153 --- wontfix
firefox160 --- wontfix
firefox161 --- wontfix
firefox162 --- wontfix
firefox163 --- fix-optional

People

(Reporter: Sylvestre, Unassigned, Mentored)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: good-first-bug, regression, Whiteboard: [lang=c++])

Filing as a good first bug to learn workflows.

Coverity (CID 1700948, COPY_INSTEAD_OF_MOVE) flags LlamaGenerateTask::MaybePushMessageLocked in toolkit/components/ml/backends/llama/LlamaRunner.cpp. The function takes mozilla::Maybe<LlamaChatResponse> aMessage by value, and when the queue is empty it copies it:

} else {
  messageToResolve = aMessage;
}

aMessage is not used again after this branch, so it should be moved:

} else {
  messageToResolve = std::move(aMessage);
}

Only change this else branch: in the other branch aMessage is passed to mMessagesQueue.Enqueue() and must stay as it is.

Link to the code:
https://searchfox.org/firefox-main/source/toolkit/components/ml/backends/llama/LlamaRunner.cpp

To verify the fix:

./mach build
./mach format toolkit/components/ml/backends/llama/LlamaRunner.cpp

Tutorial to contribute:
https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
https://firefox-source-docs.mozilla.org/contributing/stack_quickref.html

Please don't ask for the bug to be assigned. It will be automatically assigned to the first patch.

Set release status flags based on info from the regressing bug 1973711

Severity: -- → S3
Priority: -- → P3

Set release status flags based on info from the regressing bug 1973711

You need to log in before you can comment on or make changes to this bug.