question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reduce dependency on padding

See original GitHub issue

Many of our functions use padding to simplify vectorization of certain operations, eg:

https://github.com/librosa/librosa/blob/aec87d801144168d95142386a3efd200cb3dde76/librosa/util/utils.py#L943-L946

in util.localmax exists solely to make edge cases easy to handle in vectorized code.

This is good because the code is concise, readable, and fast. But it’s also bad because it invokes a full O(n) memory copy for what is literally an edge case.

We should conduct a thorough audit of the library for this kind of thing – I don’t think there is very much of it – and replace pads with more careful code that can operate in place if possiible. Odds are good that this will require some numbafication if we have to replace vector ops with loops.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bmcfeecommented, Jul 7, 2022

Adding this to the 0.10 docket - I expect what we’ll end up with is:

  • stft/istft via #1514
  • localmax/localmin via the above

The rest of the identified pad usages seem either low-priority (few code paths touch them) or not worth the added code complexity to optimize.

Local min and max are higher priority because they get used as utility functions, eg within (p)yin and beat tracking. The optimization is easy to do and the payoff is substantial.

1reaction
bmcfeecommented, Jun 3, 2022

After a bit of reflection, I think we should remove this from the 0.9.2 milestone.

Getting STFT and friends #871 covered will pick up the vast majority of performance gains here, and the rest would make the code more complex than I’m really comfortable with. (Though TBH, not very many of these are easy modifications anyway.)

Thinking longer term, I think what would be most helpful here is an abstracted “padded array” class that divides up an ndarray into its padded regions and original region, similar to how a dask array divides up into chunks, where the original region is copy-by-reference. I don’t think this functionality belongs in librosa, but if it made its way into numpy (or a lightweight standalone package that we could depend on), that would be the best option all around IMO.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to automatically reduce or increase content padding ...
You may want to remove the padding/margin for any smaller screen sizes. Try like this: @media (max-width: 978px) { .container { padding:0; ...
Read more >
spacing - How can I reduce padding after figure? - TeX
I recommend using more than just [h] for positioning. See Keeping tables/figures close to where they are mentioned. – Stefan Kottwitz ♢. Jul...
Read more >
Oh Hey, Padding Percentage is Based on the Parent ...
I always thought that percentage padding was based on the element itself. So if an element is 1,000 pixels wide with padding-top: 50%...
Read more >
Responsive Padding, Margin & Gutters With CSS Calc
Make your padding, margin, gutters, and other whitespace elements dynamic so they respond to match the screen size of the current device ...
Read more >
A padding method to reduce edge effects for enhanced ...
Request PDF | A padding method to reduce edge effects for enhanced damage identification using wavelet analysis | Vibration response based ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found