This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 117279 - CND's common MIMEResolver architecture causes duplicated recognition
Summary: CND's common MIMEResolver architecture causes duplicated recognition
Status: CLOSED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Vladimir Voskresensky
URL:
Keywords: PERFORMANCE
Depends on:
Blocks: 114195
  Show dependency tree
 
Reported: 2007-10-01 11:02 UTC by Petr Nejedly
Modified: 2007-11-02 15:17 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Nejedly 2007-10-01 11:02:40 UTC
When a file is about to be recognized, it is passed through (among others) onm.cnd.loaders.MIMEResolver, which in turn
drags it through att of the CND's DataLoaders. Once this is done and the mime type is recognized (e.g. text/x-java), the
file goes through all the registered data loaders (also all of the CND's) and the same kind of recognition is performed
on it once more.
If you have MIMEResolver safely resolved, you'd better bind your DataLoaders _only_ to the mime type, not the extensions
again.
Comment 1 Petr Nejedly 2007-10-01 11:07:36 UTC
Moreover, both CND's MIME resolvers should better be ordered near the end of the MIMEResolvers folder as they are both
sniffing resolvers, opening each file they encounter.
There would better be only few files left for them, majority recognized first by cheaper resolvers.
This part of the issue is SIMPLEFIX and reduces the impact significantly.
Comment 2 Petr Nejedly 2007-10-02 12:02:36 UTC
The second part of the issue is actually P2, as it consumes (together with issue 117426) 25% of the folder recognition time.
As it is simplefix anyway, please consider fixing this ASAP.
Comment 3 Vladimir Voskresensky 2007-10-02 17:33:09 UTC
our MIMEResolver is registered in layer.xml Services/Hidden (old approach)
As I see in org.openide.filesystems.MIMESupport
the order of resolvers is:
- META-INF/services registered (2 resolvers without #position attributes)
- layer.xml Services/Hidden registered (1 cnd resolver)
- a lot of other Services/MIMEResolver registered

how can we put our resolver at the end?
Thanks,
Vladimir.
Comment 4 Petr Nejedly 2007-10-02 18:05:10 UTC
Using either relative ordering as with any layer-registered entity, or numerical positions, but I'm not sure what will
happen if no other resolver uses numeric order.
CCing Jesse (numeric order question - We need to move these resolvers as close to the end as possible. There are no
collision and the resolvers are very expensive).

At least try to order them "after" the Java mime resolver ;-)
Comment 5 Jesse Glick 2007-10-02 19:11:12 UTC
If any files (or subfolders) in a folder use numerical positions, they all need to, and they all need distinct positions
- with the special exception that there can be multiple files all using 0 (zero), among whom the order is arbitrary.
Comment 6 Vladimir Voskresensky 2007-10-02 21:23:31 UTC
as I pointed:
the ordered list is constructor from 3 different registration places and ordering become:
- META-INF/services registered (2 resolvers without #position attributes)
- layer.xml Services/Hidden registered (1 cnd resolver)
- a lot of other Services/MIMEResolver registered

if you want cnd resolver to be the last, please change impl and put Services/Hidden registeration at the end of list
Comment 7 Petr Nejedly 2007-10-02 22:06:06 UTC
Ouch!
In fact, the places are only 2, meta-inf lookup and services lookup.
The fact that the resolvers are registered in more services lookup folders just make it more complicated.
There are two CND's MIMEResolvers, though, one coded (which is in Services/Hidden) and one declarative (in
Services/MIMEResolvers).
I'm more concerned about the declarative one, according to my profiler logs, and the declarative one is easy to move.
Comment 8 Jesse Glick 2007-10-02 22:24:01 UTC
Please move the resolver out of Services/Hidden into MIMEResolver; S/Hidden is deprecated (it has been years since there
was any reason for it to exist). In fact all locations inside Services/ work equally well, but it is nicer to keep
related services together in their own folders - e.g. so that we can decide to order services on a folder-by-folder basis.
Comment 9 Vladimir Voskresensky 2007-10-04 14:25:27 UTC
fixing:
- simplified cnd's data loaders
- split declarative resolvers by the kinds: extension based, attribute based, hex-based
- moved cnd's resolvers at the end of resolvers list

#position attribute is not supported in Services/MIMEResolvers folders =>
I prepend expensive resolvers with z* prefix to be ordered by name to the end of list.

Please, verify the current impact of cnd.
Thanks,

cvs log:
Checking in resources/mime-resolver-ext-based.xml;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/resources/mime-resolver-ext-based.xml,v  <-- 
mime-resolver-ext-based.xml
initial revision: 1.1
done
Removing resources/mime-resolver.xml;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/resources/mime-resolver.xml,v  <--  mime-resolver.xml
new revision: delete; previous revision: 1.7
done
RCS file: /shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/resources/mime-resolver-attr-based.xml,v
done
Checking in resources/mime-resolver-attr-based.xml;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/resources/mime-resolver-attr-based.xml,v  <-- 
mime-resolver-attr-based.xml
initial revision: 1.1
done
RCS file: /shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/resources/mime-resolver-hex-based.xml,v
done
Checking in resources/mime-resolver-hex-based.xml;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/resources/mime-resolver-hex-based.xml,v  <-- 
mime-resolver-hex-based.xml
initial revision: 1.1
done
Checking in resources/mf-layer.xml;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/resources/mf-layer.xml,v  <--  mf-layer.xml
new revision: 1.25; previous revision: 1.24
done
Checking in loaders/ExeLoader.java;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/loaders/ExeLoader.java,v  <--  ExeLoader.java
new revision: 1.8; previous revision: 1.7
done
Checking in loaders/ShellDataLoader.java;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/loaders/ShellDataLoader.java,v  <--  ShellDataLoader.java
new revision: 1.11; previous revision: 1.10
done
Removing loaders/MIMEResolver.java;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/loaders/MIMEResolver.java,v  <--  MIMEResolver.java
new revision: delete; previous revision: 1.5
done
RCS file: /shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/loaders/CndMIMEResolver.java,v
done
Checking in loaders/CndMIMEResolver.java;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/loaders/CndMIMEResolver.java,v  <--  CndMIMEResolver.java
initial revision: 1.1
done
Checking in loaders/HDataLoader.java;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/loaders/HDataLoader.java,v  <--  HDataLoader.java
new revision: 1.14; previous revision: 1.13
done
Checking in loaders/CndAbstractDataLoader.java;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/loaders/CndAbstractDataLoader.java,v  <-- 
CndAbstractDataLoader.java
new revision: 1.8; previous revision: 1.7
done
Checking in loaders/MakefileDataLoader.java;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/loaders/MakefileDataLoader.java,v  <-- 
MakefileDataLoader.java
new revision: 1.10; previous revision: 1.9
done
Checking in MIMENames.java;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/MIMENames.java,v  <--  MIMENames.java
new revision: 1.6; previous revision: 1.5
done
Comment 10 Petr Nejedly 2007-10-04 15:09:06 UTC
Thanks, I'll check it later today.
I'm also preparing global reorder of MIME resolvers (see issue 117781), so I'll order them according to their impact.
Comment 11 Jesse Glick 2007-10-04 15:33:29 UTC
"#position attribute is not supported in Services/MIMEResolvers folders" - it is supported. Again, you may set the
position attribute on files in a folder, so long as you set it on all files in that folder.
Comment 12 Vladimir Voskresensky 2007-10-04 15:43:40 UTC
next speed up:
- removed using get/setAttribute from ExeLoader
- added some more extensions to declarative resolver and removed from ExeLoader

cvs log:
Checking in resources/mf-layer.xml;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/resources/mf-layer.xml,v  <--  mf-layer.xml
new revision: 1.26; previous revision: 1.25
done
Checking in resources/mime-resolver-ext-based.xml;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/resources/mime-resolver-ext-based.xml,v  <-- 
mime-resolver-ext-based.xml
new revision: 1.2; previous revision: 1.1
done
Checking in loaders/ExeLoader.java;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/loaders/ExeLoader.java,v  <--  ExeLoader.java
new revision: 1.9; previous revision: 1.8
done
Comment 13 Vladimir Voskresensky 2007-10-04 15:59:39 UTC
to Jesse:
yes, sure, this is the topic of http://www.netbeans.org/issues/show_bug.cgi?id=117781
Comment 14 Vladimir Voskresensky 2007-10-04 17:21:46 UTC
last step:
- split extension based resolver from sniffing resolver and put sniffing at the end

cvs log
Checking in resources/mf-layer.xml;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/resources/mf-layer.xml,v  <--  mf-layer.xml
new revision: 1.29; previous revision: 1.28
done
RCS file: /shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/loaders/CndSniffyMIMEResolver.java,v
done
Checking in loaders/CndSniffyMIMEResolver.java;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/loaders/CndSniffyMIMEResolver.java,v  <-- 
CndSniffyMIMEResolver.java
initial revision: 1.1
done
Checking in loaders/CndMIMEResolver.java;
/shared/data/ccvs/repository/cnd/core/src/org/netbeans/modules/cnd/loaders/CndMIMEResolver.java,v  <--  CndMIMEResolver.java
new revision: 1.2; previous revision: 1.1
done