Modify

Opened 6 years ago

Last modified 6 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

Description

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
java.util.stream.ForEackOps$ForEachTask by
org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer$TileSet.visitTiles(Consumer, Consumer) AbstractTileSourceLayer.java:1297

and 1104ms of blocking time on monitor
org.openstreetmap.josm.data.osm.visitor.paint.ComputeStyleListWorker called by
org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer.paintWithLock(OsmData, boolean, RenderBenchmarkCollector, BBox) StyledMapRenderer.java:1645

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:
https://stackoverflow.com/questions/21163108/custom-thread-pool-in-java-8-parallel-stream/

Attachments (1)

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

Change History (3)

by stephankn, 6 years ago

comment:1 by Don-vip, 6 years ago

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);
            @Override
            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()));
                thread.setPriority(threadPriority);
                return thread;
            }
        }, null, true);
    }

comment:2 by wiktorn, 6 years ago

@stephankn:

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
Action
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to stephankn.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.