Opened 2 years ago

Last modified 2 years ago

#16760 new defect

Event loop stuck on ForkJoinPool

Reported by: stephankn Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: performance Cc: wiktorn


In ticket #16734 the GUI was not responsive for up to 10s.

I reproduced it again and attached a YourKit snapshot here.
Use-Case was a new empty data layer and one imagery layer visible. I am in drawing mode and have a node places. Line follows the cursor. Then zooming the map. GUI freezes für multiple seconds, often shortly unblock to freeze then again.

Monitor usage view of profiler indicates AWT being blocked here for 2657ms, with 1359ms of blocking time on$ForEachTask by
org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer$TileSet.visitTiles(Consumer, Consumer)

and 1104ms of blocking time on monitor called by, boolean, RenderBenchmarkCollector, BBox)

Both seem to be ForkJoinPool instances. I'm not certain whether they are independent or shared. Someone deeper into the internals might want to comment on this one.

Interesting reading on Stack Overflow as others seem to have faces similar issues before:

Attachments (1)

josm-custom-2018-09-20(3).zip (12.5 MB) - added by stephankn 2 years ago.

Change History (3)

Changed 2 years ago by stephankn

comment:1 Changed 2 years ago by Don-vip

Cc: wiktorn added
Keywords: performance added

Maybe related to how we create ForkJoinPool:

     * Returns a {@link ForkJoinPool} with the parallelism given by the preference key.
     * @param pref The preference key to determine parallelism
     * @param nameFormat see {@link #newThreadFactory(String, int)}
     * @param threadPriority see {@link #newThreadFactory(String, int)}
     * @return a {@link ForkJoinPool}
    public static ForkJoinPool newForkJoinPool(String pref, final String nameFormat, final int threadPriority) {
        int noThreads = Config.getPref().getInt(pref, Runtime.getRuntime().availableProcessors());
        return new ForkJoinPool(noThreads, new ForkJoinPool.ForkJoinWorkerThreadFactory() {
            final AtomicLong count = new AtomicLong(0);
            public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
                // Do not use JDK default thread factory !
                // If JOSM is started with Java Web Start, a security manager is installed and the factory
                // creates threads without any permission, forbidding them to load a class instantiating
                // another ForkJoinPool such as MultipolygonBuilder (see bug #15722)
                final ForkJoinWorkerThread thread = new JosmForkJoinWorkerThread(pool);
                thread.setName(String.format(Locale.ENGLISH, nameFormat, count.getAndIncrement()));
                return thread;
        }, null, true);

comment:2 Changed 2 years ago by wiktorn


Use-Case was a new empty data layer and one imagery layer visible.

Can you elaborate what you mean that one layer was visible? Did you have only one layer added, only one marked as visible (eye icon on layer list) or top layer was covering all the layers below? How many imagery layers you had in total?

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain team.
as The resolution will be set.
to The owner will be changed from team to the specified user.
The owner will change to stephankn
as duplicate The resolution will be set to duplicate.The specified ticket will be cross-referenced with this ticket
The owner will be changed from team to anonymous.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.