Bug 273901 - Set of small optimizations
Set of small optimizations
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: libusb (Show other bugs)
7
All All
medium Severity low
: ---
: ---
Assigned To: Jindrich Novy
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-09-01 11:40 EDT by Ulrich Drepper
Modified: 2013-07-02 19:22 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-09-04 07:20:57 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Small set of optimizations (3.06 KB, patch)
2007-09-01 11:40 EDT, Ulrich Drepper
no flags Details | Diff

  None (edit)
Description Ulrich Drepper 2007-09-01 11:40:28 EDT
Description of problem:
Seeing libusb start up is currently painful.  usb_find_devices open all kinds of
files and tries to read from them.  This can never work for directories and
since we know when a directory entry is a directory, why not skip them?

This is what d_type is for.  The patch adds support for it.

The next optimization is to use openat() instead of open() to open files in
directories.  Not only is this more efficient, it also does not impose file name
length limits, and is potentially more secure.  For this to work the autoconf
tests must be extended for openat (and define HAVE_OPENAT) and define
_GNU_SOURCE in CFLAGS.  I didn't attach a patch for that part.

Lastly, while we are at it, I changed a couple of malloc+memset in calloc.  It's
more efficient (sometimes significantly so) and it is more safe because in
future two places don't have to be changed in lockstep.

Version-Release number of selected component (if applicable):
0.1.12-7.fc7

How reproducible:
always


Steps to Reproduce:
1.start any program using usb_find_devices
2.
3.
  
Actual results:
lots of unnecessary opens

Expected results:
skip those directory entries

Additional info:
I'll file the problem also upstream but we should apply these changes even
before upstream uses them.  Let's reduce startup times.
Comment 1 Ulrich Drepper 2007-09-01 11:40:28 EDT
Created attachment 184501 [details]
Small set of optimizations
Comment 2 Jindrich Novy 2007-09-04 07:20:57 EDT
Applied, thanks.

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