Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#18749 closed enhancement (fixed)

Fix issues reported by Heap Hero

Reported by: simon04 Owned by: simon04
Priority: normal Milestone: 20.02
Component: Core Version:
Keywords: memory heap intern heaphero svg svgsalamander Cc:

Description (last modified by simon04)

https://heaphero.io/my-heap-report.jsp?p=YXJjaGl2ZWQvMjAyMC8wMi8yMi8tLWhlYXBkdW1wLTE1ODIzODQ0NjA5NjIuaHByb2YuZ3otMTUtMTYtNy5qc29uLS0=

The heap bump has been obtained from running JOSM r15898 on a fresh profile and loading the attached dataset.

Build-Date:2020-02-22 17:26:08
Revision:15898
Is-Local-Build:true

Identification: JOSM/1.5 (15898 SVN en_GB) Linux Arch Linux
Memory Usage: 829 MB / 3531 MB (658 MB allocated, but free)
Java version: 1.8.0_242-b08, Oracle Corporation, OpenJDK 64-Bit Server VM
Screen: :0.0 3840x2160
Maximum Screen Size: 3840x2160
VM arguments: [-Djosm.home=<josm.pref>/]
Program arguments: [--set=expert=true, --set=iso.dates=true]
Dataset consistency test: No problems found

Attachments (2)

b.osm.bz2 (72.4 KB ) - added by simon04 5 years ago.
18749.patch (9.6 KB ) - added by simon04 5 years ago.

Download all attachments as: .zip

Change History (36)

by simon04, 5 years ago

Attachment: b.osm.bz2 added

comment:1 by Don-vip, 5 years ago

Keywords: svg added

Looks like svgSalamander is responsible for many of the issues.

comment:2 by Don-vip, 5 years ago

What version of Java were you running?

comment:3 by GerdP, 5 years ago

Keywords: svg removed

See kitfox.patch in #17040

comment:4 by GerdP, 5 years ago

Keywords: svg added

comment:5 by GerdP, 5 years ago

in reply to:  5 ; comment:6 by Don-vip, 5 years ago

Replying to GerdP:

The svg issue is still open: https://github.com/blackears/svgSalamander/issues/36

You should open a Pull Request instead.

comment:7 by simon04, 5 years ago

Description: modified (diff)

by simon04, 5 years ago

Attachment: 18749.patch added

comment:8 by simon04, 5 years ago

With attachment:18749.patch​ applied, the "5. Duplicate Strings / Wasted Memory" goes down from 9.7mb to 4.64mb

comment:9 by Don-vip, 5 years ago

Milestone: 20.02

in reply to:  6 comment:10 by GerdP, 5 years ago

Replying to Don-vip:

Replying to GerdP:

The svg issue is still open: https://github.com/blackears/svgSalamander/issues/36

You should open a Pull Request instead.

I still don't know how to open a Pull Requests. I hope I don't have to learn it for JOSM, whenever I tried to work with git I was searching for the right way to undo something in my local directory and ended in messed up code. Getting old...
I think the negative comment regarding String.intern() usage stopped my issue.

in reply to:  9 ; comment:11 by simon04, 5 years ago

Replying to GerdP:

I still don't know how to open a Pull Requests.

You might want to use the GitHub website to make an edit and create a PR: https://help.github.com/en/github/managing-files-in-a-repository/editing-files-in-another-users-repository

How's your svgSalamander workflow? We make modifications to our copy and at the same time try to get the changes upstream via a PR?

in reply to:  11 comment:12 by Don-vip, 5 years ago

Replying to simon04:

We make modifications to our copy and at the same time try to get the changes upstream via a PR?

Yes. It can take many months before svgSalamander PR are merged, so we clearly don't want to wait.

comment:13 by simon04, 5 years ago

In 15901/josm:

see #18749 - Intern strings to reduce memory footprint of svgSalamander

comment:14 by simon04, 5 years ago

In 15902/josm:

