Open Bug 1188411 Opened 6 years ago Updated 10 months ago

[Meta] Find and remove unused preferences

Categories

(Core :: General, task)

39 Branch
task
Not set
normal

Tracking

()

People

(Reporter: BenWa, Unassigned, Mentored)

References

(Depends on 2 open bugs)

Details

(Keywords: good-first-bug, meta)

Attachments

(3 files)

We have a several preferences (about:config) that have been removed but are still around. I don't have any idea how many preferences are unused but it comes up from time to time.

A good first bug/mentored bug for someone good with scripting-foo would be to:
- Build a list of preference that occur in our preference files like all.js, b2g.js, firefox.js, mullet.js, etc...
- Find which of these preferences only appear in preference files.
- File follow-up bugs (either per preference or per pref component group) saying which preference is unused.
- (Optional) Post patch in these follow-up bugs (or let others do them).

Ideally we can have a reusable script to make this easier in the future.
Hi Benoit,

I want to work on this bug. Could you explain me a lit bit detailed what needs to be done in those steps:

> - Build a list of preference that occur in our preference files like all.js, b2g.js, firefox.js, mullet.js, etc...
> - Find which of these preferences only appear in preference files.

Thank you a lot
Flags: needinfo?(bgirard)
Attached file preference file list
Here's a command you can run to get a list of preference files:
find . -name "*.js" | xargs grep -l ^pref\(.*\) 2> /dev/null | sort | uniq

Here's the result of the command against my checkout.

We want to find preference names that only occur in these files in the tree and no where else (non preference js files, c++ code, or any other file). These should be unused preferences.
Flags: needinfo?(bgirard)
Sorry, I forgot this issue due I was not assigned, so didn't appear in my dashboard.

Could I attach here an script to find those preferences and after I got it complete with your feedback, start creating the follow-ups bugs?

Thanks
Flags: needinfo?(bgirard)
Yes that would be great. By posting the script we can re-run it from time to time.

Note that I'm not absolutely sure that we have unused preferences but I'd say it's fairly likely that we do.
Flags: needinfo?(bgirard) → needinfo?(gioyik)
Assignee: nobody → gioyik
Flags: needinfo?(gioyik)
Thanks for the fast answer. Early tomorrow I will attach it. :)
Hello,

We are three students and we would like to work on this bug.
Is this still up ?
Attached file find_unused_prefs.py
I tried to find a solution to this bug, but it seems very hard (if not impossible).

I wrote a script, which is attached, and it finds 1166 prefs! When I investigate it more deeply, I found that I can't find out if a preference is used by simply searching its string. As an example, nsHttpHandler defined the preferences in Macros:

https://dxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/nsHttpHandler.cpp#277

And there's a lot of other usages like this.

What do you think Benoit? If you have any ideas, I will be happy to try it out.
Flags: needinfo?(bgirard)
Attached file Sorted result
Flags: needinfo?(bgirard)
Yes I think you're right. However when you sort the results I think a lot of these preferences have a common prefix we could maybe just had to an ignore list in the script for now.

For instance the vast majority have the prefix:
font.name.*

Already a few preference stick out such as 'gfx.prefer-mesa-llvmpipe' which is now a dead preference. Once we start going through it I don't think it will take too much time.
I took the bug. I will look through it to see what can I done.
Assignee: gioyik → aidin
Assignee: aidin → nobody
As well as removing unused prefs, we can also convert some prefs to code constants. Bug 1414150 did this for a few prefs.
Depends on: 90440
Type: defect → task
Keywords: good-first-bug
Whiteboard: good first bug
You need to log in before you can comment on or make changes to this bug.