Skip to content

Fix Date.now after 2038 on Windows, current GC memory, and speed up Array<Int>.join (#413, #414, #415) - #440

Merged
dimensionscape merged 4 commits into
mainfrom
fix/date-gcstats-intjoin
Nov 13, 2026
Merged

dimensionscape merged 4 commits into
mainfrom
fix/date-gcstats-intjoin

Conversation

@dimensionscape

Copy link
Copy Markdown
Member

Three runtime fixes for 6.0.0, each with a regression test. They were first written on the cppia-bugs-1106 branch and are picked from there onto current main.

  • Date.now() on Windows passed the seconds since 1970 through a long, which is 32 bits there on x64 too, so after January 2038 it went back to 1902. They stay 64 bits until they become a double. DateNowAfter2038 force-includes a GetSystemTime that reports 2040 into the MSVC build, and checks the real clock elsewhere. Fixes Keep Date.now Unix seconds out of 32-bit long on Windows #413.
  • Gc.memInfo64(Gc.MEM_INFO_CURRENT) counted a block's rows only when the block came from the locked slow path. The usual path, a block taken from the free list without the lock, added nothing until the next collection, so retaining 2 MB of arrays showed about 90 KB more. That path counts the block too, and the count is atomic. Fixes Account for reused small blocks in current GC memory statistics #414.
  • Joining an Array<Int> made a String for each element and then joined those. With a byte-string separator the digits now go straight into one allocation, as String(int) writes them. A UTF-16 separator keeps the general path. Fixes Avoid per-element temporary string allocation in integer-array joins #415.

Measured here (MSVC x64, Haxe 4.3.7, best of 7 rounds of 200 joins of 8,192 integers with ","): 33 to 38 ms on main, 20 ms with this change. IntArrayJoin checks the result against each element's own string for several separators, wide ones included.

DateNowAfter2038 and GcCurrentMemory fail on main and pass with these commits. All three pass here with Haxe 4.3.7.

The Windows path cast the seconds since 1970 to long, which is 32 bits on
Windows, x64 included, so after January 2038 Date.now() went back to 1902
(libhxcpp #413). They stay an __int64 until they become a double.

DateNowAfter2038 force-includes a GetSystemTime that reports 2040 into the
MSVC build; elsewhere it checks the real clock.
GetFreeBlock added a block's free rows to the current rows in use only on
its slow path, under the lock. The usual path, taking a block from the
free list without it, added nothing, so Gc.memInfo64(MEM_INFO_CURRENT)
left out most of what was allocated until the next collection: retaining
2 MB of arrays showed 90 KB more (libhxcpp #414). That path counts the
block too, and the count is atomic, as threads take blocks at once.
Joining a typed array made a String for each element, an allocation for
every value of more than one digit, and then joined those (libhxcpp
the result once and writes them in, as String(int) does. Joining 8,192
integers 200 times takes 41 ms instead of 53 ms, what writing them with
std::to_chars takes.

IntArrayJoin compares the result with the elements' own strings for
several separators, wide ones included, which keep the general path.
@dimensionscape
dimensionscape force-pushed the fix/date-gcstats-intjoin branch from 9431a3e to f101695 Compare November 13, 2026 06:09
# Conflicts:
#	Changes.md
@dimensionscape
dimensionscape merged commit 89a7691 into main Nov 13, 2026
37 checks passed
@dimensionscape
dimensionscape deleted the fix/date-gcstats-intjoin branch November 13, 2026 15:53
@dimensionscape dimensionscape mentioned this pull request Nov 13, 2026
28 of 34 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant