RFR: JDK-8266503: [UL] Make Decorations safely copy-able and reduce their size

Thomas Stuefe stuefe at openjdk.java.net
Thu May 6 11:07:55 UTC 2021


On Wed, 5 May 2021 08:09:35 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> This patch reduces the size of UL `LogDecorations` by about 85% (from 368 -> 56 bytes on Linux x64). This matters in the context of asynchronous logging in UL where we plan to keep a buffer containing log messages, including decorations, for asynchronous printing.
> 
> As a side effect, it makes the LogDecorations object safe to copy with trivial assignment constructors and operators (which it had not been before).
> 
> As another side effect, the 256-char-for-all-decorators limit has been removed with this patch.
> 
> What the patch does:
> 
> In LogDecorations, we resolve the values of the given decorators ("uptime", "tid" etc) and print them in human-readable format. Before this patch, the class LogDecorations stored the printed decorators in an internal (limited, fixed-sized) buffer. This is inefficient since this takes much more memory than storing the binary data before printing them.
> 
> So this patch separates the decorator value resolving from the printing. It stores the resolved values in binary form and only prints them when needed. Since a decorations object is only printed once this is fine. No need to cache the formatted text.
> 
> *Please Note that this patch includes the fix for JDK-8266536: "Provide a variant of os::iso8601_time which works with arbitrary timestamps" which is in a separate PR (https://github.com/openjdk/jdk/pull/3869) - so please ignore all the iso6801 stuff. It also contains a fix for the broken harfbuzz build.*
> 
> Testing:
> - gtests, manually
> - jtreg runtime/logging, manually
> - SAP nightlies ran fine, but since then the tests changed, will run them again tonight

src/hotspot/share/runtime/os.cpp line 102:

> 100:   va_end(args);
> 101:   return result;
> 102: }

Reviewer Note: not part of this patch: see https://github.com/openjdk/jdk/pull/3869

src/hotspot/share/runtime/os.hpp line 224:

> 222:   // It is MT safe, but not async-safe, as reading time zone
> 223:   // information may require a lock on some platforms.
> 224:   static char*      local_time_string(char *buf, size_t buflen);

Reviewer Note: not part of this patch: see #3869

src/java.desktop/share/native/libharfbuzz/hb-ot-shape-complex-use-machine.hh line 375:

> 373: struct machine_index_t :
> 374: hb_iter_with_fallback_t<machine_index_t<Iter>,
> 375: typename Iter::item_t>

Reviewer Note: not part of this patch: This is a compile fix for the broken harfbuzz build, see https://github.com/openjdk/jdk/pull/3873. Will remove this before pushing.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3874


More information about the hotspot-runtime-dev mailing list