| Summary: | Reduce number of heap allocations on the audio thread in AudioSampleDataSource | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Chris Dumez <cdumez> | ||||||||
| Component: | Media | Assignee: | Chris Dumez <cdumez> | ||||||||
| Status: | RESOLVED FIXED | ||||||||||
| Severity: | Normal | CC: | darin, eric.carlson, ews-watchlist, ggaren, glenn, hta, jer.noble, peng.liu6, philipj, sam, sergio, tommyw, webkit-bug-importer, youennf | ||||||||
| Priority: | P2 | Keywords: | InRadar | ||||||||
| Version: | WebKit Nightly Build | ||||||||||
| Hardware: | Unspecified | ||||||||||
| OS: | Unspecified | ||||||||||
| Bug Depends on: | |||||||||||
| Bug Blocks: | 223226 | ||||||||||
| Attachments: |
|
||||||||||
|
Description
Chris Dumez
2021-03-19 19:53:22 PDT
Created attachment 423800 [details]
Patch
Created attachment 423801 [details]
Patch
Comment on attachment 423801 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=423801&action=review > Source/WebCore/ChangeLog:10 > + Reduce number of heap allocations on the audio thread in AudioSampleDataSource > + for performance reasons. I got rid of the heap allocations that I could easily > + address. Some trickier ones remain. Seems like it might be worth annotating the ones that remain and adding a comment indicating that no new heap allocations should be added due to the realtime-ness of things. > Source/WebCore/ChangeLog:23 > + > + * platform/audio/cocoa/AudioSampleDataSource.h: > + (WebCore::AudioSampleDataSource::inputDescription const): > + * platform/audio/cocoa/AudioSampleDataSource.mm: > + (WebCore::AudioSampleDataSource::AudioSampleDataSource): > + (WebCore::AudioSampleDataSource::~AudioSampleDataSource): > + (WebCore::AudioSampleDataSource::setInputFormat): > + (WebCore::AudioSampleDataSource::setOutputFormat): > + (WebCore::AudioSampleDataSource::pushSamplesInternal): > + (WebCore::AudioSampleDataSource::pushSamples): > + (WebCore::AudioSampleDataSource::pullSamplesInternal): > + (WebCore::AudioSampleDataSource::pullAvalaibleSamplesAsChunks): > + (WebCore::AudioSampleDataSource::pullSamples): Since the changes aren't all super obvious, can you fill in some details here? (In reply to Sam Weinig from comment #3) > Comment on attachment 423801 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=423801&action=review > > > Source/WebCore/ChangeLog:10 > > + Reduce number of heap allocations on the audio thread in AudioSampleDataSource > > + for performance reasons. I got rid of the heap allocations that I could easily > > + address. Some trickier ones remain. > > Seems like it might be worth annotating the ones that remain and adding a > comment indicating that no new heap allocations should be added due to the > realtime-ness of things. Well yes, that’s what I am working on. I am fixing the easy ones now and adding exceptions for the remaining ones (see bug this one is marked as a dependency of). > > > Source/WebCore/ChangeLog:23 > > + > > + * platform/audio/cocoa/AudioSampleDataSource.h: > > + (WebCore::AudioSampleDataSource::inputDescription const): > > + * platform/audio/cocoa/AudioSampleDataSource.mm: > > + (WebCore::AudioSampleDataSource::AudioSampleDataSource): > > + (WebCore::AudioSampleDataSource::~AudioSampleDataSource): > > + (WebCore::AudioSampleDataSource::setInputFormat): > > + (WebCore::AudioSampleDataSource::setOutputFormat): > > + (WebCore::AudioSampleDataSource::pushSamplesInternal): > > + (WebCore::AudioSampleDataSource::pushSamples): > > + (WebCore::AudioSampleDataSource::pullSamplesInternal): > > + (WebCore::AudioSampleDataSource::pullAvalaibleSamplesAsChunks): > > + (WebCore::AudioSampleDataSource::pullSamples): > > Since the changes aren't all super obvious, can you fill in some details > here? Ok, I will do that. I thought the changes were trivial here, I either started initializing things earlier on the main thread or I switch from uniqueptr to optional to avoid the heap allocation. Created attachment 423889 [details]
Patch
Comment on attachment 423889 [details] Patch Clearing flags on attachment: 423889 Committed r274808 (235608@main): <https://commits.webkit.org/235608@main> All reviewed patches have been landed. Closing bug. Comment on attachment 423889 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=423889&action=review > Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.h:72 > + const CAAudioStreamDescription* inputDescription() const { return m_inputDescription ? &m_inputDescription.value() : nullptr; } Seems like we could use a generic function that converts an Optional to a pointer or nullptr. |