see #18749 - Intern strings to reduce memory footprint

comment:15 by simon04, 5 years ago

In 15904/josm:

see #18749 - SVGElement: store String instead of StyleAttribute in map

comment:16 by simon04, 5 years ago

In 15909/josm:

see #18749 - Use efficient/unmodifiable collections

in reply to:  11 comment:17 by GerdP, 5 years ago

Replying to simon04:

Replying to GerdP:

I still don't know how to open a Pull Requests.

You might want to use the GitHub website to make an edit and create a PR: https://help.github.com/en/github/managing-files-in-a-repository/editing-files-in-another-users-repository

Thanks for the link. That looks easy enough for me.

comment:18 by simon04, 5 years ago

I submitted two upstream PR for svgSalamander (extracted from r15901 and r15904, respectively):

comment:19 by simon04, 5 years ago

In 15912/josm:

see #18749 - Use efficient/unmodifiable maps for svgSalamander


Here is a histogram of the sizes of the map fields in SVGElement when running with Java ⩾9:

  count      map in SVGElement   map.size   class used since r15912
  ===================================================================================
   4894      [java] inlineStyles     0000   class java.util.Collections$EmptyMap
   1297      [java] inlineStyles     0001   class java.util.Collections$SingletonMap
   1118      [java] inlineStyles     0002   class java.util.ImmutableCollections$MapN
    537      [java] inlineStyles     0003   class java.util.ImmutableCollections$MapN
    552      [java] inlineStyles     0004   class java.util.ImmutableCollections$MapN
    319      [java] inlineStyles     0005   class java.util.ImmutableCollections$MapN
    443      [java] inlineStyles     0006   class java.util.ImmutableCollections$MapN
    423      [java] inlineStyles     0007   class java.util.ImmutableCollections$MapN
    438      [java] inlineStyles     0008   class java.util.ImmutableCollections$MapN
    513      [java] inlineStyles     0009   class java.util.ImmutableCollections$MapN
    561      [java] inlineStyles     0010   class java.util.ImmutableCollections$MapN
    222      [java] inlineStyles     0011   class java.util.ImmutableCollections$MapN
     31      [java] inlineStyles     0012   class java.util.ImmutableCollections$MapN
      3      [java] inlineStyles     0013   class java.util.ImmutableCollections$MapN
      8      [java] inlineStyles     0014   class java.util.ImmutableCollections$MapN
      6      [java] inlineStyles     0015   class java.util.ImmutableCollections$MapN
     18      [java] inlineStyles     0016   class java.util.ImmutableCollections$MapN
     39      [java] inlineStyles     0017   class java.util.ImmutableCollections$MapN
     24      [java] inlineStyles     0018   class java.util.ImmutableCollections$MapN
     53      [java] inlineStyles     0019   class java.util.ImmutableCollections$MapN
     21      [java] inlineStyles     0020   class java.util.ImmutableCollections$MapN
     40      [java] inlineStyles     0021   class java.util.ImmutableCollections$MapN
      4      [java] inlineStyles     0022   class java.util.ImmutableCollections$MapN
      1      [java] inlineStyles     0027   class java.util.ImmutableCollections$MapN
    395      [java] inlineStyles     0028   class java.util.ImmutableCollections$MapN
     39      [java] inlineStyles     0029   class java.util.ImmutableCollections$MapN
      2      [java] inlineStyles     0031   class java.util.ImmutableCollections$MapN
      1      [java] inlineStyles     0032   class java.util.ImmutableCollections$MapN
      1      [java] inlineStyles     0033   class java.util.ImmutableCollections$MapN
      4      [java] inlineStyles     0036   class java.util.ImmutableCollections$MapN
      1      [java] inlineStyles     0049   class java.util.ImmutableCollections$MapN
     28      [java] inlineStyles     0050   class java.util.ImmutableCollections$MapN
     24      [java] presAttributes   0000   class java.util.Collections$EmptyMap
   1730      [java] presAttributes   0001   class java.util.Collections$SingletonMap
    596      [java] presAttributes   0002   class java.util.ImmutableCollections$MapN
   1568      [java] presAttributes   0003   class java.util.ImmutableCollections$MapN
   2161      [java] presAttributes   0004   class java.util.ImmutableCollections$MapN
   1624      [java] presAttributes   0005   class java.util.ImmutableCollections$MapN
   1516      [java] presAttributes   0006   class java.util.ImmutableCollections$MapN
   1428      [java] presAttributes   0007   class java.util.ImmutableCollections$MapN
    489      [java] presAttributes   0008   class java.util.ImmutableCollections$MapN
    537      [java] presAttributes   0009   class java.util.ImmutableCollections$MapN
    160      [java] presAttributes   0010   class java.util.ImmutableCollections$MapN
    134      [java] presAttributes   0011   class java.util.ImmutableCollections$MapN
     50      [java] presAttributes   0012   class java.util.ImmutableCollections$MapN
      4      [java] presAttributes   0013   class java.util.ImmutableCollections$MapN
      5      [java] presAttributes   0014   class java.util.ImmutableCollections$MapN
      9      [java] presAttributes   0015   class java.util.ImmutableCollections$MapN
      1      [java] presAttributes   0016   class java.util.ImmutableCollections$MapN
