Skip to content

improve precision of @env.now() on native backend#3405

Merged
bobzhang merged 1 commit intomainfrom
Guest0x0/fix-native-now-precision
Apr 2, 2026
Merged

improve precision of @env.now() on native backend#3405
bobzhang merged 1 commit intomainfrom
Guest0x0/fix-native-now-precision

Conversation

@Guest0x0
Copy link
Copy Markdown
Contributor

@Guest0x0 Guest0x0 commented Apr 1, 2026

The API @env.now() should return the duration of time since the Unix epoch in milliseconds. However, previously its implementation on native backend only has second precision. With moonbitlang/moonbit-native-runtime@eac2ffc, the latest MoonBit native runtime now provides an API for getting millisecond precision time. This PR utilizes the new runtime API to fix the precision of @env.now().


Open with Devin

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Apr 1, 2026

Pull Request Test Coverage Report for Build 3717

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.006%

Totals Coverage Status
Change from base Build 3714: 0.0%
Covered Lines: 14610
Relevant Lines: 15378

💛 - Coveralls

@Guest0x0 Guest0x0 requested a review from bobzhang April 1, 2026 07:52
Copy link
Copy Markdown
Contributor

@bobzhang bobzhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Rally - Reviewer]

Clean, well-motivated change that improves @env.now() precision on the native backend from second-level to millisecond-level. The old implementation called C's time() (second precision) and multiplied by 1000, which meant sub-second time differences were lost. The new implementation directly calls moonbit_get_ms_since_epoch from the updated native runtime, which provides true millisecond precision. The change reduces 7 lines to 1, maintains the same now_internal() -> UInt64 signature so callers are unaffected, and the dependency on the new runtime API is documented in the PR description with a link to the runtime commit.

@bobzhang bobzhang force-pushed the Guest0x0/fix-native-now-precision branch from dea6aca to 55a96d3 Compare April 2, 2026 08:56
@bobzhang bobzhang enabled auto-merge (rebase) April 2, 2026 08:57
@bobzhang bobzhang merged commit f02cfea into main Apr 2, 2026
14 checks passed
@bobzhang bobzhang deleted the Guest0x0/fix-native-now-precision branch April 2, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants