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 236094 - Improve performance of FileObjectFactory
Summary: Improve performance of FileObjectFactory
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 7.4
Hardware: PC Solaris
: P3 normal (vote)
Assignee: Jaroslav Havlin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-18 07:22 UTC by Alexander Simon
Modified: 2013-11-21 14:11 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
proposed patch (1.74 KB, patch)
2013-09-18 07:24 UTC, Alexander Simon
Details | Diff
Patch - Split lock on read/write lock (8.34 KB, patch)
2013-09-18 15:11 UTC, Jaroslav Havlin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Simon 2013-09-18 07:22:09 UTC
Profiling snapshots show that method:
FileObjectFactory.getCachedOnly(File, boolean)
is a top hot spot (CND project, initial indexing/parsing of LLVM 3.3).
Please:
- reduce critical section by moving calculation of id out of synchronized block.
- remove double synchronization of allIBaseFileObjects (remove Collections.synchronizedMap())
This two improvements reduce method wall time 41 -> 26 seconds (by YourKit profiler).
Comment 1 Alexander Simon 2013-09-18 07:24:37 UTC
Created attachment 140198 [details]
proposed patch
Comment 2 Alexander Simon 2013-09-18 07:39:03 UTC
Also profiling snapshots show that allIBaseFileObjects is a top critical monitor.
To resolve this bottleneck consider:
- split lock on read/write lock.
- split monolithic map on slices (see example in org.netbeans.modules.cnd.repository.disk.MemoryCache).
Comment 3 Jaroslav Havlin 2013-09-18 13:47:04 UTC
> This two improvements reduce method wall time 41 -> 26 seconds
Thank you very much for the patch.
Applied as http://hg.netbeans.org/core-main/rev/5c4d5bd4b630.

> [...] allIBaseFileObjects is a top critical monitor.
> To resolve this bottleneck consider:
> - split lock on read/write lock.
I would prefer this solution.
> - split monolithic map on slices (see example in [...] MemoryCache).
Comment 4 Jaroslav Havlin 2013-09-18 15:11:35 UTC
Created attachment 140218 [details]
Patch - Split lock on read/write lock

Prepared patch that uses a ReadWrite lock instead of synchronization
on allIBaseFileObjects object.

Can you please check it?
It would be great if you also could measure it to see how the performance
was affected.
Thanks.
Comment 5 Alexander Simon 2013-09-18 18:36:45 UTC
(In reply to Jaroslav Havlin from comment #4)
> Can you please check it?
> It would be great if you also could measure it to see how the performance
> was affected.
> Thanks.
Ok, I'll check.
Comment 6 Alexander Simon 2013-09-20 13:59:29 UTC
(In reply to Alexander Simon from comment #5)
> (In reply to Jaroslav Havlin from comment #4)
> > Can you please check it?
> > It would be great if you also could measure it to see how the performance
> > was affected.
> > Thanks.
> Ok, I'll check.
By YourKit profiler wall time of FileObjectFactory.getCachedOnly(File, boolean) is 3 seconds with patch.
Comment 7 Jaroslav Havlin 2013-09-20 14:35:25 UTC
(In reply to Alexander Simon from comment #6)
> By YourKit profiler wall time of FileObjectFactory.getCachedOnly(File,
> boolean) is 3 seconds with patch.
Thank you very much.
I've applied the patch: http://hg.netbeans.org/core-main/rev/8cfd3c4c0fed
Comment 8 Vladimir Voskresensky 2013-09-20 20:36:07 UTC
we need this for studio
Comment 9 Jaroslav Havlin 2013-09-23 14:58:51 UTC
The change caused bug 236264.

Method FileObjectFactory.collectForRefresh needs to get parents of FileObjects
sometimes. If the parent has been garbage-collected during invocation of the
method, a new object needs to be created for the parent, and thus write-lock
needs to be acquired inside read-lock (which leads to a deadlock).

Fixed in http://hg.netbeans.org/core-main/rev/61037d5ae9d7.
Comment 10 Quality Engineering 2013-09-24 01:40:17 UTC
Integrated into 'main-silver', will be available in build *201309240002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/61037d5ae9d7
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #236094: Fix deadlock in FileObjectFactory - write-lock requested while a read-lock is held
Comment 11 Jaroslav Havlin 2013-11-13 08:44:05 UTC
(In reply to Vladimir Voskresensky from comment #8)
> we need this for studio
Vladimir, Alexander, can you please verify the fix, to ensure
it can be included in 74patch1? Thank you.
Comment 12 Alexander Simon 2013-11-13 12:54:37 UTC
(In reply to Jaroslav Havlin from comment #11)
> (In reply to Vladimir Voskresensky from comment #8)
> > we need this for studio
> Vladimir, Alexander, can you please verify the fix, to ensure
> it can be included in 74patch1? Thank you.
Ok, I'll verify.
Comment 13 Alexander Simon 2013-11-13 13:23:01 UTC
Now the profiler shows 5 sec in FileObjectFactory.getCachedOnly(File, boolean)
Comment 14 Jaroslav Havlin 2013-11-13 14:56:41 UTC
Thank you for verifying.

Integrated into release74 branch:
http://hg.netbeans.org/releases/rev/dacf17bb1399 (graft - patch)
http://hg.netbeans.org/releases/rev/99a7f3f43b8a (graft - read/write lock)
http://hg.netbeans.org/releases/rev/f061a7ebf9a2 (graft - fixed deadlock)
http://hg.netbeans.org/releases/rev/880d5d21a994 (specification version)
Comment 15 Quality Engineering 2013-11-14 14:30:36 UTC
Integrated into 'releases/release74', will be available in build *201311141216* or newer. Wait for official and publicly available build.

Changeset: http://hg.netbeans.org/releases/rev/dacf17bb1399
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #236094: Improve performance of FileObjectFactory

Patch by  Alexander Simon.
Comment 16 Tomas Danek 2013-11-21 14:11:01 UTC
masterfs module got updated, functionality verification would be appriciated by CND team.