Last edited 5 years ago by simon04 (previous) (diff)

comment:20 by Don-vip, 5 years ago

Nice! Are there still issues to fix?

comment:21 by simon04, 5 years ago

There are, for sure ;). But it shouldn't hinder us from releasing a new tested. I can always open a follow-up ticket for the next milestone.

comment:22 by simon04, 5 years ago

Resolution: fixed
Status: assignedclosed

comment:23 by tuxayo, 5 years ago

Which kinds of memory savings have been seen during the testing of this patch? (just for the record)

comment:24 by simon04, 5 years ago

The reports:

The numbers:

  • Object Headers 19.92 → 18.19mb
  • Duplicate Strings 9.7 → 4.5mb
  • Inefficient collections 6.4 → 5.4mb
  • Duplicate Objects 2.3 → 1.2mb

comment:25 by GerdP, 5 years ago

Last time that I looked at this I wondered why we keep both the parsed svg data and the rendered image in the heap, possibly also the svg source files in a cache.

comment:26 by simon04, 5 years ago

In 15934/josm:

see #18749 - Intern strings to reduce memory footprint

comment:27 by simon04, 5 years ago

In 15935/josm:

see #18749, see #16183 - Add non-regression test

comment:28 by simon04, 5 years ago

In 15949/josm:

see #18749, see #16183 - removeAreaStylePseudoClass not for validator MapCSS files

comment:29 by GerdP, 5 years ago

In 16031/josm:

see #18749: reduce memory footprint
errors array was allocated with 30 elements for each MapCSSTagCheckerAndRule instance

comment:30 by simon04, 5 years ago

Keywords: svgsalamander added

comment:31 by GerdP, 5 years ago

FYI: I've noticed that the *.svg file in the svn repo are much larger than the ones included in the jar files produced by Jenkins. Seems that there is a compressor which removes lots of strings. No idea if that has an influence on the memory footprint?

in reply to:  31 comment:32 by Klumbumbus, 5 years ago

Replying to GerdP:

Seems that there is a compressor which removes lots of strings.

Yes we use https://github.com/RazrFalcon/svgcleaner but a patched version iirc.

comment:33 by GerdP, 5 years ago

I think r15909 introduced a performance regresssion. Field conds used to be null for empty collections, now it is never null. In Selector.MatchingReferrerFinder.doVisit() this means that a costly sequential search is performed much more often.
This "kills" JOSM when ways with many nodes are processed.

comment:34 by GerdP, 5 years ago

In 16191/josm:

see #18749: fix performance regression introduced with r15909

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain simon04.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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