After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 635371 - Reduce overhead of native module support
Reduce overhead of native module support
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2010-11-20 19:01 UTC by Owen Taylor
Modified: 2010-12-10 16:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Don't repeatedly try to load built-in modules (1.52 KB, patch)
2010-11-20 19:01 UTC, Owen Taylor
committed Details | Review
Check for a builtin module before beginning to load it (6.52 KB, patch)
2010-11-20 19:01 UTC, Owen Taylor
reviewed Details | Review

Description Owen Taylor 2010-11-20 19:01:16 UTC
When tracing through the importer code to debug a different problem, I found
that for every module import, we would for every element of the search path,
create a module object, store a pointer to it in the parent module, try to
load the module as a built-in module, fail, remove the pointer in the parent
module, and continue.

These two patches try to improve the situation.
Comment 1 Owen Taylor 2010-11-20 19:01:18 UTC
Created attachment 174924 [details] [review]
Don't repeatedly try to load built-in modules

There's no point in trying to load a built-in module once per every
item in the search path; once is sufficient.
Comment 2 Owen Taylor 2010-11-20 19:01:21 UTC
Created attachment 174925 [details] [review]
Check for a builtin module before beginning to load it

When used to check for builtin modules, import_native_file() would create a
module object, set properties on it, store it in the native class, fail
to load a builtin module of that name, and then back everything out.
Add a pre-check to avoid this. (It means that we do extract the module ID
twice when we actually load a built-in module, but built-in modules will
a small fraction of modules.)
Comment 3 Colin Walters 2010-12-05 19:32:56 UTC
Review of attachment 174924 [details] [review]:

Looks good!
Comment 4 Colin Walters 2010-12-05 19:46:39 UTC
Review of attachment 174925 [details] [review]:

::: gjs/native.c
@@ +98,3 @@
+    if (gjs_object_get_property(context, module_obj, "__moduleName__", tmp) &&
+        JSVAL_IS_STRING(*tmp))
+        return gjs_string_get_ascii(*tmp);

This malloc()s now, you'll need to change the signature to char * and adjust callers.
Comment 5 Colin Walters 2010-12-10 16:12:58 UTC
Attachment 174924 [details] pushed as b92ba1b - Don't repeatedly try to load built-in modules