Ignore:
Timestamp:
2022-06-08T17:48:47+02:00 (3 years ago)
Author:
taylor.smock
Message:

Fix #22032: Various memory enhancements for MVT tiles

There is about a 88% decrease in memory allocations due to MVT tiles.

The majority of changes came from the following:

  1. Avoiding ArrayList#grow calls by using a ByteArrayOutputStream that gets passed around
  2. Caching nodes to avoid QuadBuckets#search calls

This additionally fixes a bug where VectorRelation#setMembers does not
work properly and adds a putAll method in Tagged (there is a default
method).

Location:
trunk/test/unit/org/openstreetmap/josm/data/protobuf
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/protobuf/ProtobufRecordTest.java

    r17862 r18473  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    6 
     6import java.io.ByteArrayOutputStream;
    77import java.io.IOException;
    88
     
    1616    void testFixed32() throws IOException {
    1717        ProtobufParser parser = new ProtobufParser(ProtobufTest.toByteArray(new int[] {0x0d, 0x00, 0x00, 0x80, 0x3f}));
    18         ProtobufRecord thirtyTwoBit = new ProtobufRecord(parser);
     18        ProtobufRecord thirtyTwoBit = new ProtobufRecord(new ByteArrayOutputStream(), parser);
    1919        assertEquals(WireType.THIRTY_TWO_BIT, thirtyTwoBit.getType());
    2020        assertEquals(1f, thirtyTwoBit.asFloat());
     
    2424    void testUnknown() throws IOException {
    2525        ProtobufParser parser = new ProtobufParser(ProtobufTest.toByteArray(new int[] {0x0f, 0x00, 0x00, 0x80, 0x3f}));
    26         ProtobufRecord unknown = new ProtobufRecord(parser);
     26        ProtobufRecord unknown = new ProtobufRecord(new ByteArrayOutputStream(), parser);
    2727        assertEquals(WireType.UNKNOWN, unknown.getType());
    2828        assertEquals(0, unknown.getBytes().length);
  • trunk/test/unit/org/openstreetmap/josm/data/protobuf/ProtobufTest.java

    r18037 r18473  
    88import java.awt.geom.Ellipse2D;
    99import java.io.ByteArrayInputStream;
     10import java.io.ByteArrayOutputStream;
    1011import java.io.File;
    1112import java.io.IOException;
     
    172173    void testSimpleMessage() throws IOException {
    173174        ProtobufParser parser = new ProtobufParser(new byte[] {(byte) 0x08, (byte) 0x96, (byte) 0x01});
    174         ProtobufRecord record = new ProtobufRecord(parser);
     175        ProtobufRecord record = new ProtobufRecord(new ByteArrayOutputStream(), parser);
    175176        assertEquals(WireType.VARINT, record.getType());
    176177        assertEquals(150, record.asUnsignedVarInt().intValue());
Note: See TracChangeset for help on using the changeset viewer.