Closed
Bug 1479484
Opened 6 years ago
Closed 6 years ago
Provide perfecthash.py as general usable module and add codegen
Categories
(Core :: XPCOM, enhancement)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla63
Tracking | Status | |
---|---|---|
firefox63 | --- | fixed |
People
(Reporter: janerik, Assigned: nika)
References
Details
Attachments
(5 files)
46 bytes,
text/x-phabricator-request
|
froydnj
:
review+
|
Details | Review |
46 bytes,
text/x-phabricator-request
|
froydnj
:
review+
|
Details | Review |
46 bytes,
text/x-phabricator-request
|
froydnj
:
review+
|
Details | Review |
46 bytes,
text/x-phabricator-request
|
froydnj
:
review+
|
Details | Review |
46 bytes,
text/x-phabricator-request
|
froydnj
:
review+
|
Details | Review |
perfecthash.py[1] is a nice small implementation of a perfect hash function, useful for mapping elements to integers. Its C++ part is just 2 functions[2]. This module should be extracted into a common place in order to reuse it in other modules. Additionally, it should bring functionality for the code generation as well. The Telemetry module would adopt it to provide a String->Integer map for its internal use. [1]: https://searchfox.org/mozilla-central/source/xpcom/reflect/xptinfo/perfecthash.py [2]: https://searchfox.org/mozilla-central/source/xpcom/reflect/xptinfo/xptinfo.cpp#16-44
Reporter | ||
Updated•6 years ago
|
Flags: needinfo?(nika)
Assignee | ||
Comment 1•6 years ago
|
||
The plan is to also expose perfecthash.py from this module on the python path. This also allows us to stop using explicit module loading to load make_dafsa.py. make_dafsa.py was moved into tools/ to avoid any extra python files from accidentally ending up on the python path.
Assignee | ||
Comment 2•6 years ago
|
||
This information is already being detected, and it will allow us to avoid byteorder swaps in XPT on big-endian systems. This patch allows buildconfig to detect endianness. It may make sense in the future to also expose this endianness as a define, so we can avoid custom detection such as in /mfbt/EndianUtils.h: https://searchfox.org/mozilla-central/rev/196560b95f191b48ff7cba7c2ba9237bba6b5b6a/mfbt/EndianUtils.h#85-148 Depends On D2614
Assignee | ||
Comment 3•6 years ago
|
||
This is a streamlined version of perfecthash.py from xpcom/reflect/xptinfo. There are a few major changes here: Instead of providing '(key, value)' pairs to the constructor, callers provide a list of 'entries'. An optional 'key' parameter allows overriding the function used to get an entry's key. The default behaviour is as before, destructuring a (key, value) tuple. Keys can now be anything which supports the 'memoryview' protocol with 1-byte elements, rather than being forced to be a 'bytearray'. This allows passing in types such as bytestrings. A new 'cxx_codegen' method is now exposed which generates a series of fully-contained C++ declarations to perform entry lookups. It is possible to override many parts of this codegen to make it the best fit for your component. PerfectHash remembers the 'key' function, meaning lookup methods automatically verify a valid key was passed in, and return 'None' otherwise. Depends On D2615
Assignee | ||
Comment 4•6 years ago
|
||
This patch ports xptcodegen.py over to the new perfecthash.py system, removing some special-case code generators, and taking advantage of the easier-to-use interface. In addition, the code was changed to take advantage of the endianness information from Part 2, allowing us to avoid having to perform endianness swaps at runtime when hashing nsIDs. Depends On D2616
Assignee | ||
Comment 5•6 years ago
|
||
Depends On D2618
Assignee | ||
Updated•6 years ago
|
Assignee: nobody → nika
Flags: needinfo?(nika)
Comment 6•6 years ago
|
||
Comment on attachment 8996791 [details] Bug 1479484 - Part 1: Add make_dafsa.py to the virtualenv's python path, r=froydnj Nathan Froyd [:froydnj] has approved the revision. https://phabricator.services.mozilla.com/D2614
Attachment #8996791 -
Flags: review+
Comment 7•6 years ago
|
||
Comment on attachment 8996792 [details] Bug 1479484 - Part 2: Expose endianness from buildconfig, r=gps Nathan Froyd [:froydnj] has approved the revision. https://phabricator.services.mozilla.com/D2615
Attachment #8996792 -
Flags: review+
Comment 8•6 years ago
|
||
Comment on attachment 8996793 [details] Bug 1479484 - Part 3: Add perfecthash.py with codegen to xpcom/ds/tools, r=froydnj Nathan Froyd [:froydnj] has approved the revision. https://phabricator.services.mozilla.com/D2616
Attachment #8996793 -
Flags: review+
Comment 9•6 years ago
|
||
Comment on attachment 8996795 [details] Bug 1479484 - Part 4: Move xptcodegen over to new perfecthash.py, r=froydnj Nathan Froyd [:froydnj] has approved the revision. https://phabricator.services.mozilla.com/D2618
Attachment #8996795 -
Flags: review+
Comment 10•6 years ago
|
||
Comment on attachment 8996796 [details] Bug 1479484 - Part 5: Remove old perfecthash.py, r=froydnj Nathan Froyd [:froydnj] has approved the revision. https://phabricator.services.mozilla.com/D2619
Attachment #8996796 -
Flags: review+
Comment 11•6 years ago
|
||
Pushed by nika@thelayzells.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/20668aaf20eb Part 1: Add make_dafsa.py to the virtualenv's python path, r=froydnj https://hg.mozilla.org/integration/mozilla-inbound/rev/a509c3520b77 Part 2: Expose endianness from buildconfig, r=froydnj https://hg.mozilla.org/integration/mozilla-inbound/rev/fc662efea520 Part 3: Add perfecthash.py with codegen to xpcom/ds/tools, r=froydnj https://hg.mozilla.org/integration/mozilla-inbound/rev/9863b56882dc Part 4: Move xptcodegen over to new perfecthash.py, r=froydnj https://hg.mozilla.org/integration/mozilla-inbound/rev/6175bdb411f5 Part 5: Remove old perfecthash.py, r=froydnj
Comment 12•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/20668aaf20eb https://hg.mozilla.org/mozilla-central/rev/a509c3520b77 https://hg.mozilla.org/mozilla-central/rev/fc662efea520 https://hg.mozilla.org/mozilla-central/rev/9863b56882dc https://hg.mozilla.org/mozilla-central/rev/6175bdb411f5
Status: NEW → RESOLVED
Closed: 6 years ago
status-firefox63:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in
before you can comment on or make changes to this bug.
Description
•